Posts

Log error in a separate file

You can log your applications errors in separate text file. Use this code public static void WriteException(string msg)         {             try             {                 SPSecurity.RunWithElevatedPrivileges(delegate()                 {                     string LogFile = SPUtility.GetVersionedGenericSetupPath("LOGS",15) + "\\SPErrorLog-" + DateTime.Today.ToString("MM-dd-yyyy") + ".txt";                     StringBuilder sMessage = new StringBuilder();                     msg = msg.Replace("<b>", "");                     msg = msg.Replace("</b>", "");                   ...

Get error with details

You can log error with all details you want. Here is the example. You need to just pass the exception object & it will return you the whole error details which will be very helpful.   public static string GetErrorInfo(Exception ex)         {             StringBuilder errorRows = new StringBuilder();             StackTrace stackTrace = new StackTrace(ex, true);             StackFrame stackFrame = stackTrace.GetFrame(stackTrace.FrameCount - 1);             MethodBase methodBase = null;             try             {                 methodBase = stackFrame.GetMethod();             }             catch { }             errorRows.AppendLine("<b>S...

Publishing Features for Site Collection & Web

If you are going to created & deploy the custom master page then you should activate the following publishing features : Display Name PublishingSite Title SharePoint Server Publishing Infrastructure Scope Site ID f6924d36-2fa8-4f0b-b16d-06b7250180fa Description Provides centralized libraries, content types, master pages and page layouts and enables page scheduling and other publishing functionality for a site collection. Display Name PublishingResources Title Publishing Resources Scope Site ID aebc918d-b20f-4a11-a1db-9ed84d79c87e Description Enable Publishing for site collection. Display Name Publishing Title Publishing Scope Web ID 22a9ef51-737b-4ff2-9346-694633fe4416 Description Enable Publishing in a web. Display Name PublishingLayouts Title Page Layouts and Master Pages Pack Scope Site ID d3f51be2-38a8-4e44-ba84-940d35be1566 Description Publishing Lay...

Unable to create publishing pages in the pages library in SharePoint 2013

Go to  Original Post   Reproduction Steps: 1) Browse to: https://contoso.com/site/myteam 2) site Actions 3) View All Site Content 4) Pages 5) Library Tools > Documents 6) New Document 7) Page 8) Get an error message saying: An unexpected error has occurred. Troubleshoot issues with Microsoft SharePoint Foundation. Correlation ID: 5a3ab0c7-9b95-4c20-a5a7-04637fe0a120 Date and Time: 2013/12/04 04:19:04 PM When you pull the ULS logs you see: Microsoft.SharePoint.Publishing.InvalidPublishingWebException: The site is not valid. The ‘Pages’ document library is missing. at Microsoft.SharePoint.Publishing.PublishingWeb.GetPublishingListWithCleanup(PublishingListType list, Boolean throwExceptionOnInvalidWeb) at Microsoft.SharePoint.Publishing.Internal.CodeBehind.BasePageSettingsPage.get_PageListRoot() at Microsoft.SharePoint.Publishing.Internal.CodeBehind.BasePageSettingsPage.SetParentUrlLabel() at Microsoft.SharePoint.Publishing.Internal.CodeBehind.BasePageSettingsPage.LoadValues()...

Create SharePoint 2013 Project on your local machine where you don't have SharePoint 2013 installed in Visual Studio 2013

Go to the SharePoint Server where you have SharePoint 2013 is installed & follow the steps: Go to Run and type "regedit" Navigate towards HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Office Right click on 15.0 and click Export. Save the exported file Now go to your machine where SharePoint is not installed and follow these steps: Now open Registry on your machine Import the 15 directory which was exported from SharePoint server Open Powershell Run this command Set-ItemProperty -Path "HKLM:\Software\Microsoft\Shared Tools\web server extensions\15.0\" -Name "Location" -Value "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\15\" Now open visual studio 2013 & create new solution for SharePoint 2013 , You won't get any error message.