Hi Phnimx,
Based on my understanding you want to debug your class library assembly
that resides in the GAC.
Can you tell me what type of application that consumes your plug-in
assembly, console, winform, or Asp.net? I assume it is not Asp.net first.
Then, what type of debugging you want to perform over the plug-in
assembly,
source code level, IL level or binrary code level? Do you have the source
code of the class library assembly in project form? Finally, what version
of .Net you using, .Net1.1 or 2.0? This information will help me
understand
your problem context more accurate. Thanks.
Below is my further comment:
#1, yes, after you have deployed the signed assembly to the GAC, CLR will
always load the signed assembly from GAC not your local copy of assembly.
This behavior is defined by the design of CLR probing logic below:
"How the Runtime Locates Assemblies"
http://msdn2.microsoft.com/en-us/library/yx7xezcf.aspx
As you can see the CLR runtime will always check GAC before private
folders. This behavior can not be changed in .Net1.1. However, in .Net2.0,
you can override the probing logic by hosting CLR, please refer to our
Fusion developer Junfeng Zhang's blog below:
"Override CLR Assembly Probing Logic ---
IHostAssemblyManager/IHostAssemblyStore"
http://blogs.msdn.com/junfeng/archive/2006/03/27/561775.aspx
#2, I have used VS2005 to create a test Winform "GACDebuggingTest" project
and adding a class library project into the solution with name "PlugInLib"
and code below:
namespace PlugInLib
{
public class Class1
{
public static int AddInt(int a, int b)
{
return a + b;
}
}
}
The Winform project contains the code below to use the "PlugInLib":
private void button1_Click(object sender, EventArgs e)
{
MessageBox.Show(PlugInLib.Class1.AddInt(3, 5).ToString());
}
I configured these 2 projects as "release".
After signing the "PlugInLib", I drop it into the GAC. Then I use VS2005
debugger to F5 launch the application. By using "Modules" window in the
debugger, I got the GAC version PlugInLib.dll loaded as expected. Path is
listed below:
C:\WINDOWS\assembly\GAC_MSIL\PlugInLib\1.0.0.0__e9b0090aab61820b\PlugInLib.d
ll
Also, in the window, I find the symbol is loaded for PlugInLib.dll, even
if
it is loaded from GAC. Then I set a breakpoint in the class library
project, and the debugger breaks when I clicked the button to call the
"AddInt" method in PlugInLib.dll. So it seems that I can debug the class
library in GAC without any problem. So if you did not move the pdb files
around, debugger should find it without any problem.
A few questions: do you use "release" or "debug" configuration in your
plug-in project? Is your assembly symbol loaded in the debugger? You may
verify it in "Module" window. In VS2005, there is a new feature named
"Just
My Code" which is enabled by default. This means that VS2005 will not load
symbol for non-user code assemblies, such as all .Net BCL assemblies.
Below
is the rule for "your code":
1. If the code is compiled optimized, it is not your code
2. If you don't have symbols, it is not your code
You may also verify if your assembly is optimized and identified as
"User-Code" in "Module Window" in VS2005. Below link contains more
information regarding JMC feature:
"Is 'Just my Code' for you?"
http://blogs.msdn.com/greggm/archive/2004/07/29/201315.aspx
Once you find your plug-in assembly is identified as non-User Code, you
should disable the JMC feature from Tools | Options | Debugging "Enable
Just My
Code" check box.(the VS2005 IDE maybe need close&re-open to enable the
setting). This tells VS2005 load symbol for non-user code.
Finally, if your plug-in source code is not in VS project, you may use the
trick below to debug at source code level:
"How To: Debug Into File References "
http://weblogs.asp.net/okloeten/archive/2003/11/03/35418.aspx
#3, Yes, after building, the linker/compiler will generate a pdb file for
the assembly by default, and the linker/compiler will embed the absolute
path to this symbol file in the assembly so that debugger can parse this
symbol path and find the pdb file for loading.
#4, We have several ways of debugging .Net application. Regarding advanced
Net debugging, I assume you are interested in using SOS.dll to debug the
Net internal data structure and flow. Below are some good articles
regarding SOS.dll debugging:
"SOS: It's Not Just an ABBA Song Anymore"
http://msdn.microsoft.com/msdnmag/issues/03/06/Bugslayer/default.aspx
"Drill Into .NET Framework Internals to See How the CLR Creates Runtime
Objects"
http://msdn.microsoft.com/msdnmag/issues/05/05/JITCompiler/
"Investigating Memory Issues"
http://msdn.microsoft.com/msdnmag/issues/06/11/CLRInsideOut/
In VS debugger side, I recommend Mike Stall's blog, he is Microsoft VS
debugger developer:
http://blogs.msdn.com/jmstall/default.aspx
Finally, the best book on .Net debugging side is John Robbins' wonderful
book <Debugging Applications for Microsoft .NET and Microsoft Windows>.
John has just released the new version for .Net2.0 although I haven't read
it yet, see links below:
http://www.amazon.com/Debugging-Applications-Microsoft-NET-Windows/dp/073561
5365
http://www.microsoft.com/mspress/books/8650.aspx
Hope this helps and feel free to feedback, thanks.
Best regards,
Jeffrey Tan
Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.
Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no
rights.