Monday, March 2, 2009

How to remote debug .Net assemblies that are deployed in GAC

Usually when you want to remote debug a .Net assembly, you would just run vsmon.exe in target machine and connect to it using VS->Tools->Attach Debugger option, Which would list all the processes running under that machine and you would hook in your debugger into desired process.

But when u want to debug an assembly which is deployed as part of GAC, then its not as simple as external process, bcoz you cant load your .mdb(debug file) into GAC, you might load your mdb files files using "Load Modules" option but most of the time VS throws symbols doesnt match error in this case. To make easy there is another way, go to your target machine, open win explorer and type windir/assembly/GAC_MSIL, now this would list all folders that are deployed in GAC, search for your assembly name, open the folder, you would find your dll file. Now copy your .mdb file and paste here. Now connect your VS debugger to the process which is using this GAC assembly. You would be able to debug your GAC assemblies without any issues.