Custom exception and JIT debugging

  • Thread starter Thread starter saurabh
  • Start date Start date
S

saurabh

Hello All,

In my application I have created a custom exception class derived from
ApplicationException. For a particular error condition, I throw this
exception. In the calling code, I catch this exception and report the error
condition. This all works fine on my development machine (as always ;)) but
on the release machine, the exception is not reported but it launches the
JIT debugger nasty dialog saying 'unhandled exception'

Has anybody experienced anything like this? Any help in resolving this issue
is highly appreciated.

TIA,

--Saurabh
 
Is this all housed within a single assembly, or is the assembly that the
exception is defined different then the assembly that catches it? Also, what
does the stack trace say?
 
They are in different assemblies. The stack trace is exactly same as I get
in the exception object on my development machine. Can you tell me under
what conditions the JIT debugger thinks it needs to kick in?

--Saurabh
 
saurabh said:
They are in different assemblies. The stack trace is exactly same as I get
in the exception object on my development machine. Can you tell me under
what conditions the JIT debugger thinks it needs to kick in?

--Saurabh

Only an unhandled exception, I believe. Do you have a global error handler,
i.e. on the current thread?

Best Regards,

Andy
 
Assuming all things being equal you should get the same fundamental behavior
regardless of the build type. IOW, if it's unhandled in a release build it
should be unhandled in a debug build. How the system responds to an
unhandled exception may differ between builds but not whether it is
unhandled or handled in a catch handler.

That implies that you may be seeing an artifact of the environment, i.e. the
debug environment may be different then the release environment; e.g. where
the assemblies are located may be different. This can cause problems in the
client code that catches the exception. When the exception is caught the
runtime must be capable of resolving the type by locating the assembly the
type is defined in. If the type used in the client is defined in an assembly
located in a different directory then the assembly used in the server code
that throws the exception then the runtime will treat them as two distinct
types. In this case the catch block will either not catch the exception
(resulting in an unhandled exception), or when it tries to deserialize or
access the exception object it may cause a TypeCast exception, or some other
exception, nested within the original exception.

So I would look for duplicate copies of the assembly that defines the custom
exception. If you have more then 1 copy that the client can bind to it could
cause this problem.
 
Back
Top