calling a subroutine from a dll
Dear All,
Hope you have a good time. I work on a VB .net plug in . When I call two subroutines from another class as below: I see the first msgbox result but after I click ok on the first msgbox, both, my plug in and main programme will be closed.
VB Code:
Call cls1DEngine.set_openmi_ief(m_1DProjectFilename, m_1DProjectFilename.Length)
MsgBox("set_openmi passed")
Call cls1DEngine.initialise()
MsgBox("set_openmi passed")
these subroutines call two subroutine from ILM_omi.dll and they appear in Cls1DEngine as below:
VB Code:
<DllImport("C:\bin\ILM_omi.dll")> _
Shared Sub set_openmi_ief(ByVal FileName As String, ByVal Length As Integer)
' No code here
End Sub
<DllImport("C:\bin\ILM_omi.dll")> _
Shared Sub initialise()
' No code here
End Sub
Does any body know what the problem is? And also why all related windows closing down when initialise sub is called.
Many Thanks,
Reza
Re: calling a subroutine from a dll
Try putting that code in a Try..Catch block to find out why it is throwing an exception.
Re: calling a subroutine from a dll
Dear Edneeis,
I have tried it with try and catch box, too. But it doesn't throw any exception and closes down when it gets there regardless of try and catch box. Do you have any idea?
Many thanks,
Reza
Re: calling a subroutine from a dll
What kind of DLL is C:\bin\ILM_omi.dll? Was it written in .NET? If so then you are doing it wrong. You should be adding a reference to the dll and referring to its objects.
If that is not it then post the code with the try...catch.
Re: calling a subroutine from a dll
it is a fortran subroutine. and it is not in .net.
Re: calling a subroutine from a dll
are you sure you are importing the correct DLL function names?
initialise isn't spelled correctly (it should be initialize) unless the DLL has it spelled wrong as well.