Results 1 to 6 of 6

Thread: Unable to find an entry point named "Function name" in DLL "DLL filename"

  1. #1

    Thread Starter
    New Member
    Join Date
    Jun 2006
    Posts
    3

    Question Unable to find an entry point named "Function name" in DLL "DLL filename"

    Hello,

    Please help!

    I would like to prepare the DLL (Class Library) file in VB.NET and use it in a Windows Application.

    After trying many different things, I still cannot make it work.

    I have the DLL added to the Reference, if I open it in the Reference list, I can see my function listed. I think I reference the DLL properly in my Windows Application, but I still receive the following error message:
    An unhandled exception of type 'System.EntryPointNotFoundException' occurred in firstapplicationwithdll.exe
    Additional information: Unable to find an entry point named printmessage in DLL C:\LT\Visual Studio projects\sampledll\bin\sampledll.dll.


    I was trying with the following (sampledll.DLL):
    My DLL has the following code:
    Public Class sampledll
    Sub printmessage(ByVal printtext As String)
    Dim response As Byte
    response = MsgBox(printtext)
    End Sub
    Function addnum(ByVal input1 As Integer, ByVal input2 As Integer) As Integer
    Dim result As Integer
    result = input1 + input2
    Return result
    End Function
    End Class



    My windows application is very simple. One form with a button to display the messagebox:
    Public Class Form1
    Inherits System.Windows.Forms.Form

    Declare Sub printmessage Lib "C:\LT\Visual Studio projects\sampledll\bin\sampledll.dll" (ByVal printtext As String)

    #Region " Windows Form Designer generated code "
    #End Region

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    printmessage("Working with DLL")
    End Sub
    End Class


    Is there anyone who has any idea what I am missing?

    Many thanks in advance for any help!

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

    Re: Unable to find an entry point named "Function name" in DLL "DLL filename"

    ok, since it sounds like you MADE this DLL you are trying to reference, you don't do your declares like that, just add a reference to the DLL

    From the "Project" menu in VS, select Add Reference, and then click the browse button and find your dll, when you add a reference to your DLL, VS will automatically copy it to the bin folder of your project that is referencing it.

    In addition to that, something else you can do is to actually add the dll project to the same solution as the windows form app that is going to use the dll.

    Solutions can have multiple projects in them (even cross language, like VB.NET and C#)

    this is really cool because then you can debug both projects at the same time. Like step from your win form app right into the dll as its being called.

    In the solution explorer in VS.NET, right click on the solution (all the way at the top) and select "Add Existing Project", then find the project file from your DLL app and add it. Now you will see your solution has 2 projects under it. Then do as I said above, and add a reference to your win form app, but click on the 3rd tab over in the screen that comes up, and you will be able to add your dll project as a reference.

    Hope this makes sense, but post back if you have problems, since its a lot of info

  3. #3

    Thread Starter
    New Member
    Join Date
    Jun 2006
    Posts
    3

    Question Re: Unable to find an entry point named "Function name" in DLL "DLL filename"

    Thanks for your quick reply.

    I tried what you recommended. Thanks for the tip, now in the Solution Explorer I can see both project, I removed from the Reference list the previously mapped DLL and add again, but unfortunately the problem is still present.

    I think I miss something very simple, but I have no idea what it is.

    If I open the DLL I created (sampledll.dll) with the Object Browser, it even shows the functions I put into the DLL, but once I want to access them from the Windows Application, it still says "unable to find entry point" for that function. I checked spelling, definition, both are the same.

    Do you have any other recommendation to try?

    Is my Declare statement correct?

    Thanks for your help!

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

    Re: Unable to find an entry point named "Function name" in DLL "DLL filename"

    no.. its not correct

    after you reference the DLL project to your win form project (as mentioned in my first post)

    you need to create an instance of the class that is in your dll..

    all you have to do is something like this in your win form app
    VB Code:
    1. Dim MySample as New sampledll
    2. MySample.printmessage("Hello World")

    If printmessage doesn't come up with you type mysample. then change your printmessage in your dll code to be "Public Sub printmessage"

    I can't remember if it defaults to private if you don't specify an access modifier (public, private, etc..)

  5. #5

    Thread Starter
    New Member
    Join Date
    Jun 2006
    Posts
    3

    Re: Unable to find an entry point named "Function name" in DLL "DLL filename"

    Excellent!!! You turned on the light in my dark mind!!! :-)))

    Now it is working!

    Many thanks for your prompt replies and for your time!!!

  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: Unable to find an entry point named "Function name" in DLL "DLL filename"

    glad to help. If its answered, please mark the thread resolved using the thread tools menu above.

    and welcome to the forums

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