View previous topic :: View next topic |
Author |
Message |
steveDoyle
Joined: 04 Sep 2009 Posts: 112 Location: Manchester
|
Posted: Tue Jul 23, 2024 8:47 am Post subject: calling 32bit Dll from C# - string variables |
|
|
HI Everyone
Does anybody have any experience of calling a 32 fortran dll from C#. I have no knowledge of C# and the client has no knowledge of Fortran
I can successful transfer integer and Double precision data to/from the DLL but character strings become corrupt
I can successful transfer data to the DLL but the data in the common block becomes corrupt when i try to read the data back.
F_stdcall Subroutine mov_data_str (imode, cbuff80)
integer imode
character *80 cbuff80
chactacter*80 string1
common/ saved_data\ string1
if(imode.eq.0) then
string1 = cbuff80
else
cbuff80 = string1
endif
end
im assuming that it has something to do with the way the C# call is defined (pass by reference using the 'out' qualifier) and/or how the actual character variable is define in the C#
All responses appreciated
steve |
|
Back to top |
|
|
Emanuele
Joined: 21 Oct 2009 Posts: 78 Location: Bologna (Italy)
|
Posted: Thu Aug 08, 2024 3:31 pm Post subject: |
|
|
Maybe the problem is that Fortran character type has not an exact equivalent in C# (.NET strings are different).
If you can recompile your Fortran dll with .NET, you can then consider the use of .NET string type in FTN95, as explained here. |
|
Back to top |
|
|
steveDoyle
Joined: 04 Sep 2009 Posts: 112 Location: Manchester
|
Posted: Mon Aug 12, 2024 12:36 pm Post subject: |
|
|
Thanks for the feedback
after much experimentation we found that we needed add an extra argument to the C# call to specify the length of the character buffer
STR_LEN = 80
C# MOV_DATA_STR32(ref IMODE, ref CBUFF, ref STR_LEN)
steve |
|
Back to top |
|
|
|