A
AhmedKh
Guest
Hi
Actually, this is the first time for me to try to pass arrays from VB.net to Dll created by FORTRAN, but I had too much difficulty to do that. Usually I'm having this error “An attempt was made to load a program with an incorrect format. (Exception from HRESULT: 0x8007000B)”, and I don't know why and what does it mean? .following is a very simple example I'm trying to do using VB.net:
Imports System.Runtime.InteropServices
Module Module1
Declare Sub FortranDLL Lib "C:\Users\Shabana\Desktop\DLL Project\Dll2\VBPROG\Dll2.dll" Alias "FORTRANDLL" (<[In](), Out()> ByVal Array1() As Int32, ByRef Foo As Int32)
End Module
Public Class Form1 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim I As Int32
Dim Test As Int32() = {1, 2, 3, 4, 5, 6}
FortranDLL(Test, Test.Length)
For I = 0 To 5
TextBox1.Text = Str$(Test(I))
Next I
End Sub
End Class
Also this is the Fortran code to create the Dll file
Subroutine FortranDLL( Array1, upbound )
!DEC$ ATTRIBUTES DLLEXPORT, ALIAS: 'FORTRANDLL' :: FortranDLL
!DEC$ ATTRIBUTES REFERENCE :: Array1
!DEC$ ATTRIBUTES REFERENCE :: upbound
Implicit None
! ...argument declarations
Integer(4) :: upbound
Integer(4) :: Array1(1:upbound)
Array1 = Array1 + 10
End Subroutine FortranDLL
I hope that I could able to make it clear , and I will be do appreciated if you could help me solving this problem.
Continue reading...
Actually, this is the first time for me to try to pass arrays from VB.net to Dll created by FORTRAN, but I had too much difficulty to do that. Usually I'm having this error “An attempt was made to load a program with an incorrect format. (Exception from HRESULT: 0x8007000B)”, and I don't know why and what does it mean? .following is a very simple example I'm trying to do using VB.net:
Imports System.Runtime.InteropServices
Module Module1
Declare Sub FortranDLL Lib "C:\Users\Shabana\Desktop\DLL Project\Dll2\VBPROG\Dll2.dll" Alias "FORTRANDLL" (<[In](), Out()> ByVal Array1() As Int32, ByRef Foo As Int32)
End Module
Public Class Form1 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim I As Int32
Dim Test As Int32() = {1, 2, 3, 4, 5, 6}
FortranDLL(Test, Test.Length)
For I = 0 To 5
TextBox1.Text = Str$(Test(I))
Next I
End Sub
End Class
Also this is the Fortran code to create the Dll file
Subroutine FortranDLL( Array1, upbound )
!DEC$ ATTRIBUTES DLLEXPORT, ALIAS: 'FORTRANDLL' :: FortranDLL
!DEC$ ATTRIBUTES REFERENCE :: Array1
!DEC$ ATTRIBUTES REFERENCE :: upbound
Implicit None
! ...argument declarations
Integer(4) :: upbound
Integer(4) :: Array1(1:upbound)
Array1 = Array1 + 10
End Subroutine FortranDLL
I hope that I could able to make it clear , and I will be do appreciated if you could help me solving this problem.
Continue reading...