Showing posts with label Development. Show all posts
Showing posts with label Development. Show all posts

Thursday, 20 February 2014

patterns & practices SharePoint Guidance

patterns & practices SharePoint Guidance​
 
 
Error Logging in SharePoint
http://spmatt.wordpress.com/tag/sharepoint-guidance-library/

SharePoint 2013 development overview



http://msdn.microsoft.com/en-us/library/ff798413.aspx


Put the JavaScript or XAP files in a SharePoint library, and enable binary large object (BLOB) caching. BLOB caching instructs SharePoint to cache BLOB content, such as JavaScript and XAP files, on the SharePoint Web front-end servers. It also enables client browsers to cache the content. If BLOB caching is not enabled, the HTTP header that returns the JavaScript or XAP resources to the client will instruct the browser not to cache the files. It does this by including a cache-control: private directive and by setting an expiration time in the past. As a result, neither the client browser nor the web front-end server will cache the content, which instead will be retrieved from the content database on every request. BLOB caching is a SharePoint Server 2010 feature and must be enabled in the configuration files for the SharePoint web applications, so to some degree you are at the mercy of the farm administrator. For more information on BLOB caching, see Disk-Based Caching for Binary Large Objects.
http://msdn.microsoft.com/en-us/library/aa604896.aspx 

REST in SP2010



SHAREPOINT GUIDANCE FOR SHAREPOINT 2013
http://graegert.de/blog/sharepoint-guidance-for-sharepoint-2013/ 

SharePoint Development Debugging

I've been reading a lot of posts on how to get debugging going when attaching to the w3wp.exe process.

Disable 'Enable Just My Code' in Visual Studio

This blog post started me off in the correct direction by setting the Tools | Options | Debugging setting correctly.

Modify the web.config

Furthermore, it prompted me to change the web.config value from debug="false" to debug="true". The web.config file can be found in the Inetpub\wwwroot\wss\VirtualDirectories\ folder, each folder in there maps to an IIS Web Application which you can find by going to IIS Manager and looking at the Home Directory.
To get full blown ASP.NET errors rather than SharePoint branded "useless" ones follow these steps:

Setting CallStack=true

By default, WSS will redirect a user to the error page whenever an unhandled exception is encountered during the render cycle.  To disable this behavior, open your web.config and set CallStack="true" in the <SafeMode> node.  This allows you to see a typical Asp.net error page.

Setting customErrors mode...

The next step would be set mode="Off" in the <customErrors> node.  This instructs Asp.net to show you a complete error report rather than a generic "Server Error" page.

Creating pdbs

For each project you wish to debug, you need to ensure that you are creating pdbs. I am using the really cool stsdev app to create my projects and had to modify it to create pdbs by going to Project Properties and on the Build tab in the Output Section click the Advanced button. 
Then ensure that Debug Info is set to pdb-only. 


Attach to Process

The author of the previous referenced post also pointed me to running iisapp on the command line to output a list of all the running instance to know which process to attach to:
Then when you select Debug | Attach to Process the ID matches to the PID in the output of iisapp. Note you need to check 'Show processes from all users' as w3wp.exe will be typically running as another account.

You can check that you have the correct id by pressing CTRL-ALT-U and this will list all the Modules that are loaded with statuses on the symbols that are available (e.g. that when you create a breakpoint it'll work rather than giving you a 'No symbols loaded' errror).

Sometimes there are just too many instances of w3wp.exe to pick from. An easy way to just let the system sort things out for you, rather than inserting a breakpoint, is to insert the following line in your code:
System.Diagnostics.Debugger.Break();

Notes for Visual Studio Debugging Newbies


Once you are actually debugging and can step through code after it breaks on a breakpoint...you can also use the Immediate window to inspect objects by pressing CTRL-ALT-I. From here you can get up intellisense on any object in context which is a great way to inspect things like whether a SharePoint list has an Event Receiver on it or not. 
 

The web server process that was being debugged has been terminated by Internet Information Services (IIS)

If you are debugging in IIS7.0 you will find that you will receive this error if you leave it on a break point for too long.



 
Unknown macro: {NewCode}
---------------------------
Microsoft Visual Studio
---------------------------
The web server process that was being debugged has been terminated by Internet Information Services (IIS). This can be avoided by configuring Application Pool ping settings in IIS. See help for further details.
---------------------------
OK Help
---------------------------

The Resolution is to follow these steps on MSDN - Error: Web site worker process has been terminated by IIS
 


Optimizing SharePoint sites



source: https://www.nothingbutsharepoint.com/sites/devwiki/SP2007Dev/Pages/SharePoint%20Development%20Debugging.aspx

Register Telerik 2013.2.611.35

Drag & drop these file to ‘windows\assembly’ folder:
Telerik.Web.UI.dll
Telrik.Web.Design.dll 
Add these <SafeControl> entries within the <SafeControls> section in web.config:
 
      <SafeControl Assembly="Telerik.Web.UI, Version=2013.2.611.35, Culture=neutral, PublicKeyToken=121fae78165ba3d4" Namespace="Telerik.Web.UI" TypeName="*" Safe="True" SafeAgainstScript="False" />
      <SafeControl Assembly="Telerik.Web.UI, Version=2013.2.611.35, Culture=neutral, PublicKeyToken=121fae78165ba3d4" Namespace="Telerik.Web.UI.Editor" TypeName="*" Safe="True" SafeAgainstScript="False" />
      <SafeControl Assembly="Telerik.Web.UI, Version=2013.2.611.35, Culture=neutral, PublicKeyToken=121fae78165ba3d4" Namespace="Telerik.Web.UI.Widgets" TypeName="*" Safe="True" SafeAgainstScript="False" />
      <SafeControl Assembly="Telerik.Web.UI, Version=2013.2.611.35, Culture=neutral, PublicKeyToken=121fae78165ba3d4" Namespace="Telerik.Web.Design" TypeName="*" Safe="True" SafeAgainstScript="False" />
 
 
Add the clause below to SharePoint 2010 web.config file:
    <pages>
      <controls>
       .....................
        <add tagPrefix="telerik" namespace="Telerik.Web.UI" assembly="Telerik.Web.UI, Version=2013.2.611.35, Culture=neutral, PublicKeyToken=121fae78165ba3d4" />
       </controls>
    </pages>
 
    <modules runAllManagedModulesForAllRequests="true">
       .....................
      <add name="RadUploadModule" type="Telerik.Web.UI.RadUploadHttpModule, Telerik.Web.UI" preCondition="managedHandler" />
    </modules>
 
 
    <handlers>
       .....................
      <add name="ChartImage.axd_*" path="ChartImage.axd" verb="*" type="Telerik.Web.UI.ChartHttpHandler, Telerik.Web.UI, Culture=neutral, PublicKeyToken=121fae78165ba3d4" preCondition="integratedMode" />
      <add name="Telerik.Web.UI.SpellCheckHandler.axd_*" path="Telerik.Web.UI.SpellCheckHandler.axd" verb="*" type="Telerik.Web.UI.SpellCheckHandler, Telerik.Web.UI, Culture=neutral, PublicKeyToken=121fae78165ba3d4" preCondition="integratedMode" />
      <add name="Telerik.Web.UI.DialogHandler.aspx_*" path="Telerik.Web.UI.DialogHandler.aspx" verb="*" type="Telerik.Web.UI.DialogHandler, Telerik.Web.UI, Culture=neutral, PublicKeyToken=121fae78165ba3d4" preCondition="integratedMode" />
      <add name="Telerik.RadUploadProgressHandler.ashx_*" path="Telerik.RadUploadProgressHandler.ashx" verb="*" type="Telerik.Web.UI.Upload.RadUploadProgressHandler, Telerik.Web.UI" preCondition="integratedMode" />
      <add name="Telerik.Web.UI.WebResource.axd_*" path="Telerik.Web.UI.WebResource.axd" verb="*" type="Telerik.Web.UI.WebResource, Telerik.Web.UI" preCondition="integratedMode" />
 
    </handlers>
   
<httpHandlers>
      <remove verb="*" path="*.asmx" />
       .....................
      <add verb="*" path="Telerik.RadUploadProgressHandler.ashx" type="Telerik.Web.UI.Upload.RadUploadProgressHandler, Telerik.Web.UI" />
      <add verb="*" path="Telerik.Web.UI.DialogHandler.aspx" type="Telerik.Web.UI.DialogHandler, Telerik.Web.UI, Culture=neutral, PublicKeyToken=121fae78165ba3d4" />
      <add verb="*" path="Telerik.Web.UI.SpellCheckHandler.axd" type="Telerik.Web.UI.SpellCheckHandler, Telerik.Web.UI, Culture=neutral, PublicKeyToken=121fae78165ba3d4" />
      <add verb="*" path="ChartImage.axd" type="Telerik.Web.UI.ChartHttpHandler, Telerik.Web.UI, Culture=neutral, PublicKeyToken=121fae78165ba3d4" validate="false" />
      <add path="Telerik.Web.UI.WebResource.axd" verb="*" type="Telerik.Web.UI.WebResource, Telerik.Web.UI" validate="false" />
 
    </httpHandlers>
 
    <httpModules>
       .....................
      <add name="RadUploadModule" type="Telerik.Web.UI.RadUploadHttpModule, Telerik.Web.UI" />
    </httpModules>   
 
 
 
 http://yanziyang.wordpress.com/2010/11/01/config-telerik-ajax-in-sharepoint-2010/ 

 

Register the twitter certificate with sharepoint 2010

$root = New-Object System.Security.Cryptography.X509Certificates.X509Certificate2("C:\Maintenance_Sarah\VeriSignForTwitter.cer")
New-SPTrustedRootAuthority -Name "VeriSignForTwitter.cer" -Certificate $root

SharePoint 2010 and Cert Trust – Could not establish trust relationship for the SSL/TLS secure channel


Visual Studio 2010 usefull custom settings

Tools>Options>
Projects and Solutions>General-->check the "Show Output window when build starts".
Text Editor>All Languages-->Check the "Line Numbers" under "Display" section.

customerrors mode off

During the developing of a custom field, I faced some errors, but the didn't work. 
After some search, it seems that you have to do this trick on three locations. SharePoint 2010 has web.config files on the following locations:

  • C:\inetpub\wwwroot\wss\VirtualDirectories\80\
  • C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\CONFIG\
  • C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\LAYOUTS
On all these locations you can find a web.config file.
Change customerrors to:

<customErrors mode="Off" />
and the SaveMode tag (if available) to:

<SafeMode MaxControls="200" CallStack="true" DirectFileDependencies="10" TotalFileDependencies="50" AllowPageLevelTrace="true">
as well as the compilation tag to:


<compilation batch="false" debug="true" optimizeCompilations="true">



http://msdn.microsoft.com/en-us/library/ee231550.aspx

How to Turn Off SharePoint Custom Error Message and Display Stack and Page Output Trace