Results 1 to 6 of 6

Thread: calling a subroutine from a dll

  1. #1

    Thread Starter
    New Member
    Join Date
    Sep 2006
    Posts
    8

    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:
    1. Call cls1DEngine.set_openmi_ief(m_1DProjectFilename,  m_1DProjectFilename.Length)
    2.           MsgBox("set_openmi passed")
    3.           Call cls1DEngine.initialise()
    4.            MsgBox("set_openmi passed")

    these subroutines call two subroutine from ILM_omi.dll and they appear in Cls1DEngine as below:

    VB Code:
    1. <DllImport("C:\bin\ILM_omi.dll")> _
    2.     Shared Sub set_openmi_ief(ByVal FileName As String, ByVal Length As Integer)
    3.      ' No code here
    4.     End Sub
    5.  
    6.     <DllImport("C:\bin\ILM_omi.dll")> _
    7.    Shared Sub initialise()
    8.         ' No code here
    9.     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
    Last edited by immoral; Feb 6th, 2007 at 04:23 PM.

  2. #2
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339

    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.

  3. #3

    Thread Starter
    New Member
    Join Date
    Sep 2006
    Posts
    8

    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

  4. #4
    Your Ad Here! Edneeis's Avatar
    Join Date
    Feb 2000
    Location
    Moreno Valley, CA (SoCal)
    Posts
    7,339

    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.

  5. #5

    Thread Starter
    New Member
    Join Date
    Sep 2006
    Posts
    8

    Re: calling a subroutine from a dll

    it is a fortran subroutine. and it is not in .net.

  6. #6
    I'm about to be a PowerPoster! kleinma's Avatar
    Join Date
    Nov 2001
    Location
    NJ - USA (Near NYC)
    Posts
    23,373

    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width