Skip to main content

Debugging Sharepoint Site Tips


Allow Debugging for SharePoint


Problem

At some point SharePoint developers will need to trace, log and debug their code when they get tripped up with bugs or any weird things when building custom solutions, applications, or components for SharePoint.            

Solution

SharePoint hides the real detailed error messages and debug /tracing information which relate to the error. In order to display it we can debug SharePoint Applications & Solutions using the detailed steps below :
  • Enable debug information and tracing over bugs and exceptions on WSS (Windows SharePoint Services) 3.0 & MOSS (Microsoft Office SharePoint Server) 2007 - Part 1.
  • Enable debug information and tracing over bugs and exceptions on SharePoint 2010 - Part 2.

1.  Enable debug information and tracing over bugs and exceptions on WSS (Windows SharePoint Services) 3.0 & MOSS (Microsoft Office SharePoint Server) 2007:

We can allow debugging/tracing in SharePoint 2007 by using the multiple approaches below:

I. "Debugging with VSEWSS (Visual Studio Extensions For Windows SharePoint Services)": [F5 Debugging]

  1. Locate and open the target SharePoint applications "Web.Config" file . (Usually located at: "C:\Inetpub\wwwroot\wss\VirtualDirectoties\").
  2. Search and find the below line of code and change "debug" attribute to "true" then save the change:
    <compilation batch="false" debug="false"> into <compilation batch="false" debug="true">
  3. Search and find the below line of code and change "CallStack" attribute to "true" then save the changes:
    <SafeMode MaxControls="200" CallStack="false" ...> into <SafeMode MaxControls="200" CallStack="true" ...>
  4. Search and find the below line of code and change "mode" attribute to "Off" then save the changes:
    <customErrors mode="On" /> into <customErrors mode="Off" />
  5. Then in Visual Studio, Right click the SharePoint Project and then click properties.
  6.  Click the "Debug" tab then type the target SharePoint URL in the 'start browser with URL' box. Then, place a breakpoint either by clicking on the line of code or pressing F9 on the selected line of code and then press "F5".

II. "Manual Debugging": [w3wp.exe Attach to Process]

We can debug SharePoint applications without using VSEWSS [F5 Debugging] by attaching to the w3wp.exe process by using the following procedures:
  1. The SharePoint application must use the latest compiled source code. We need to recompile the source code and install the assemblies into the GAC (Global Assembly Cache - usually located at: C:\Windows\assembly). Alternatively, we may need to copy the assemblies to the bin folder of the SharePoint virtual directory. This is usually located at: "C:\Intepub\wwwroot\wss\VirtualDirectories\\bin". In either case we must run  the Microsoft Internet Information Services (IIS) command-line utility "iisreset.exe" by opening a command prompt and typing "iisreset".
  2.  Place a breakpoint in the code that we want to debug.
  3.  Click on the "Debug" menu then click "Attach to Process".
  4.  In the list of available processes, find the W3wp.exe process and then do the following, as applicable:
    •  If the W3wp.exe process is not listed make sure that the "Show processes from all users" & "Show processes in all sessions" check boxes are selected.
    •  If the W3wp.exe process is still not listed, open a web browser and navigate to the application SharePoint site. Then return to the Visual Studio, then "Attach to process" and click the refresh button to locate the W3wp.exe process.
    •  If you see multiple W3wp.exe process listed and ae not sure which one is running the code, we can click them all or open a "cmd" window and type "iisapp" towhich W3wp.exe process number is mapped to our web application port number.
    •  Click the Attach button.

III. "Remote Debugging": [W3wp.exe Remote Attach to Process]

We can debug a SharePoint application which is running on a remote computer by attaching to the remote W3wp.exe process by using the following procedures:
  1. Repeat step (1) at "Manual Debugging".
              
  2. Make sure that the Visual Studio remote debugger is installed on the remote computer and then start theremote debugger monitor.
              
  3.  Then open Visual Studio on the local computer and open the solution. Then set the breakpoints.
              
  4.  Click on the Debug menu. Then click on "Attach to process". Then in the Qualifier text box, type the name of the remote computer and then click Refresh.
              
  5.  Then in the Available Processes list , find the W3wp.exe process then repeat step (4) at "Manual Debugging"

Popular posts from this blog

How to deal with SharePoint 2010 exception "An exception occurred when trying to issue security token: The server was unable to process the request due to an internal error"

Scenario: You receive the below exception when you try to logon to a site that has been configured to use Claims Based Authentication with a custom membership provider using FBA credentials: Event ID from Event Log  - 8306 An exception occurred when trying to issue security token: The server was unable to process the request due to an internal error.  For more information about the error, either turn on IncludeExceptionDetailInFaults (either from ServiceBehaviorAttribute or from the <serviceDebug> configuration behavior) on the server in order to send the exception information back to the client, or turn on tracing as per the Microsoft .NET Framework 3.0 SDK documentation and inspect the server trace logs.. Explanation: This error started to appear in our QA environment which does not have Visual Studio installed. I have tried starting the service "Claims to Windows Token Service" but that did not help either. I have made sure that all config...

Custom Form Base Login Web Part With Sharepoint 2010

In my  Last Post , I talked about creating a Form based authentication web application with Active Directory LDAP. After implementing that you have surely noticed that, when you try to sign in after creating a site collection from FBA web application, you get the following sign in page: Surely, it does not look pretty at all. So, you might want to change this default login page. In order to do this, first let us create an empty SharePoint project in Visual Studio 2010. After that, add an application page by right click-selecting “Add New Item” and you will get like the following window in Solution Explorer: Notice that, when you add any application page to your project, Visual Studio automatically creates a Layouts  folder. To keep things simple enough for your understanding, you may keep your application page under a folder where you might name it as same as your project like the figure above. Now, add a reference for  Microsoft.SharePoint.IdentityModel...

Migrating from Skype for Business to Microsoft Teams: A Step-by-Step Guide

Do you still use Skype for Business to meet the communication and collaboration needs of your business? If so, now is the perfect time to think about switching to Microsoft Teams, a cutting-edge platform with cutting-edge capabilities and seamless connectivity with other Microsoft services. But if you're unfamiliar with the procedure, switching to a new platform can seem like a difficult task. I'll walk you through the process of switching from Skype for Business to Microsoft Teams in this article. Plan the migration in Step 1 You must make a plan before you start the relocation procedure. Set a deadline, make a list of all the Skype for Business capabilities you presently use, and choose whether to migrate gradually or all at once. Step 2: Set up your surroundings. Make sure your network and infrastructure fulfil Microsoft Teams' standards. Upgrades to your hardware, software, and licences might be necessary. Additionally, confirm that you have the right permissions to ca...