Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Debugging SharePoint 2007 Code

How do you debug your SharePoint 2007 code? Since SharePoint runs on a remote server, and I'm developing on a windows xp machine (with the necessary .dll files copied into my GAC), I haven't had much luck with finding easy ways to debug. Breakpoints don't work, etc.

The best way I've come up with is to enable page tracing in the web.config file, write trace messages throughout my code, and access trace.axd whenever I need to debug.

Does anyone have any better suggestions for debugging? Am I missing something?

like image 437
Kyle Trauberman Avatar asked Sep 28 '08 06:09

Kyle Trauberman


2 Answers

From Andrew Connell's blog post on the subject:

Attaching the debugger to GAC'd assemblies: "Why aren't my breakpoints being hit?!?!" Ever been there? Me too... what a PITA that is! What's going on? Well, the assemblies are in the GAC and the Visual Studio debugger can't see the debugging symbols (aka: *.pdb). Unless you've gone through the trouble of setting up a symbol store where all your PDBs are going, you'll need to put the debugging symbols in the same location as the assembly. The trick is finding the folder that contains your DLL in the GAC.

The c:\windows\assembly folder is not a real folder, it's a virtual folder. To get to the REAL folder, do the following:

  • Start » Run
  • %systemroot%\assembly\gac [ENTER]

This will open the GAC folder. Now, poke around until you find a folder that looks like this (you might need to jump up one folder and dive into the MSIL folder): [assembly file name -.DLL extention][assembly version in format of > #.#.#.#]__[assembly public key token].

When you find that folder, open it up and you'll see your assembly. Copy the PDB file to that folder and then attach the debugger for some debugging joy!

like image 85
Mitch Wheat Avatar answered Oct 03 '22 03:10

Mitch Wheat


The best way (even the one endorsed by Microsoft) is to have a Windows 2003 Server with Sharepoint as your local Development machine.

See also this topic.

like image 40
Michael Stum Avatar answered Oct 03 '22 02:10

Michael Stum