Tuesday, February 06, 2007

Debugging Cassini and Debugging GAC dlls

My Question in ASP.NET forums

"
Hello,
I am trying to debug the source code of Cassini.

I have modified 2 lines of the build.bat file in this way

csc /t:library /keyfile:Cassini.snk /r:System.dll /r:System.Web.dll /debug /out:Cassini.dll AssemblyInfo.cs ByteParser.cs ByteString.cs Connection.cs Host.cs Messages.cs Request.cs Server.cs

csc /nologo /define:DEBUG /t:winexe /r:System.dll /r:System.Drawing.dll /r:System.Windows.Forms.dll /r:Cassini.dll /win32icon:CassiniWebServer.ico /res:CassiniWebServer.ico,CassiniWebServerIcon /out:CassiniWebServer.exe CassiniWebServerMain.cs

Since the Cassini is installed in the GAC. I am unable to debug.

Therefore I removed the assembly from the GAC and modified the build.bat file accordingly.
When I try to debug the solution, I get an exception in

_host = (Host)_appManager.CreateObject(appId, typeof(Host), _virtualPath, _physicalPath, false /*failIfExists*/);

indicating that the file and assembly could not be found.
The error is gone after I remove from the GAC but I am not able to debug it.

Found the solution also.
The solution is

Thanks to Robert Bogue [MVP] blog
Have a look at the link to debug GAC dlls
http://thorprojects.com/blog/archive/2005/08/30/204.aspx
Getting the content again from the blog
"
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.
"
For me in Step3 the path was
C:\WINNT\assembly\GAC_MSIL\Cassini\2.0.60306.0__a2c3042d130f02aa

No comments:

Adda is the Bengali for discussion.Bengali is a language like English.