I am using P/Invoke calls to Fortran dynamic link libraries (DLLs, compiled with Intel Fortran compiler). As these Fortran libraries are currently being under development, I quite often get Fortran run-time errors which display a message box containing the error information.
The problem is that as soon as I click 'OK' on those message-boxes my own C# (.Net Framework 4.0) application shuts-down making them fatal to my application as well.
Furthermore, I am utilizing a global error handling mechanism in my C# code which traps all .Net errors and logs them into an ASCII file. Off-course since I cannot trap the Fortran generated errors no logging on my end occurs in such cases.
So my questions are: a) can I somehow get away with the P/Invoke fatal error crashes (ie keep my application running after they occur) and b) is there any way that I can tunnel the external P/Invoke error information into my own managed C# error handling routines?
EDIT:
More on the error: I am already utilizing try, catch, finally blocks within which I perform the P/Invokes. Unfortunately, ever since I posted this question I received new DLL versions that fixed the error I encountered last. I have kept though a screenshot out of which I can provide further information about what those message-boxes look like.
The Fortran .DLL files are 32-bit and the caption on the error message reads
'Intel(r) Visual Fortran run-time error', then the body of the message box reads
'forrtl: severe (408): fort: (3): Subscript #1 of the array PPLOW has value 0 which is less than the lower bound of 1'.
Now I know what that error means, fortran is using 1-based indexing whilst .Net as we all know uses 0-based indexing and that's fine, I provide this information to the Fortran library developers and they fix their routines. I would like though to keep these errors from crashing my application as well.