- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Test subroutine that raise and exception in Fortran DLL
SUBROUTINE TESTSEH()
!DEC$ ATTRIBUTES DLLEXPORT::TESTSEH
USE kernel32
call RaiseException(150, 0 , 0, 0)
END SUBROUTINE TESTSEH
And in C#,
try
{
TESTSEH();
}
catch (SEHException ex)
{
int ec = Marshal.GetExceptionCode();
}
In this case, the ec returns 150, which is expected.
Butit would be good to be able to return more information through the RaiseException apart from the ExceptionCode.
The RaiseExcpetion has the following parameters:
void RaiseException(
DWORD dwExceptionCode,
DWORD dwExceptionFlags,
DWORD nNumberOfArguments,
const ULONG_PTR* lpArguments
);
How can I make use of lpArguments to return information such as message string or integer? How to capture those information in C#?
Thank you.
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
AFAIK this is as good as it gets in C# handling of unmanaged code exceptions. If you want a traceback you have to handle the exception in Fortran (via unmanaged C++ since Fortrandoesn't do exception handling, except in f03 for those of the ieee fp variety).
Gerry
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thank you Gerry for responding to my question.Where can I get more information onhandling exception in Fortran via unmanaged C++? Any example would be very helpful.
Thank you.
David
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
It depend on which Fortran compiler you use. CVF 6+ has numerous working samples on SEH but whether they work on IVF is another matter. Specifically, they don't work with ivf 10.1.013, they may or may not work with 10.1.014 but even if they do, don't back on them working on releases beyond that. I got them to work with ivf 9.1.There was a thread called Exception handling under IVF in Q4 of 2006 (or 7, if forget which) dealing with this issue but I see nothing to suggest that IVF has changed to amend its flaws in respect to SEH.
Gerry
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I am using IVF 10.1.011. I manage to get to the thread Exception handling under IVF. I need a bit of time to go through. Thank you.

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page