Debugging in the GAC

设置vs.net编译时执行如下脚本即可,方便调试那些只能部署在GAC里面的代码,如果执行不过,提示返回代码错误,请把install.bat的编码格式修改为utf-8.

install.bat:
@SET GACUTIL="c:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\Bin\gacutil.exe"
@SET GACDIR = "C:\WINDOWS\assembly\GAC_MSIL\ItemEventReceiver\1.0.0.0__b2d95d5c08f849f8"

Echo Installing ItemEventReceiver.dll in GAC
%GACUTIL% -if bin\debug\ItemEventReceiver.dll

Echo Installing ItemEventReceiver.pdb in GAC
cd %GACDIR%
copy bin\debug\ItemEventReceiver.pdb

iisreset


参考:

Debugging in the GAC

There are sometimes when your assembly almost has to be in the GAC and when you need to debug it.  This was difficult since if you registered a .NET assembly into the GAC the debugger wouldn't break on it.  This is because the .PDB file information didn't get loaded since it's not in the same directory as the DLL.  Here's how to work around that.

1) Install the Assembly in the GAC
2) Start-Run, %SYSTEMROOT%\Assembly\GAC
3) Navigate into the folder with name of the DLL that you want to debug
4) Navigate into the folder with the version number and public key that you want
5) Copy the .PDB file into this directory

Now you'll be able to run a debugger against code running in the GAC.


你可能感兴趣的:(debug)