“Unable to find an entry point named [function] in dll” (c++ to c# type conversion)

前端 未结 9 1382
夕颜
夕颜 2020-12-14 02:09

I have a dll which comes from a third party, which was written in C++. Here is some information that comes from the dll documentation:

//start documentation
         


        
相关标签:
9条回答
  • 2020-12-14 02:39

    We had this problem when we want to access to DB and solved it by changing EF core to EF 6.4.4 It may be you have a problem like this and need to change or downgrade your version of EF (If you used EF)

    0 讨论(0)
  • 2020-12-14 02:45

    First make sure the function is actually exported:

    In the Visual Studio Command Prompt, use dumpbin /exports whatever.dll

    0 讨论(0)
  • 2020-12-14 02:47

    I solved the same problem in these steps:

    step 1) If you program your custom DLL in C++ using Visual studio,then at the property page of your project set the Common Language Runtime Support (/clr)parameter to Common Language Runtime Support (/clr).

    step 2) To function deceleration in .h file use __declspec(dllexport) keyword like below:

    __declspec(dllexport) double Sum(int a,int b);
    

    step 3) Build and export DLL file, then use the Dependency Walker software to get your function EntryPoint.

    step4) Import DLL file In the C# project and set EntryPoint and CallingConvention variable like below:

    [DllImport("custom.dll", EntryPoint = "?Sum@@YAXHHHHHHNNN@Z", CallingConvention = CallingConvention.Cdecl)]
    
        public static extern double Sum(int a,int b);
    
    0 讨论(0)
提交回复
热议问题