Tool for viewing assembly load exception stack traces

  • Thread starter Thread starter Keith Patrick
  • Start date Start date
K

Keith Patrick

I have an assembly that fails to run because of some SecurityException
related to my permission settings. I *really* want to figure out why the
failure occurs, but when I debug in VS.Net, it happens so early (during
loading) that I cannot step into code to look at the stack trace. The only
thing I can know is that it's a SecurityException; no watching of the
exception object because I never get to my own code. Is there any way to
debug this? I can't even get another process to attach a debug session to,
so I would even take doing something like java where I go "java
myassembly.exe -verbose"...anything with some kind of verbose logging.
 
will fuslogvw.exe help ?

It is located in SDK/V1.1/Bin folder under the VS .Net install folder. The
tool is also available with framework V1.0.
 
No, it didn't show any errors. It will only tell about why an assembly
can't be bound, but I think it's binding fine for me. The problem is that a
Windows Service cannot load because it refuses a permission (FileDialog in
this case) unrestricted. It will bind OK, but a security check fails, so
unfortunately, fuslogvw doesn't check for that.
 
You may want to try the following,

(1) disable the security, caspol -s off, then run your
app, if it is really a security thing, your app should run.
Turn the security back on, caspol -s on

(2) if your assembly is strong named, is it possible that
the assembly is tampered? use peverify to do a check

(3) Since the exception was thrown during loading, you can
write a simple test to load your assembly dynamically,
e.g., this way, you have control on the loading process

try {
Assembly.LoadFrom("your.dll");
// here you invoke some method
....
} catch (Exception e) {
Console.WriteLine(e.StackTrace);
}

(4) most likely, the security exception is thrown during
jitting some method, you can check wether there is any
declarative security permissions by names such
as "LinktimeDemand", use permview /decl your.dll to see
all permissions. Comment those out, and re-try your app

(5) if you are willing to send me your files, I can send
you a log of the methods jitted, etc. We have an internal
tool that logs all method jitting, invocation, strings,
etc. with lots of verbose information

Huihong
http://www.remotesoft.com
..NET code decompiler, obfuscator, protector, linker and
native compiler
 
Back
Top