View previous topic :: View next topic |
Author |
Message |
jetcheve
Joined: 23 Aug 2006 Posts: 23
|
Posted: Tue Dec 19, 2006 10:59 pm Post subject: calling personally built .NET dlls |
|
|
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) :
Code: | 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? |
|
Back to top |
|
|
Andrew
Joined: 09 Sep 2004 Posts: 232 Location: Frankfurt, Germany
|
Posted: Wed Dec 20, 2006 12:01 pm Post subject: |
|
|
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. |
|
Back to top |
|
|
jetcheve
Joined: 23 Aug 2006 Posts: 23
|
Posted: Wed Dec 20, 2006 3:00 pm Post subject: |
|
|
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? |
|
Back to top |
|
|
Andrew
Joined: 09 Sep 2004 Posts: 232 Location: Frankfurt, Germany
|
Posted: Wed Dec 20, 2006 4:31 pm Post subject: |
|
|
Is there any chance you could post a full example please? |
|
Back to top |
|
|
jetcheve
Joined: 23 Aug 2006 Posts: 23
|
Posted: Thu Dec 21, 2006 11:42 pm Post subject: |
|
|
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. |
|
Back to top |
|
|
Andrew
Joined: 09 Sep 2004 Posts: 232 Location: Frankfurt, Germany
|
Posted: Fri Dec 22, 2006 12:58 pm Post subject: |
|
|
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. |
|
Back to top |
|
|
jetcheve
Joined: 23 Aug 2006 Posts: 23
|
Posted: Fri Dec 22, 2006 3:03 pm Post subject: |
|
|
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 |
|
Back to top |
|
|
|