alex21
Joined: 20 Apr 2011 Posts: 75 Location: Australia
|
Posted: Tue Jul 05, 2011 5:57 am Post subject: A callback was made on a garbage collected delegate |
|
|
Hello,
I have had some what of a sucess implementing a WPF .Net 4.0 GUI for my old FORTRAN95 console application, however I have recently come across this error which I don't have a clue about when trying to call a function in FORTRAN code.
Error:
Code: | 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. |
The above is just a warning, I then recieve a NullReferenceException, and what appears to be null is the FORTRAN function itself...
FORTRAN Function:
Code: | FUNCTION CheckInputFormatsFunc(InputParser, cLine, noVars)
USE ZE
USE FTNHelper
IMPLICIT NONE
ASSEMBLY_INTERFACE(NAME="CheckInputFormatsFunc")
OBJECT("System.String[]") :: CheckInputFormatsFunc
OBJECT("WinTransform.DataModel.Parser"), INTENT(IN) :: InputParser
STRING, INTENT(IN) :: cLine
INTEGER, INTENT(IN) :: noVars
CheckInputFormatsFunc = NEW@("System.String[]", 0)
END FUNCTION CheckInputFormatsFunc |
.Net Call:
Code: | Public ReadOnly Property InputFileColumnsOutput As String
Get
If InputFile Is Nothing Then
Return String.Empty
End If
Dim test = New List(Of String)
Dim mOutCols = WinTransformUtility.CheckInputFormatsFunc(Source, InputFileParseLine, InputVariables.Count)
Return String.Join(" ", mOutCols)
End Get
End Property |
However after recieving the afore mentioned warning I get a NullReferenceException on this line:
Code: | CheckInputFormatsFunc = NEW@("System.String[]", 0) |
Can someone please explain why this might be happening?
Thanks,
Alex.
 |
|