To be able to debug the NHibernate source code the debugger must know how to find it. If you are using the 3.0.0 version of NHibernate you may use http://www.symbolsource.org configuring Visual Studio to use their symbol store. If your NHibernate version is different you need to either compile NHibernate on your own and reference the produced binaries in your application build process or make use of the sourcepack script. Here I will describe the second approach (especially because I’m the author of the sourcepack and I need to advertise it somehow ;)).
To use sourcepack you will need to install Debugging Tools for Windows (you may install them from the WDK image) and powershell v2. Next step is to download NHibernate binaries (you should have them already in your application bin folder) and NHibernate sources from their sourceforge page.
Now, we are ready to index the NHibernate symbol (pdb) files with the zipped sources. Open powershell console and type:
.\sourcepack.ps1 -sourcesRoot "d:\CSharp\NH\NH\nhibernate\" -sources C:\src\NHibernate-3.1.0.GA-src.zip -symbols C:\temp\sample-app\bin -archiverCommandPath C:\bin\7za\7za.exe -verbose
- d:\CSharp\NH\NH\nhibernate is a path to the source root on a computer where the NHibernate was built (you may check this path using srctool.exe or dbh.exe from the Debugging Tools for Windows – please have a look at my blog for usage examples)
- C:\src\NHibernate-3.1.0.GA-src.zip is a place where you put the downloaded source codes
- C:\temp\sample-app\bin is a place where you have your application binaries (dlls + pdbs)
- C:\bin\7za\7za.exe sourcepack requires a path to the 7za command that will be used by the debugger to extract the necessary source files (sourcepack release already contains the 7za.exe application so just copy it someplace)
After running the command you should see some yellow (verbose) messages and NHibernate pdb files are now linked with the source code zip file. It’s time to test if the debugger will be able to successfully extract them. For this purpose you should again use srctool.exe (it’s located in the srcsrv folder of the Debugging Tools for Windows installation):
srctool -l:*AbstractSessionImpl.cs NHibernate.pdb -x -d:c:\temp\nh-test
The ouput of the upper command should be:
c:\temp\nh-test\src\NHibernate\Impl\AbstractSessionImpl.cs NHibernate.pdb: 1 source files were extracted
If you saw something different you probably made some mistake in the indexing and you will need to rerun it (I know it’s tedious and I have plans to make sourcepack usage a little bit more pleasant). If the previous sentence does not apply to your situation you are ready to fire Visual Studio and start debugging NHibernate sources with your brand new symbol files :).