Error handling for unmanaged code

  • Thread starter Thread starter Harry Simpson
  • Start date Start date
H

Harry Simpson

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
 
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.
 
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top