replica nfl jerseysreplica nfl jerseyssoccer jerseyreplica nfl jerseys forums.silverfrost.com :: View topic - FTN95 Express and VB 2010 Express Compatibility
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 

FTN95 Express and VB 2010 Express Compatibility

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



Joined: 30 Dec 2009
Posts: 9
Location: Los Angeles, USA

PostPosted: Mon Oct 15, 2012 1:14 am    Post subject: FTN95 Express and VB 2010 Express Compatibility Reply with quote

I have the need to update a .NET application that I wrote in Visual Basic 2008 Express a couple years ago that calls a Win32 DLL that I compiled using Silverfrost FTN95 Express. The problem quickly arises as soon as the Fortran DLL subroutine is called. A sample error that I get is:

Quote:
PInvokeStackImbalance was detected
Message: A call to PInvoke function 'Test Functions!Test_Functions.Form1::FSUB' has unbalanced the stack. This is likely because the managed PInvoke signature does not match the unmanaged target signature. Check that the calling convention and parameters of the PInvoke signature match the target unmanaged signature.


This is confusing to me, as it worked before; why doesn�t it work now? What changed? It took me more than a few moments to realize that I had upgraded to Visual Basic 2010 Express about a year or so ago. The error occurs when running the VS2010 (Visual Basic 2010 Express) debugger. If I run the application without using the debugger (Ctrl+F5), the application and DLL seem to run fine. (Obviously, I can�t see VB problems that may exist when running in this mode.)

Before identifying that the newer IDE seemed to be causing my problem, I also tried compiling the Fortran code as a .NET DLL and calling the subroutine that way. In this case I get the following error:

Quote:
CallbackOnCollectedDelegate was detected
Message: A callback was made on a garbage collected delegate of type 'ftn95lib.mdl!Salford.Fortran.RTLibrary+clearwin_callback::Invoke'. This may cause application crashes, corruption and data loss. When passing delegates to unmanaged code, they must be kept alive by the managed application until it is guaranteed that they will never be called.


As in the case of the Win32 DLL, I can get the .NET DLL to run properly if I turn off the VS2010 debugger.

These errors occur even when the simplest of Fortran code is called, such as the below, where I test passing Integer, Floating Point, String and Array values:

Code:
      SUBROUTINE fsub (x, z)
        INTEGER*2, Intent(inout):: x
        INTEGER*4, Intent(inout):: z
        x = x + x
        z = z * z
      END
     
      REAL FUNCTION ffunc (y)
        REAL, Intent(inout):: y
        ffunc = y + 1.23
      END

      SUBROUTINE fstring (fstr)
        CHARACTER*20, Intent(inout):: fstr
        fstr = 'Jack Be Nimble'
      END
     
      SUBROUTINE farray(farr)
        REAL, Intent(inout):: farr(:)
        DO 10 n= 1,10
          farr(n)=n+.123
   10   CONTINUE
      END


(Note: The above code is the Win32 version; the .NET version has the Assembly_Interface(name= ) declaration lines added.)

A call to just the FSTRING subroutine (Win32), which simply receives and passes back a string, results in the following error:

Quote:
System.StackOverflowException was unhandled
Message: An unhandled exception of type 'System.StackOverflowException' occurred in mscorlib.dll


In Visual Basic 2010 Express, the declarations and calls seem to be correct:
[code:1:983b27734a]
Declare Sub FSUB Lib "C:\� \Release\Win32\TestFunctions.dll" (ByRef x As Short, ByRef z As Integer)
Declare Function FFUNC Lib "C:\� \Release\Win32\TestFunctions.dll" (ByRef y As Single) As Single
Declare Sub FSTRING Lib "C:\�\Release\Win32\TestFunctions.dll" (ByVal fstr As String)
Declare Sub FARRAY Lib "C:\� \Release\Win32\TestFunctions.dll" (ByVal farr() As Single)



Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
Dim x As Short
Dim z As Integer
x = 10
z = 12
FSUB(x, z)
MsgBox(x & " "
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