Friday, November 14, 2014

sharepoint 2010 entity (external content type) cannot be found with namespace =

I was getting this error after redeploying a solution with BDC model. There are few ways described in below posts about fixing them, but in our case they did not work

http://www.sharepointing2010.com/2013/09/restore-bcs-ect-external-content-type.html

http://sharepointpromag.com/sharepoint/deploy-vs-business-data-connectivity-model-solution-sharepoint

Finally, we exported the BDC model from dev server central admin site and imported it on the live server central admin site which worked fine...

There might be a better and more ideal solution available to this problem, but for now we are relieved.

Friday, October 10, 2014

Create a SharePoint 2013 app

The posts below explain how to create basic and advanced apps in SharePoint 2013. These apps access SharePoint object model through Client object model or through rest web services or OData model. Thus our code is lot more safe and secure, it can be easily managed and the application as a whole is a lot more flexible. Please note that the basic .Net framework version used is 4.5.

http://msdn.microsoft.com/en-us/library/office/fp142379(v=office.15).aspx

http://www.codeproject.com/Articles/690015/SharePoint-Online-App-Development-Part

http://sharepoint.stackexchange.com/questions/54008/how-to-create-apps-for-sharepoint-2013-in-visual-studio-2012


In SharePoint 2013 development can be done either in "Napa" web development platform or visual studio of SharePoint designer.


SharePoint 2013 Identity Model and claims aware apps

The new SharePoint 2013 Identity authentication model has lot of cool features, however configuring it the right way is absolute essential for our apps to be able to use it, here are some links which throw more light on that aspect

http://technet.microsoft.com/en-us/library/jj715264(v=office.15).aspx

http://www.harbar.net/articles/fimportal.aspx

http://thesharepointfarm.com/2013/06/using-an-external-identity-manager-for-sharepoint-user-profile-synchronization/


Thursday, October 2, 2014

Sharepoint cache.ini access denied permission issue

Visual studio remote debugging symbol files location

Visual studio has a great facility to do remote debugging which is a lifesaver in many cases where our code works at one location but then fails to run properly at some other location. However, we need to be careful while using the remote debugger components. I have listed the major points to consider below:


  1. There are two separate debugging tools for x86 and x64 environmets
  2. Remote debugger on the remote machine needs to be run with the same user account as the user account used to run visual studio on development machine. (There is an option to relax permission settings and allow any user to debug, but when I tried to use it, it didn't work for some reason.)
  3. Debug symbol files (.pdb) location is very important, since visual studio has to be able to locate these files on local as well as the remote machine. The rule of thumb in this case is to place them at the same relative location on both development machine and the remote machine. A detailed explanation can be found in this post http://www.wintellect.com/blogs/jrobbins/visual-studio-remote-debugging-and-pdb-files


Tuesday, September 30, 2014

sharepoint deploy operation is not valid due to the current state of the object

I was getting this error while deploying solution when I added an event receiver for ItemAdded event for document libraries. It disappears after removing the elements.xml file from event receiver schema.

Email handler SPEmailEventReceiver does not work in multiple server farm setup

I came across this situation after developing an email event receiver on dev with standalone sharepoint 2010 installation which was working perfectly fine, but for some reason it was not being fired at all when deployed to the live server with multiple server sharepoint farm. All other things were absolutely fine with the live server and the document library would receive email using OOTB email receiving settings.

After searching a lot through intenet and scraching my head, I came across this post which explains the reason and solution. Thank you Benjamin

http://blog.creative-sharepoint.com/2012/01/sharepoint-2010-email-event-reciever-not-working-in-a-farm/

On another note, a web.config modification also needs to be deployed in a different way on multiple server farm setup. The post below explains just that

http://blogs.msdn.com/b/malag/archive/2009/05/22/spwebconfigmodification-does-not-work-on-farms-with-multiple-wfes.aspx

Wednesday, September 24, 2014

Xpath if else statement

Now this is something... I would like to never recall again :)

I came across a situation where I had to use if..else like statement in Infopath XPath expression and below post solved that problem beautifully..

http://stackoverflow.com/questions/971067/is-there-an-if-then-else-statement-in-xpath


Some more magic in X Path can be seen here

http://incrementaldevelopment.com/xsltrick/


But even after that.. I would prefer to stay away from X Path ;-)

Wednesday, September 17, 2014

Free pdf libraries

Open webpart page in maintenance view

To open a webpart page in maintenance view follow these steps:


  1. Open the document or assets library that contains the page.
  2. Click the Documents or Files tab, select the page, and then in the Manage group, click Edit Properties.
  3. Click Open Web Part Page in maintenance view to display the Web Part Maintenance Page.
Alternatively add ?contents=1 after the page name in url bar

Email mime reader

Codeplex has great utility to read and parse mime email messages

http://mimeparser.codeplex.com/

Tuesday, September 16, 2014

Specified value is not supported for the urlOfFile parameter

This error is misleading, actually we should not use SPFolder.Files collection to retrieve SPFile object the correct way is to use SPWeb.GetFile method.

Reference:
http://www.sharepointnadeem.com/2012/01/urloffile-parameter-name-specified.html

Thursday, September 11, 2014

Rename sharepoint server

Renaming a sharepiont server can get you in serious trouble unless you follow very careful approach. This blog has very useful information which has helped our team resolve the issue that central admin site was unavailable after renaming SP 2010 server

http://blog.walisystemsinc.com/2012/08/how-to-change-sharepoint-2010-server.html

Run miisactivate.exe

This post explains how to fix this error in sharepoint 2010 environment

http://blog.helloitsliam.com/Lists/Posts/Post.aspx?ID=7

Wednesday, September 10, 2014

Email with Embedded (Inline) image in sharepoint

In asp.net we can send an email with inline image as explained in this post
http://stackoverflow.com/questions/18358534/send-inline-image-in-email

But in sharepoint the procedure is slightly different. I have used below post to do the stuff

http://sharepoint-tamizha.blogspot.co.uk/2013/08/send-email-with-embedded-images-in-c.html


And the final code looks like


byte[] imgByte = null;
SPFile file = SPContext.Current.Web.GetFile(ImageUrl);
                                            imgByte = file.OpenBinary();

// Creating Unique ID for adding image referrence
string GUId1 = Guid.NewGuid().ToString();               

// frame the HTML with the img tag and above unique id
string htmlBody = "<html><body><div><img src=\"cid:" + GUId1 + "\"></div></body></html>";

// Create alternateview object with Mime type HTML
AlternateView avHtml = AlternateView.CreateAlternateViewFromString
                    (htmlBody, nullMediaTypeNames.Text.Html);

//Create object for Linked Resource with the Image physical path or Image Stream
MemoryStream stream = new MemoryStream(imgByte);
                LinkedResource pic1 = new LinkedResource(stream, "image/png");

// Provide the previously created Unique ID to associate the Image with the respective img src.
pic1.ContentId = GUId1;

//Add the Linked Resource to the AlternateView
avHtml.LinkedResources.Add(pic1);

string from = SPContext.Current.Web.Site.WebApplication.OutboundMailSenderAddress;

string smtpAddress =SPContext.Current.Web.Site.WebApplication.OutboundMailServiceInstance.Server.Address;

// Assign SMTP address
SmtpClient smtpClient = new SmtpClient();
smtpClient.Host = smtpAddress;

MailMessage mailMessage = new MailMessage(from, toRecipients);
mailMessage.Subject = subject;

// Add the Alternate view with the Mail message
mailMessage.AlternateViews.Add(avHtml);
mailMessage.IsBodyHtml = true;


smtpClient.Send(mailMessage);

Monday, September 8, 2014

Scheduled reminders in Sharepoint 2007

While surfing through google search results I found this great utility created by Mullivan for sp 2007,

http://www.codeproject.com/Articles/32753/Send-scheduled-Reminder-Alerts-by-email-in-SharePo

I can be easily modified to work for SP 2010 and it has a lot of features.


Monday, August 11, 2014

Sharepoint CSS cache issue

Below post from Chris O'Brian has some useful ideas to keep css refreshed with each version

http://www.sharepointnutsandbolts.com/2011/11/avoiding-bugs-from-cached-javascript.html

SharePoint 2010 Error: No language-neutral solution exists in the store

While uninstalling wsp solution using Remove-SPSolution command, I suddenly started getting this error

Uninstalling solution: MySolution.wsp.

Solution uninstalled.
Removing solution: MySolution.wsp
Error occurred, during SharePoint deployment.
Object reference not set to an instance of an object.

After investigating further, I found out that a solution with the name already exists in the solution store, so after searching on internet I found out that a temporary work around is to remove solution entry from SharePoint_Config database and then add it back again using the same powershell script.

http://ftduarte.blogspot.co.uk/2009/07/sharepoint-no-language-neutral-solution.html?_sm_au_=iVVFhhM3k6FkL4Np

Friday, August 8, 2014

COMException: 0x80131904 while deleting sharepoint 2010 files


I was getting below error while trying to delete files in a sharepoint 2010 site collection.


StackTrace: ' at Microsoft.SharePoint.SPGlobal.HandleComException(COMException comEx)
at Microsoft.SharePoint.Library.SPRequest.DeleteItem(String bstrUrl, String bstrListName, Int32 lID, UInt32 dwDeleteOp, Guid& pgDeleteTransactionId) at Microsoft.SharePoint.SPListItem.DeleteCore(DeleteOp deleteOp) at Microsoft.SharePoint.SPListItem.Delete() at VFS.PMS.ApplicationPages.CommonMaster.DeleteCompetenciesDraft(Int32 appraisalPhaseId, String currentUser, String listName) at VFS.PMS.ApplicationPages.Layouts.H2initial.SelfEve.SaveCompetenciesDraft(Int32 appraisalID, Int32 appraisalPhaseId, String listName) at VFS.PMS.ApplicationPages.Layouts.H2initial.SelfEve.b_0() at Microsoft.SharePoint.SPSecurity.<>c_DisplayClass4.b__2() at Microsoft.SharePoint.Utilities.SecurityContext.RunAsProcess(CodeToRunElevated secureCode) at Microsoft.SharePoint.SPSecurity.RunWithElevatedPrivileges(WaitCallback secureCode, Object param) at Microsoft.SharePoint.SPSecurity.RunWithElevatedPrivileges(CodeToRunElevated secureCode) at VFS.PMS.ApplicationPages.Layouts.H2initial.SelfEve.btnSave_Click(Object sender, EventArgs e)' Source: 'Microsoft.SharePoint' TargetSite: 'Void HandleComException(System.Runtime.InteropServices.COMException)' ------------------------------------------------------------ Inner exception:
------------------------------------------------------------ ExceptionType: 'COMException' ExceptionMessage: '0x80131904'
StackTrace: ' at Microsoft.SharePoint.Library.SPRequestInternalClass.DeleteItem(String bstrUrl, String bstrListName, Int32 lID, UInt32 dwDeleteOp, Guid& pgDeleteTransactionId) at Microsoft.SharePoint.Library.SPRequest.DeleteItem(String bstrUrl, String bstrListName, Int32 lID, UInt32 dwDeleteOp, Guid& pgDeleteTransactionId)' Source: '' TargetSite: 'Void DeleteItem(System.String, System.String, Int32, UInt32, System.Guid ByRef)' 8f922003-389d-4edf-b75f-7e69c5818a7a



It was resolved after I added myself in farm administrators group and then gave dbo permissions on the content database for the site collection and then shrinked database files using below post

http://support.powerdnn.com/kb/a447/how-to-shrink-your-mssql-database-log-file-truncate.aspx

More reference can be found in the comments in the post below:

http://stackoverflow.com/questions/10723746/sharepoint-2010-error-0x80131904-after-uploading-large-amount-of-files



Powershell command to delete sharepoint files

I have used poweshell commands from below post to delete files from sharepoint document libraries

http://sharepoint.stackexchange.com/questions/6511/download-and-delete-documents-using-powershell

Thursday, June 26, 2014

Regular expression to find src attribute value of img tag

This regex is very handy when we want to parse html tags and use them in our code

Regex reSrc = new Regex(@"src=(?:(['""])(?<src>(?:(?!\1).)*)\1|(?<src>[^\s>]+))", RegexOptions.IgnoreCase | RegexOptions.Singleline);

Match mSrc = reSrc.Match(htmlImageTag);

if (!string.IsNullOrEmpty(mSrc.Groups["src"].Value))
{
         string imageUrl = mSrc.Groups["src"].Value;
}



Refer:http://www.experts-exchange.com/Programming/Languages/Regular_Expressions/Q_23964786.html

Tuesday, June 10, 2014

Javascript Clear all timeouts and intervals

I came across the reuqirement in a project to use mouse over, mouse out as well as mouse click methods to call some javascript functions which basically rotate a carousel. I tried a lot to use OOTB setTimeout and clearTimeout methods but they seem to have created multiple instances of the setinterval methods. Therefore after searching a bit I came across following solution which works like a magic!

Modify OOTB methods to store and retrieve all timer ids while clearing them.

window.timeoutList = new Array();
window.intervalList = new Array();

window.oldSetTimeout = window.setTimeout;
window.oldSetInterval = window.setInterval;
window.oldClearTimeout = window.clearTimeout;
window.oldClearInterval = window.clearInterval;

window.setTimeout = function(code, delay) {
    var retval = window.oldSetTimeout(code, delay);
    window.timeoutList.push(retval);
    return retval;
};
window.clearTimeout = function(id) {
    var ind = window.timeoutList.indexOf(id);
    if(ind >= 0) {
        window.timeoutList.splice(ind, 1);
    }
    var retval = window.oldClearTimeout(id);
    return retval;
};
window.setInterval = function(code, delay) {
    var retval = window.oldSetInterval(code, delay);
    window.intervalList.push(retval);
    return retval;
};
window.clearInterval = function(id) {
    var ind = window.intervalList.indexOf(id);
    if(ind >= 0) {
        window.intervalList.splice(ind, 1);
    }
    var retval = window.oldClearInterval(id);
    return retval;
};
window.clearAllTimeouts = function() {
    for(var i in window.timeoutList) {
        window.oldClearTimeout(window.timeoutList[i]);
    }
    window.timeoutList = new Array();
};
window.clearAllIntervals = function() {
    for(var i in window.intervalList) {
        window.oldClearInterval(window.intervalList[i]);
    }
    window.intervalList = new Array();
};


Copied from http://stackoverflow.com/questions/3141064/how-to-stop-all-timeouts-and-intervals-using-javascript

Tuesday, June 3, 2014

SharePoint 2010 remove customization (Reghost) a master page or page layout file

Use the below script and change file name to the desired object


---------------------------------------------------------------------------


$s = Get-SPSite "http://<server name>/"
$w = $s.RootWeb

$ps = New-Object Microsoft.SharePoint.Publishing.PublishingSite($s)
$pls = $ps.PageLayouts
    
      
    $f = $w.GetFile("/_catalogs/masterpage/<Page Layout Name>.aspx")
Write-Host $f.CustomizedPageStatus
    if ($f.CustomizedPageStatus -eq "Customized")
    {
        Write-Host
        Write-Host "Layout page name: " -NoNewline
        Write-Host $f.Name        
        Write-Host "Status before: " -NoNewline

        Write-Host $f.CustomizedPageStatus
         
        #$f.RevertContentStream()
      
        Write-Host "Status after: " -NoNewline
        Write-Host $f.CustomizedPageStatus
    }

    
$w.Dispose()
$s.Dispose()

Wednesday, April 16, 2014

JQuery does not work with SVG files

The libraries mentioned below have some of the latest javascript functionalities, but I had a problem surfing through the correct library which provides an implemention for indexOf() function on an svg map area.

http://keith-wood.name/svg.html#dom
http://www.farinspace.com/top-svg-javascript-libraries-worth-looking-at/

Tuesday, April 1, 2014

Error: Some of the files failed to copy during deployment of the solution.

Sometimes installation of a wsp package to SharePoint 2010 server fails with the error message
"Some of the files failed to copy during deployment of the solution. <Server Name> : <Server URL>: SharePoint - 80 : Error: The copying of this file failed: MyProject.dll.
I/O error occurred.
<Server Name>: I/O error occurred."

After digging I found out that this was due to the dll in bin folder being locked by sharepoint 2010 timer services job.

Below powershell script stops and starts the timer job service again

http://practicalkungfu.net/2012/10/05/sharepoint-2010-restart-the-timer-service-on-all-service-in-the-farm-remotely/


Monday, March 17, 2014

Excel rest api with secure store service

Handy reference to sharepoint and office integrated development ideas

Read or write data in an excel workbook using excel services in sharepoint 2010

client object model the remote server returned an error (500) internal server error

Friday, February 7, 2014

Display svg image in asp.net and sharepoint 2010

http://forums.asp.net/p/1083772/1714230.aspx?Re+SVG+with+ASP+NET+

Using suggestion in the above post, I created a .html file instead of .aspx file which simply has all the .svg file xml in it. And then the svg image was displayed in another .aspx file as

<!-- World map start -->
<div class="worldMap">
<embed src="/images/WorldMap.html" width="100%" height="100%" type="image/svg+xml">
 </div>
<!-- World map end -->

c# httpclient The remote certificate is invalid according to the validation procedure: RemoteCertificateNameMismatch

 If we get this error while trying to get http reponse using HttpClient object, it could mean that certificate validation fails for the remo...