Debugging NHibernate: prepare symbol files

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 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\ -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\ 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:


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 :).

One thought on “Debugging NHibernate: prepare symbol files

Leave a Reply

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

You are commenting using your 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 )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.