Alexander Anikin's blog

My personal blog

Sharepoint 2010: Debug and trace into Microsoft.Sharepoint.dll using Reflector

leave a comment »

 

Hi all!

Task 1. Debuging your event reciever

We have 2 options in Visual Studio 2010 – farm or sandboxed solution.

a. Creating and deploing sandboxed solution – all OK, but many constraints. Not useful in many cases.  Good article: http://soumya-sharepointblog.blogspot.com/2010/01/sharepoint-2010-sandbox-solutions.html

For debug Sandboxed Solutions attach to SPUCHostService.exe

b. Visual Studio 2010 Beta has the problem with deploing solutions to farm:

1. Turn off VS scripts for feature activation.

image

There, you can see option Sandboxed Solution. We can switch this option.

2. Copy Feature files to C:Program FilesCommon FilesMicrosoft SharedWeb Server Extensions14TEMPLATEFEATURES

3. Register feature using

c:Program FilesCommon FilesMicrosoft SharedWeb Server Extensions14BIN>stsadm -o installfeature -force -filename "Sample_Feature1feature.xml"

c:Program FilesCommon FilesMicrosoft SharedWeb Server Extensions14BIN>stsadm -o activatefeature -force -filename "Sample_Feature1feature.xml" -url http://sp001

3. At Project Properties add lines to Post-Build Events for registering my dll in GAC:

"C:Program Files (x86)Microsoft SDKsWindowsv7.0ABinNETFX 4.0 Toolsx64"gacutil.exe -u Sample
"C:Program Files (x86)Microsoft SDKsWindowsv7.0ABinNETFX 4.0 Toolsx64"gacutil.exe -i "C:UsersaanikinDocumentsVisual Studio 2010ProjectsSampleSamplebinDebug"Sample.dll

iisreset –noforce (I’m not sure need it, but I do it.)

image

4. Attach to w3wp.exe processes and debug your code.

Task 2. Step into Microsoft.Sharepoint.dll using Reflector Pro

1. Install Reflector Pro and enable integration with Visual Studio 2010 and Windows Explorer (we need this to open Microsoft.Sharepoint.dll from GAC).

2. Open C:WindowsassemblyGAC_MSILMicrosoft.SharePoint14.0.0.0__71e9bce111e9429cMicrosoft.SharePoint.dll using .NET Reflector menu button Choose Assemblies fo Debug.

3. Debug your solution and set breakpoints to Sharepoint reflectored sources. Visual Studio will stops everywhere you need.

Advertisements

Written by Alex Anikin

April 10, 2010 at 1:27 pm

Posted in Sharepoint

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: