Reputation: 12613
I have a situation where I get an exception in a dynamic assembly, which in turn terminates my application. I assume this assembly is generated by some of the third party libraries we use, because we don't use Reflection.Emit
or other codegen tools ourselves. However, as far as I can tell, there is no way for me to determine where it comes from?
This is the exception I get:
An unhandled exception of type 'System.ArgumentException' occurred in Unknown Module.
Additional information: An item with the same key has already been added.
Is there tooling, or some code I can write into my own application, to figure out what is going on?
Upvotes: 0
Views: 354
Reputation: 51430
Go to Debug -> Exceptions:
then check the Thrown checkbox on the Common Language Runtime Exceptions line (or directly on the ArgumentException
line). This will make the debugger kick in as soon as any exception is thrown, before the stack is unwinded. You'll be able to examine the call stack at this point.
Note that you may also have to disable the following option:
Tools -> Options -> Debugging -> General -> Enable Just My Code
And in the call stack window, enable Show External Code from the context menu:
Upvotes: 1