Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

calling .dll from VB.net

Tom_C_
Beginner
865 Views

I have a larger program where VB6 code was changed to VB.net. It calls an IVF .dll which contains a bunch of routines. In trying to make it work, I made a test case whichjust multiplies a number by 2. Im using Visual studio 2005 and IVF version 10.1.014

The IVF.dll named bigd1.dll contains asubroutine bigd2which is called by bigV.

subroutine bigd2(was)

!DEC$ ATTRIBUTES DLLEXPORT::bigd2

integer was

was=was*2

return

end subroutine bigd2

VB.net program called bigV

Imports System.Runtime.InteropServices

Public Class Form1

"bigd1.dll")> _

Public Shared Sub bigd2(ByRef aaa As Integer)

End Sub

Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click

Dim aaa As Integer

aaa = TextBox1.Text

Call bigd2(aaa)

TextBox1.Text = aaa

End Sub

End Class

It compiles fine. Upon execution it gives the error

unhandled exception of type 'System.EntryPointNotFoundException' occurred in bigV.exe

Unable to find entry point named 'bigd2' in DLL'bigd1.dll'

The VB form shows up fine. If I remove the .dll file the error changes to didnt find the .dll. So its finding the .dll it just isnt finding the subroutine in the .dll.It's got to be something simple and I realize this is interface between 2 languages but any help you could give would be appreciated.

Tom

0 Kudos
2 Replies
Steven_L_Intel1
Employee
865 Views
Two things wrong. First is that you didn't give bigd2 the STDCALL attribute, which all calls from VB require. Second is that the name that VB is looking for is 'bigd2' and Fortran makes the routine named _BIGD2 by default. Use this instead:

!DEC$ ATTRIBUTES DLLEXPORT, STDCALL, REFERENCE, ALIAS:"bigd2" :: bigd2
0 Kudos
Tom_C_
Beginner
865 Views
Thanks!!!
Tom

0 Kudos
Reply