397,373 Members | 2,728 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 397,373 IT Pros & Developers. It's quick & easy.

Catch Win32 Exception from unmanaged code

dh
P: n/a
dh
AppA is a console application (in C#), which uses DLLs in a unmanaged code
(C++, no source available for them).

AppB is a service (in C#), which starts AppA when needed.

When an exception of Win32 (e.g. Integer Division by Zero) thrown by those
DLLs, it will pop up an errorbox waiting for responses.

Just wondering if it's possible for either AppA itself or AppB to catch such
exceptions immediately when it occurs.

Any idea?

Thanks!
Jan 26 '08 #1
Share this Question
Share on Google+
1 Reply


forever.zet@gmail.com
P: n/a
On 26 , 22:00, "dh" <d...@yahoo.comwrote:
AppA is a console application (in C#), which uses DLLs in a unmanaged code
(C++, no source available for them).

AppB is a service (in C#), which starts AppA when needed.

When an exception of Win32 (e.g. Integer Division by Zero) thrown by those
DLLs, it will pop up an errorbox waiting for responses.

Just wondering if it's possible for either AppA itself or AppB to catch such
exceptions immediately when it occurs.

Any idea?

Thanks!
Hi,

In case of integer division by zero the exception should be converted
to the native .NET System.DivideByZeroException.
In general case if the exception will be converted to
System.Runtime.InteropServices.SEHException (you can look into MSDN to
see how exceptions are converted).
So I think you can catch them in AppA and probably it would be better
to check input so divide by zero exception doesn't occur.

HTH,
Sergey Zyuzin
Jan 26 '08 #2

This discussion thread is closed

Replies have been disabled for this discussion.