Author Archives: Lin Zhang

Add an assembly into .wsp package

I have a project that needs to use Microsoft Exchange WebServices (Microsoft.Exchange.WebServices.dll). After I deployed the solution into SharePoint 2016, sometimes I receive the following error: System.IO.FileNotFoundException: Could not load file or assembly ‘Microsoft.Exchange.WebServices, Version=, Culture=neutral, PublicKeyToken=31bf3856ad364e35’ or one of … Continue reading

Posted in SharePoint 2010, SharePoint 2016, Visual Studio 2010, Web Service | Leave a comment

System.Net.WebRequest throws a “(401) Unauthorized” error: The Double Hop Syndrome.

When using System.Net.WebRequest to POST (or GET) data to a SharePoint page, a 401 Unauthorized error occurs. For example: Uri address = new Uri(“”); System.Net.WebRequest request = System.Net.WebRequest.Create(address); request.Credentials = System.Net.CredentialCache.DefaultCredentials; request.Method = “GET”; System.Net.WebResponse response = request.GetResponse();  response.Close(); The … Continue reading

Posted in Visual Studio 2010, SharePoint 2016 | Leave a comment

Get error messages by Correlation ID

When I get an error in SharePoint with a correlation ID, I find it easy to use the following PowerShell script to search for the detailed error message within the farm: Add-PsSnapin Microsoft.SharePoint.PowerShell Merge-SPLogFile -Path C:\Temp\log\log.txt -Level “Unexpected” -Correlation 6911329e-d6ff-c016-d2d4-1cd533dc1c03 … Continue reading

Posted in SharePoint 2010, PowerShell, SharePoint 2016 | Leave a comment

Add SharePoint Web Services

In Solution Explorer, right-click the name of the project that you want to add the service to, and then click Add Service Reference. The Add Service Reference dialog box appears. In the Add Service Reference dialog box, click the Advanced button. The Service Reference Settings dialog box appears. In the Service … Continue reading

Posted in SharePoint 2010, Web Service, SharePoint 2016 | Leave a comment

Event Receiver does not fire

I wrote an event receiver for a list but it seems not firing when you add/update/delete an item. I used the following Powershell script to see what event receivers that are attached to this list: Add-PsSnapin Microsoft.SharePoint.PowerShell $spWeb = Get-SPWeb … Continue reading

Posted in PowerShell, SharePoint 2010 | Leave a comment

Get all items from a list performance

Running on a list with 4,000 items. Option 1 is on average 1 second slower than Option 2. Option 1: using (SPSite currentSite = new SPSite(SPContext.Current.Site.ID)) { using (SPWeb currentWeb = currentSite.OpenWeb(“crm”)) { DateTime dt1 = DateTime.Now; DateTime dt2 = … Continue reading

Posted in SharePoint 2010, SharePoint 2016, Visual Studio 2010 | Leave a comment

SharePoint 2013/2016 Branding

1. Create a html/css/javascript file using your favorite designer tool; 2. Go to SharePoint >> Site Settings >> Designer Manager; 3. Go to “Step 3 Upload design files” and Map the following location as a network drive so you can … Continue reading

Posted in SharePoint 2016 | Tagged | Leave a comment