Silverfrost Forums

Welcome to our forums

calling personally built .NET dlls

19 Dec 2006 9:59 #1464

I'm using some legacy code that I want to call back to VB rather than print code to a command window and wait for input there. I've create a solution that has a VB front end exe project, a FORTRAN .dll project and a VB .dll that is somewhat of a go-between. It's the one that FORTRAN calls subs from, it gets the input from the user and returns it to the FORTRAN code. Now, I've done the examples in the help file, and I've done while similar to it, and I've done something somewhat like it in this case and I keep running into the following problem (I've left some code out since it's working and doesn't have anything to do with this part) :

ASSEMBLY_EXTERNAL(NAME='VBINT.fortranPubs.loadChooseType') CHTYPE
....
....
....
CALL CHTYPE(VTYPE,RT,NRT)

The VB sub it calls to (VBINT.fortranPubs.loadChooseType) is :

Imports System.Windows.Forms
Public Class fortranPubs
    Public Shared Sub loadChooseType(ByVal VTYPE() As String, ByVal RT() As Double, ByVal NRT As Integer)
        ReDim VbVTYPE(29)

        Dim chType As New chooseType(NRT)

        Dim j As Integer = -1

        For i As Integer = 0 To NRT - 1
            VbVTYPE(i) = VTYPE(CInt(RT(i)))

        Next

        ReDim Preserve VbVTYPE(NRT - 1)

        chType.ShowDialog()

    End Sub

End Class

These are all in three different projects in one solution, and when I try to build the solution it builds the VB part first, successfully, then the FORTRAN part of the code, where the compiler stops and gives the following error : error 1119 - No .NET method matches this call. At which point, of course, the compiler stops.

Any thoughts?

20 Dec 2006 11:01 #1467

Have you got a reference to the VB project in the FORTRAN project that uses the routine? When using Visual Studio you can select to 'Add Reference' and select the project output from the VB project as the reference to add.

If you do have this reference added then you need to be sure that the name of the routine is correct that you use the ASSEMBLY_EXTERNAL for. You can inspect a .NET assembly using ildasm.exe (part of the framework) and check that the namespace/classname/routine name are all correct and are as you expect them to be.

20 Dec 2006 2:00 #1470

yes, and I just confirmed that they are correct. I'd been checking using the assembly name from VB but I confirmed it in ildasm. This isn't the first time I've run into this problem. The first time I fixed it by making my method a shared sub, this time that didn't do anything. Any other suggestions?

20 Dec 2006 3:31 #1472

Is there any chance you could post a full example please?

21 Dec 2006 10:42 #1482

Andrew, is there a reason why trying to pass arrays back to .NET would cause this error? Because when I try to pass a single array of strings its fine, but add in an array of doubles or anything else with that array and it won't compile anymore.

22 Dec 2006 11:58 #1484

Have you checked the documentation regarding the use of .NET arrays? Standard Fortran arrays are not the same as .NET arrays and special consideration needs to be made when passing arrays. It looks like you need to be using .NET arrays when passing into the VB. When manipulating these arrays in the Fortran it might be more efficient to copy them into standard Fortran arrays from the .NET arrays before manipulation and copy them back into .NET arrays for passing to VB.

The documentation for .NET arrays can be found at:

.NET platform → .NET arrays .NET platform → Object and string arrays

Hope this helps.

22 Dec 2006 2:03 #1485

Well, that was it. I thought I was converting to a .NET array already, but I wasn't re-indexing it, so I guess that was making it angry. Guess that fixed it. Thanks

Please login to reply.