Silverfrost Forums

Welcome to our forums

A callback was made on a garbage collected delegate

5 Jul 2011 4:57 #8511

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:

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:

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:

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:

CheckInputFormatsFunc = NEW@('System.String[]', 0)

Can someone please explain why this might be happening?

Thanks, Alex. 😢

Please login to reply.