Preface
As is described in my initial question I just want to debug custom SharePoint 2010 solutions running in 2010 mode on a SharePoint 2013 farm. This answer is not about changing and re-compiling 2010 code in a 2013 environment.
Requirements
You need at least these artifacts to debug your 2010 solution:
- Source code of your solution
- The corresponding wsp-package
- The corresponding pdb-file for the wsp-package (in fact this is the most important bit; see next)
Getting the pdb-files
The pdb-file is essential for debugging. (Definition see here or here). This great blog article from John Robbins "PDB Files: What Every Developer Must Know" describes in detail how to get the right pdb-file using the dumpbin /headers
command from the Visual Studio tools.
Unfortunately I didn't keep the pdb-file for my 2010 wsp-package I deployed to the 2013 farm. But fortunately I still have access to a SharePoint 2010 VM with Visual Studio 2010. Here is how I generated the needed pdb-file then:
- Get the source code of your solution
- Do a new, clean build and deploy the solution to the 2010 environment from Visual Studio so that a wsp-file is generated.
- Grab the generated dll-file and wsp-package located under
\bin\Debug
.
- Inspect the generated dll-file with
dumpbin /headers
to obtain the information about the needed pdb-file. (In my case I had to use the pdb-file located unter \obj\Debug
not \bin\Debug
.) Grab that pdb-file. Make sure the pdb-file was actually generated for the dll/wsp build before: pdb, dll and wsp should have the same timestamp.
Deploying the solution to SharePoint 2013
Now copy the source code, the wsp-Package and the pdb-file to your 2013 environment.
- Deploy the wsp-Package to your 2013 environment as usual using PowerShell / CA.
- Copy the pdb-file to the exact location the
dumpbin /headers
command told you (see above). The blog article of John Robbins says that there are better places to store your pdb-file but copying it to the exact location did it for me.
Debugging
- Open the source code project in Visual Studio and do not upgrade the project to 2013.
- Just attach to the IIS worker process(es). No need to build the code.
The symbols from the pdb-file should be loaded so that you can debug your solution. See Debug > Windows > Module
from the menu while debugging to check if the pdb-file is loaded.
Now you should be able to debug your 2010 solution running in 2010 mode in a 2013 environment.