Debugging sharepoint dll's is pretty straight forward and just like any other dll.
What you need:
- The program database file (pdb)
- The source files
- A compatible debugger (VS 2005)
- Access to the dll registered directory (global assembly cache/ webapp bin)
For this example we're gona debug a GAC dll, so the only task post dll registration is to copy the pdb to the GAC directory.
Note: Copying the pdb may NOT be required with VS 2008 as it will look in the project debug directory for the pdb.
To copy the pdb, if required, to the gac you have various options some are listed below by my order of preference.
- Use the subst command to map a drive to the GAC
- Type: Win + R > cmd > Enter
- subst X: %windir%\assembly\gac_msil
You should now have an X: drive pointing to your intermediate language assembly cache. Locate your dll directory and copy the pdb file.
- Use the copy command to copy your pdb file
- Type: Win + R > cmd > Enter
- copy <your_pdb_location> c:\windows\assembly\gac_msil\<your_dll>\<version>__<public_key>
I create a post build event to accomplish this.
- Edit or rename the Desktop.ini file in c:\windows\assembly\
- Type: Win + R > cmd > Enter
- attrib c:\windows\assembly\desktop.ini -h -r -s
rename c:\windows\assembly\desktop.ini desktop.dir
You should now be able to browse the GAC directory.
- Disable cache viewer in the registry
- Type: Win + R > regedit > Enter
- create a new dword key under HKLM\Software\Microsoft\Fusion\ with the nane DisableCacheViewer and set it’s [DWORD] value to 1.
Or you could also just change HKEY_CLASSES_ROOT\CLSID\{1D2680C9-0E2A-469d-B787-065558BC7D43}\Server\ default to xShfusion.dll or delete the value.
You should now be able to browse the GAC directory.
Debugging
- Create a break point.
- Do an IIS reset, cos 90% of the time if you don't you'll crash IIS and VS.
- Open a SharePoint page you know uses the dll
- Attach the w3wp.exe process with your application user id to the debugger.
- Interact with the page until you reach your break point.
works for me , thanks very much.
ReplyDeleteThanks. Very useful.
ReplyDelete