473,513 Members | 2,440 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Error handling for unmanaged code

I've got a call within my .NET code to a function which uses an API call to
get printer settings. When there's an error in the API call code, it
crashes the .NET app. Try Catch doesn't prevent the crash - it's like it
crashes before the catch catches.....

Any ideas how to error handle this type of function so it doesn't crash the
application??

TIA

Harry
Nov 20 '05 #1
2 1992
In article <OA**************@TK2MSFTNGP10.phx.gbl>, Harry Simpson wrote:
I've got a call within my .NET code to a function which uses an API call to
get printer settings. When there's an error in the API call code, it
crashes the .NET app. Try Catch doesn't prevent the crash - it's like it
crashes before the catch catches.....

Any ideas how to error handle this type of function so it doesn't crash the
application??

TIA

Harry


Examples? If the unmanaged code does something stupid that cause's the
application to crash - there isn't much you'll be able to do about it.
That's why it's called unmanaged code - the runtime has no control over
what it can/can't do.

--
Tom Shelton [MVP]
Nov 20 '05 #2
That's what i thought. Even spinning of the DLL call into another thread
will still crash the code right?

Threads won't/can't isolate the main managed code app from the unmanaged
code - Am i correct?

I'm trying to get printer status with winspool.drv.
Can winspool.drv be interopted for a Windows Forms application.

The WMI is not bringing back accurate info on status so....

I've got API declares but the API call is very unstable and crashes and
brings down the call app. Try catches just don't work.

Help!

Harry

"Tom Shelton" <to*@YOUKNOWTHEDRILLmtogden.com> wrote in message
news:Oc*************@TK2MSFTNGP12.phx.gbl...
In article <OA**************@TK2MSFTNGP10.phx.gbl>, Harry Simpson wrote:
I've got a call within my .NET code to a function which uses an API call to get printer settings. When there's an error in the API call code, it
crashes the .NET app. Try Catch doesn't prevent the crash - it's like it crashes before the catch catches.....

Any ideas how to error handle this type of function so it doesn't crash the application??

TIA

Harry


Examples? If the unmanaged code does something stupid that cause's the
application to crash - there isn't much you'll be able to do about it.
That's why it's called unmanaged code - the runtime has no control over
what it can/can't do.

--
Tom Shelton [MVP]

Nov 20 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

13
4434
by: Thelma Lubkin | last post by:
I use code extensively; I probably overuse it. But I've been using error trapping very sparingly, and now I've been trapped by that. A form that works for me on the system I'm using, apparently...
0
2030
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...
12
6164
by: Sharon | last post by:
I’m wrote a small DLL that used the FreeImage.DLL (that can be found at http://www.codeproject.com/bitmap/graphicsuite.asp). I also wrote a small console application in C++ (unmanaged) that uses...
6
3111
by: Ken | last post by:
When running a program in the debugger, what would cause it to crash without any error messages? I get "The program has exited with code 0 (0x0)". The program is a MDI app with threading for...
9
2216
by: Gustaf | last post by:
I'm confused about structured error handling. The following piece of code is a simplification of a class library I'm working on. It works, and it does what I want, but I'm still not convinced that...
0
920
by: mhdostal | last post by:
I have a multi-threaded application using both managed (C#/.NET) and unmanaged code (C++). The unmanaged code calls into the manage code (via COM Interop) to perform a variety of tasks. Every two...
11
7000
by: Don | last post by:
When using Visual Basic .NET with a reference to Interop.Outlook, is there a way to get more detailed information about an error other than Exception.Message or Exception.ToString? For example,...
0
11554
by: Lysander | last post by:
Thought I would give something back with a few articles. This article is a bit of code to add error handling. When I have time, I want to write articles on multilingual databases, and Access...
9
3280
by: MrDeej | last post by:
Hello guys! We have an SQL server which sometimes makes timeouts and connection errors. And we have an function witch writes and updates data in 2 tables on this server. When the SQL server error...
0
7162
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7384
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
7539
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...
0
7527
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
5090
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
4746
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3234
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
3223
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1597
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.