Getting An unhandled exception of type 'System.EntryPointNotFoundException'

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • gyanendar
    New Member
    • Jun 2007
    • 90

    Getting An unhandled exception of type 'System.EntryPointNotFoundException'

    Hi ,

    I am trying to call a method from unmanaged DLL in my C# client application.
    I am getting this exception "An unhandled exception of type 'System.EntryPo intNotFoundExce ption' occurred in DLLInjection.ex e"

    My C# Client code:
    Code:
    public class ImportedFunction
        {
           [DllImport("C:\\CPP Project\\DLLInjection\\Debug\\Win32DLL.dll")]
           public static extern int GetStorageName();
    
        }
    In Main()
    Code:
    Console.Write("Calling Imported Function...");
                
                int k=ImportedFunction.GetStorageName();
    IN C++ file.
    Code:
    #define DllExport   __declspec( dllexport)
    
    
    extern "C" DllExport int __stdcall
     GetStorageName();
    
    // dllmain.cpp : Defines the entry point for the DLL application.
    #include "stdafx.h"
    #include "dllmain.h"
    #include<Windows.h>
    
    BOOL APIENTRY DllMain( HMODULE hModule,
                           DWORD  ul_reason_for_call,
                           LPVOID lpReserved
    					 )
    {
    	switch (ul_reason_for_call)
    	{
    	case DLL_PROCESS_ATTACH:
    	case DLL_THREAD_ATTACH:
    	case DLL_THREAD_DETACH:
    	case DLL_PROCESS_DETACH:
    		break;
    	}
    	return TRUE;
    }
    
    
    int __stdcall GetStorageName()
    {
    	return 100;
    }
    Please help
  • Paul Johnson
    New Member
    • Oct 2010
    • 97

    #2
    Is it actually doing the import?

    Comment

    • gyanendar
      New Member
      • Jun 2007
      • 90

      #3
      Yes ...I m trying to import the function from DLL(written in C++)

      Comment

      • Paul Johnson
        New Member
        • Oct 2010
        • 97

        #4
        Bit of a misunderstandin g.

        You're trying to import a DLL. Have you checked that the import is actually happening? (by the looks of it, the binary cannot find the imported dll)

        Comment

        • bvrwoo
          New Member
          • Aug 2011
          • 16

          #5
          Does your dll have a .def file? Linking the DLL (plus .H and .LIB) in a C++ project does not need .def if using __declspec(dlle xport) before the function, but it does with C#/VB.NET.

          Comment

          Working...