Don Johnson
11-14-2003, 11:22 PM
Ok, I'm trying to call a C Sharp DLL from a fortran.NET Console application. All method calls works fine, except when I use the "out" attribute with strings or arrays.
It compiles fine, and the CS dll is callable from other CS apps, but I get this message when running the Fortran ap:
"Method not found: Void ClassLibrary7.Class1.getstr(Int16, System.String)."
The code:
//ClassLibrary7.cs
using System;
namespace ClassLibrary7
{
public class Class1
{
public Class1()
{
}
public static void getstr(short num, out string ostr)
{
ostr = num.ToString();
}
}
}
!***fortran.net***
! ConsoleApp
program MyProg
use System
use ClassLibrary7
implicit none
integer*2 :: xxx
character(len=5) :: buff
type (Class1), pointer :: cslib
type (String), pointer :: str1
xxx = 5_2
call cslib.getstr(xxx, str1)
buff = astring(str1)
end program MyProg
***
Now, the problem seems to be with the "out" statement...as if I take that out, I don't get that error, but the value is NOT passed to my fortran str1 pointer, and hence using astring fails.
Looking at the ildasm of both, I see that the arguments for getstr with the "out" attribute left in, shows "getstr: void(int16,string&)"
while, w/o the "out", it's just "getstr: void(int16,string)".
Meanwhile, the call from MyProg shows it looking for (int16,string), hence the error, as if it doesn't recognize the string out properly.
Single numeric values seem to work fine, with the out attribute, but arrays and strings have this problem. Any suggestions? I have tried using functions, but then I get a whole different error saying I have more actual arguments than dummy arguments (even with zero actual arguments).
Thanks in advance. :)
It compiles fine, and the CS dll is callable from other CS apps, but I get this message when running the Fortran ap:
"Method not found: Void ClassLibrary7.Class1.getstr(Int16, System.String)."
The code:
//ClassLibrary7.cs
using System;
namespace ClassLibrary7
{
public class Class1
{
public Class1()
{
}
public static void getstr(short num, out string ostr)
{
ostr = num.ToString();
}
}
}
!***fortran.net***
! ConsoleApp
program MyProg
use System
use ClassLibrary7
implicit none
integer*2 :: xxx
character(len=5) :: buff
type (Class1), pointer :: cslib
type (String), pointer :: str1
xxx = 5_2
call cslib.getstr(xxx, str1)
buff = astring(str1)
end program MyProg
***
Now, the problem seems to be with the "out" statement...as if I take that out, I don't get that error, but the value is NOT passed to my fortran str1 pointer, and hence using astring fails.
Looking at the ildasm of both, I see that the arguments for getstr with the "out" attribute left in, shows "getstr: void(int16,string&)"
while, w/o the "out", it's just "getstr: void(int16,string)".
Meanwhile, the call from MyProg shows it looking for (int16,string), hence the error, as if it doesn't recognize the string out properly.
Single numeric values seem to work fine, with the out attribute, but arrays and strings have this problem. Any suggestions? I have tried using functions, but then I get a whole different error saying I have more actual arguments than dummy arguments (even with zero actual arguments).
Thanks in advance. :)