Sunday, June 8, 2014

Debugging Sharepoint Application

Defination :

Identifying root cause and removing error from application is called debugging.

Sharepoint Debugging Can be achieved following ways .

1.Developer Dashboard
2.ULS logs
3.Web.config changes
4.Correlation ID
5.Fiddler : REST
6.Windows Server trace.
7.Red gate reflector
 8.Java script Debugging

Developer Dashboard :

Enabling and disabling Developer Dashboard  using power-shell script :

$ErrorActionPreference = 'Stop'
# Load SharePoint PowerShell snapin
Write-Host
Write-Host " Step 1 of 2: Loading SharePoint PowerShell Module" -ForegroundColor Black -BackgroundColor Gray
Write-Host
Write-Host " Verify SharePoint PowerShell Snapin Loaded" -ForegroundColor White
$snapin = Get-PSSnapin | Where-Object {$_.Name -eq 'Microsoft.SharePoint.PowerShell'}
if ($snapin -eq $null) {
Write-Host " .. loading SharePoint PowerShell Snapin..." -ForegroundColor Gray
Add-PSSnapin "Microsoft.SharePoint.PowerShell"
}
Write-Host " Microsoft SharePoint PowerShell snapin loaded" -ForegroundColor Gray
$contentService = [Microsoft.SharePoint.Administration.SPWebService]::ContentService
$devDashboardSettings = $contentService.DeveloperDashboardSettings
Write-Host
Write-Host " Turning on Developer Dashboard" -ForegroundColor White
if ($devDashboardSettings.DisplayLevel -eq "On"){
$devDashboardSettings.DisplayLevel = "Off"
Write-Host "Developer dashboard disabled." -ForegroundColor Gray
} else {
$devDashboardSettings.DisplayLevel = "On"
Write-Host "Developer dashboard enabled." -ForegroundColor Gray
}
$devDashboardSettings.Update()
Write-Host
Write-Host "Finished!" -ForegroundColor Green



SP 2010 Output :

 

 
SP 2013 Output :


Web.Config Changes : 


CallStack=true
CustomErrormode=off
Compilation\@debug=true

Do the changes in root web.config

Location :
C:\inetpub\wwwroot\wss\VirtualDirectories\<<webapplication port>>

To identify the _layout error message :

Compilation\@debug=true  Change of the settings.

C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\LAYOUTS\web.config .


Farm Solution  :
-------------------
w3wp.exe
OwsTimer.exe (Workflows, Timer job,scheduler)

These two will be useful for debug to Farm solutions

Sandbox solution
-----------------

SPUCWorkerProcessor.exe


Client side code : (Such as silver- light and  Java script)
--------------
iexplore.exe


When your Breakpoints is not working ?

Write following line of code in Debug :

System.Diagnostics.Debugger.Break();
or
Debugview   +system.Diagnostics.debugger.WriteLine()



Fiddler : 

This is used for debug  REST (WCF service calls)based API calls.

Example for REST :

http://ServerName/_vti_bin/listdata.svc







 

No comments:

Post a Comment