Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. DLL Entry point [modified]

DLL Entry point [modified]

Scheduled Pinned Locked Moved C#
help
7 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Muammar
    wrote on last edited by
    #1

    This is the header of my only function in my dll file and it compiles just fine

    public static string SaveName(string strName)

    and on the other hand in my class that implements the dll I have this:

        \[DllImport("MyBloodyDLL.dll", EntryPoint = "SaveName")\]
        public static extern string SaveName(string strName);
    

    and when calling the SaveName("string") function later, I get this beautiful exception:
    Unable to find an entry point named 'SaveName' in DLL 'MyBloodyDLL.dll

    Please help :sigh: ps. I HATE DLLs!!


    All generalizations are wrong, including this one! (\ /) (O.o) (><)

    modified on Wednesday, April 16, 2008 4:49 PM

    L R 2 Replies Last reply
    0
    • M Muammar

      This is the header of my only function in my dll file and it compiles just fine

      public static string SaveName(string strName)

      and on the other hand in my class that implements the dll I have this:

          \[DllImport("MyBloodyDLL.dll", EntryPoint = "SaveName")\]
          public static extern string SaveName(string strName);
      

      and when calling the SaveName("string") function later, I get this beautiful exception:
      Unable to find an entry point named 'SaveName' in DLL 'MyBloodyDLL.dll

      Please help :sigh: ps. I HATE DLLs!!


      All generalizations are wrong, including this one! (\ /) (O.o) (><)

      modified on Wednesday, April 16, 2008 4:49 PM

      L Offline
      L Offline
      Luc Pattyn
      wrote on last edited by
      #2

      strName!=SaveName :confused:

      Luc Pattyn [Forum Guidelines] [My Articles]


      This month's tips: - before you ask a question here, search CodeProject, then Google; - the quality and detail of your question reflects on the effectiveness of the help you are likely to get; - use PRE tags to preserve formatting when showing multi-line code snippets.


      M 1 Reply Last reply
      0
      • L Luc Pattyn

        strName!=SaveName :confused:

        Luc Pattyn [Forum Guidelines] [My Articles]


        This month's tips: - before you ask a question here, search CodeProject, then Google; - the quality and detail of your question reflects on the effectiveness of the help you are likely to get; - use PRE tags to preserve formatting when showing multi-line code snippets.


        M Offline
        M Offline
        Muammar
        wrote on last edited by
        #3

        Luc Pattyn wrote:

        strName!=SaveName

        Sorry Luc, I just made a mistake while pasting it, any idea what the problem is?? Thanks for helping mate!


        All generalizations are wrong, including this one! (\ /) (O.o) (><)

        modified on Wednesday, April 16, 2008 4:54 PM

        L 1 Reply Last reply
        0
        • M Muammar

          Luc Pattyn wrote:

          strName!=SaveName

          Sorry Luc, I just made a mistake while pasting it, any idea what the problem is?? Thanks for helping mate!


          All generalizations are wrong, including this one! (\ /) (O.o) (><)

          modified on Wednesday, April 16, 2008 4:54 PM

          L Offline
          L Offline
          Luc Pattyn
          wrote on last edited by
          #4

          Hi Muammar, if your target file is unmanaged C++ (as opposed to C) then the function names would be mangled somehow. You could either try and find out what the rules are, or use good old DUMPBIN to look at the exports of the DLL. BTW: maybe just omitting the EntryPoint stuff solves it (just a guess). :)

          Luc Pattyn [Forum Guidelines] [My Articles]


          This month's tips: - before you ask a question here, search CodeProject, then Google; - the quality and detail of your question reflects on the effectiveness of the help you are likely to get; - use PRE tags to preserve formatting when showing multi-line code snippets.


          M 1 Reply Last reply
          0
          • M Muammar

            This is the header of my only function in my dll file and it compiles just fine

            public static string SaveName(string strName)

            and on the other hand in my class that implements the dll I have this:

                \[DllImport("MyBloodyDLL.dll", EntryPoint = "SaveName")\]
                public static extern string SaveName(string strName);
            

            and when calling the SaveName("string") function later, I get this beautiful exception:
            Unable to find an entry point named 'SaveName' in DLL 'MyBloodyDLL.dll

            Please help :sigh: ps. I HATE DLLs!!


            All generalizations are wrong, including this one! (\ /) (O.o) (><)

            modified on Wednesday, April 16, 2008 4:49 PM

            R Offline
            R Offline
            Rojan Gh
            wrote on last edited by
            #5

            Hi Muammar©, As you mentioned, it seems like the DLL you have is written in C# or .Net somehow, because as much as I know, working with string types is not as easy as C# in C and C++ and the Entry Point you mentioned makes me feel like the library you have is written in C# and in that case: It you want to access the library at design time (coding time) you just need to add it to your project as a reference and use it by adding it's main namespace to your code, using the "using" keyword and then you can easily access the method you like. But if you want to access it at runtime (directly from your compiled code) you need to know about the System.Reflection namespace and much more to use the classes inside it. You can find what you need on MSDN and google. ;) Good luck and have fun.

            Sojaner!

            1 Reply Last reply
            0
            • L Luc Pattyn

              Hi Muammar, if your target file is unmanaged C++ (as opposed to C) then the function names would be mangled somehow. You could either try and find out what the rules are, or use good old DUMPBIN to look at the exports of the DLL. BTW: maybe just omitting the EntryPoint stuff solves it (just a guess). :)

              Luc Pattyn [Forum Guidelines] [My Articles]


              This month's tips: - before you ask a question here, search CodeProject, then Google; - the quality and detail of your question reflects on the effectiveness of the help you are likely to get; - use PRE tags to preserve formatting when showing multi-line code snippets.


              M Offline
              M Offline
              Muammar
              wrote on last edited by
              #6

              Hey Luc, Well, both files are written in C# "guess that's why i'm posting this in the C# forum:)"

              Luc Pattyn wrote:

              maybe just omitting the EntryPoint stuff solves it

              While I though adding it would solve the problem :laugh: .. I just added it after the problem has occurred! Anyways, thanks for helping Luc!


              All generalizations are wrong, including this one! (\ /) (O.o) (><)

              L 1 Reply Last reply
              0
              • M Muammar

                Hey Luc, Well, both files are written in C# "guess that's why i'm posting this in the C# forum:)"

                Luc Pattyn wrote:

                maybe just omitting the EntryPoint stuff solves it

                While I though adding it would solve the problem :laugh: .. I just added it after the problem has occurred! Anyways, thanks for helping Luc!


                All generalizations are wrong, including this one! (\ /) (O.o) (><)

                L Offline
                L Offline
                Luc Pattyn
                wrote on last edited by
                #7

                Hi Muammar, if you have a managed EXE/DLL calling unmanaged code in a DLL, then and only then you need the DllImport and the static external stuff (on the managed side), and you must worry about name mangling if the unmanaged code is C++. if both parts are managed, you don't use DllImport, you don't use external. You just use the type(s) from the DLL as if they are part of your EXE. :)

                Luc Pattyn [Forum Guidelines] [My Articles]


                This month's tips: - before you ask a question here, search CodeProject, then Google; - the quality and detail of your question reflects on the effectiveness of the help you are likely to get; - use PRE tags to preserve formatting when showing multi-line code snippets.


                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups