soccer jersey forums.silverfrost.com :: View topic - calling 32bit Dll from C# - string variables
forums.silverfrost.com Forum Index forums.silverfrost.com
Welcome to the Silverfrost forums
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

calling 32bit Dll from C# - string variables

 
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> Support
View previous topic :: View next topic  
Author Message
steveDoyle



Joined: 04 Sep 2009
Posts: 112
Location: Manchester

PostPosted: Tue Jul 23, 2024 8:47 am    Post subject: calling 32bit Dll from C# - string variables Reply with quote

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
View user's profile Send private message
Emanuele



Joined: 21 Oct 2009
Posts: 78
Location: Bologna (Italy)

PostPosted: Thu Aug 08, 2024 3:31 pm    Post subject: Reply with quote

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
View user's profile Send private message
steveDoyle



Joined: 04 Sep 2009
Posts: 112
Location: Manchester

PostPosted: Mon Aug 12, 2024 12:36 pm    Post subject: Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> Support All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group