By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,989 Members | 2,392 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,989 IT Pros & Developers. It's quick & easy.

Error handling for unmanaged code

P: n/a
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
Share this Question
Share on Google+
2 Replies


P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.