Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
29277 Discussions

trap exception in C# application

babe59
Beginner
614 Views

Hello,

I created a Fortran DLL and I use it on C# application (VS2005). I generate an application error on my C# program and I want to trap it but the following code dosen't work. Could you explain me why ?

C# code:

[DllImport("dll1.dll")]
public static extern void ARRAYTEST(
[MarshalAs(UnmanagedType.LPArray)] int[,] arr,
[MarshalAs(UnmanagedType.I4)]int len);

...

int[,] entiers = new int[3, 7];
try
{
ARRAYTEST(entiers, 10); ====> Error because 10 corresponding of my first bound of my array 'entiers' and the max value is 3 (int[3,7])...
}
catch (Exception ex)
{
MessageBox.Show(ex.Message + "\n" + ex.Source + "\n" + ex.InnerException + "\n" + ex.StackTrace);
}

This code dosen't work : the program print an error windows in line 'ARRAYTEST(entiers, 10);' and it stoped... the prog dosen't continue on my catch...

0 Kudos
1 Solution
Steven_L_Intel1
Employee
614 Views

Please see this previous discussion for why you can't trap a Fortran array bounds error.

View solution in original post

0 Kudos
1 Reply
Steven_L_Intel1
Employee
615 Views

Please see this previous discussion for why you can't trap a Fortran array bounds error.

0 Kudos
Reply