473,504 Members | 13,601 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Handling unmanaged exceptions in managed code

7 New Member
Hi All,

I am having an executable developed in C#.Net. My app make use of services from some unmanaged dlls it loads. My problem is that my application is termainted due to some exceptions within these unmanaged codes. I tried AppDomain UnhandledExceptionEventHandler and ThreadExceptionEventHandler....but it fails to catch the excpetions...

Can anyone tell me how to handle the unmanaged exceptions in manged code in.
Thanks in advance...
May 21 '09 #1
4 6147
PRR
750 Recognized Expert Contributor
Have a
Expand|Select|Wrap|Line Numbers
  1. Catch
  2. {
  3. // catch unmanaged exceptions here
  4. }
  5.  
for unmanaged exceptions... Catch{} catches all exceptions .. both unmanaged and managed
May 21 '09 #2
sree83
7 New Member
.Thanks for the reply...
But still i am not sure whether the exception is raised when any method is invoked from the managed code...

There are 2 unmanaged modules in use..one for logging purpose and the other for enabling a communication with another server....Both of them manage a lot of threads within them...

so where to put the try-catch statement to catch exceptions which may be raised from some other threads within the unamanged app..??
May 21 '09 #3
PRR
750 Recognized Expert Contributor
You can put the catch{} block in your C# code... Do you have exception handling built within those modules? Things should be cleaner if your module either calls functions or fails with app reason...
May 21 '09 #4
PRR
750 Recognized Expert Contributor
Check these links Consuming Unmanaged DLL Functions and Map HRESULTs and Exceptions
May 21 '09 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

2
2575
by: Bret Pehrson | last post by:
Suppose the following: // Unmanaged code class UnmanagedException /* not visible outside of unmanaged code */ { }; void DoSomething() /* visible (exported) to managed code */ { throw new...
6
746
by: Jesper Ordrup Christensen | last post by:
Say I've created a piece of code that involves both sql, io and some number conversions. Being a responsible developer I have tried to catch all of the exceptions - but how can I be sure? Is...
0
2028
by: Joe | last post by:
Reposting here as there were no useful replies in the dotnet.framework NG... What is the correct pattern for handling exceptions in IDisposable.Dispose, especially in a class that manages...
0
1474
by: Niall | last post by:
I'm attempting to put a C# front end on my unmanaged C++ ray tracer code. It's still in experimental stage, as I have never done anything with exporting types from an unmanaged dll through to a...
2
7243
by: asanford | last post by:
We use StackWalk(StackWalk64) from dbghelp.dll to walk our callstacksas needed, using the various Sym* methods (SymGetSymFromAddr, SymGetLineFromAddr) to resolve source file, function name, and...
12
6087
by: Vasco Lohrenscheit | last post by:
Hi, I have a Problem with unmanaged exception. In the debug build it works fine to catch unmanaged c++ exceptions from other dlls with //managed code: try { //the form loads unmanaged dlls...
4
5707
by: William F. Kinsley | last post by:
My understanding is that when I re-compile a existing MFC application with the /clr switch, that the code generated is managed(with some exceptions) but that the data isn't, i.e. not garbage...
2
2396
by: yaron | last post by:
Hi, How do i catch an unmanaged c++ exceptions ? right now i can catch the System.Runtime.InteropServices.SEHException and System.Exception exceptions , but i wan't to catch myException...
1
1851
by: hcaituiro | last post by:
Can all unmanaged exceptions and others be caught in managed code? Or, you can do nothing to avoid your managed application to crash. Suppouse, you cannot modify the unmanaged code. If you have...
0
7213
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7298
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7366
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7017
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
1
5026
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3187
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3176
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
754
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
406
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.