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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Unable to find an entry point when loading an unmanaged DLL

Unable to find an entry point when loading an unmanaged DLL

Scheduled Pinned Locked Moved C / C++ / MFC
c++helpquestion
6 Posts 2 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.
  • J Offline
    J Offline
    Jordan C Atlas
    wrote on last edited by
    #1

    Hello, I have an unmanaged C++ dll that I would like to load in a managed C++ application. I can call methods in the dll from an *unmanaged* program with no issues. I set up the import using: // Set up the import [DllImportAttribute("lib.dll")] int function(); The project is correctly set to find the libary files. When I run the compiled program, it throws an execption at the line: function(); The exception is: An unhandled exception of type 'System.EntryPointNotFoundException' occurred in testManaged.exe Additional information: Unable to find an entry point named function in DLL lib.dll. This error indicates that it cannot find the function in my libarary, but I know the function is there and accessible because I can access it from unmanged code. Is there something wrong with my import statement? Anything else? Thanks, --Jordan -- modified at 23:40 Thursday 19th January, 2006

    S J 2 Replies Last reply
    0
    • J Jordan C Atlas

      Hello, I have an unmanaged C++ dll that I would like to load in a managed C++ application. I can call methods in the dll from an *unmanaged* program with no issues. I set up the import using: // Set up the import [DllImportAttribute("lib.dll")] int function(); The project is correctly set to find the libary files. When I run the compiled program, it throws an execption at the line: function(); The exception is: An unhandled exception of type 'System.EntryPointNotFoundException' occurred in testManaged.exe Additional information: Unable to find an entry point named function in DLL lib.dll. This error indicates that it cannot find the function in my libarary, but I know the function is there and accessible because I can access it from unmanged code. Is there something wrong with my import statement? Anything else? Thanks, --Jordan -- modified at 23:40 Thursday 19th January, 2006

      S Offline
      S Offline
      Stephen Hewitt
      wrote on last edited by
      #2

      Try adding a ExactSpelling=true. I think the syntax would be like this: [DllImportAttribute("lib.dll", ExactSpelling=true)] int function(); But I'm not a dotNET guru... Steve

      J 1 Reply Last reply
      0
      • S Stephen Hewitt

        Try adding a ExactSpelling=true. I think the syntax would be like this: [DllImportAttribute("lib.dll", ExactSpelling=true)] int function(); But I'm not a dotNET guru... Steve

        J Offline
        J Offline
        Jordan C Atlas
        wrote on last edited by
        #3

        The ExactSpelling attribute did not fix it (I get the same exception), but thank you for the suggestion. --Jordan

        S 1 Reply Last reply
        0
        • J Jordan C Atlas

          The ExactSpelling attribute did not fix it (I get the same exception), but thank you for the suggestion. --Jordan

          S Offline
          S Offline
          Stephen Hewitt
          wrote on last edited by
          #4

          Can you post the declaration of the unmanaged function (so I can check the calling convention) - The C++ code. Steve -- modified at 0:06 Friday 20th January, 2006 FIXED errors

          J 1 Reply Last reply
          0
          • J Jordan C Atlas

            Hello, I have an unmanaged C++ dll that I would like to load in a managed C++ application. I can call methods in the dll from an *unmanaged* program with no issues. I set up the import using: // Set up the import [DllImportAttribute("lib.dll")] int function(); The project is correctly set to find the libary files. When I run the compiled program, it throws an execption at the line: function(); The exception is: An unhandled exception of type 'System.EntryPointNotFoundException' occurred in testManaged.exe Additional information: Unable to find an entry point named function in DLL lib.dll. This error indicates that it cannot find the function in my libarary, but I know the function is there and accessible because I can access it from unmanged code. Is there something wrong with my import statement? Anything else? Thanks, --Jordan -- modified at 23:40 Thursday 19th January, 2006

            J Offline
            J Offline
            Jordan C Atlas
            wrote on last edited by
            #5

            I found the problem -- I was using an improper function prototype for the shared function. I reset the import to say: // Set up the import [DllImportAttribute("lib.dll")] extern "C" int function(); I'm not sure why the extern "C" is necessary, so here is a link to the article that tipped me off: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconcreatingprototypesinmanagedcode.asp[^] Thanks again to Stephen for his suggestion. --Jordan

            1 Reply Last reply
            0
            • S Stephen Hewitt

              Can you post the declaration of the unmanaged function (so I can check the calling convention) - The C++ code. Steve -- modified at 0:06 Friday 20th January, 2006 FIXED errors

              J Offline
              J Offline
              Jordan C Atlas
              wrote on last edited by
              #6

              Stephen, The function was declared as: LIB_API int function(void); where I have #define LIB_API __declspec(dllexport) Changing it to: extern "C" LIB_API int function(void); seems to have fixed the problem -- I'd be happy to hear an explanation for that if you have one. Thanks, --Jordan -- modified at 0:14 Friday 20th January, 2006

              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