Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Getting name of entry assembly
Message
 
To
02/04/2008 16:41:01
Mike Cole
Yellow Lab Technologies
Stanley, Iowa, United States
General information
Forum:
ASP.NET
Category:
Other
Environment versions
Environment:
VB 8.0
Miscellaneous
Thread ID:
01307752
Message ID:
01307975
Views:
10
>I am trying to make a utility library that reports exceptions. When I call the method, I want to get the calling application's name. In Winforms, I can get this by using Assembly.GetEntryAssembly. This same method doesn't work for Webforms. Anybody know a way to consistently do this in .NET? Thanks!

Something like this might work:
System.Diagnostics.StackTrace trace = new System.Diagnostics.StackTrace();
System.Diagnostics.StackFrame[] frames = trace.GetFrames();
foreach (System.Diagnostics.StackFrame stackFrame in frames)
{
    //stackFrame.GetMethod();
    //stackFrame.GetMethod().DeclaringType.FullName;
}
You could also just call trace.GetFrame() with an index to get a specific method on the stack.

If you're C# challenged, the VB might look like this:
Dim trace As System.Diagnostics.StackTrace = New System.Diagnostics.StackTrace()
Dim frames As System.Diagnostics.StackFrame() = trace.GetFrames()
For Each stackFrame As System.Diagnostics.StackFrame In frames
	'stackFrame.GetMethod();
	'stackFrame.GetMethod().DeclaringType.FullName;
Next
-Paul

RCS Solutions, Inc.
Blog
Twitter
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform