Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / New Users / June 2006

Tip: Looking for answers? Try searching our database.

how to catch win32 dll exception in c#?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
BEelzebub - 13 Jun 2006 04:03 GMT
how to catch win32 dll exception in c#?
Marcus Heege - 13 Jun 2006 09:03 GMT
"BEelzebub" <beelzebub2006@163.com> wrote in message
news:23I4bbrrjGHA.4512@TK2MSFTNGP02.phx.gbl...
> how to catch win32 dll exception in c#?

If a C++ exceptions is thrown, you can catch the exception as a
System::Runtime::InteropServices::SEHException.

If a Win32 SEH exception is thrown, it depends on the exception code. Most
exception codes are also caught as
System::Runtime::InteropServices::SEHException, but there are some
exceptions. E. g. The exception code EXCEPTION_INT_DIVIDE_BY_ZERO is mapped
to a System::DevideByZeroException.

If you use this exception mapping intensively, you should also notice that
there is a breaking change in v2.0:
EXCEPTION_ACCESS_VIOLATION is caught as System::AccessViolation in 2.0,
whereas it is caught as System::NullReferenceException in 1.1 and 1.0. To
get the old behavior you can add an element
<legacyNullReferenceExceptionPolicy enabled="1"/> to the <runtime> element
of your config file.

However, in all these cases, you loose significant aspects of your
exception. If you can not afford this, you have to use C++/CLI, where you
can catch Win32 exceptoins as well as C++ exceptions in managed code.

Marcus Heege
DevelopMentor

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.