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

前端 未结 9 1381
夕颜
夕颜 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:21

    C# doesn't support C++ name mangling and you either need to declare the C++ functions with

    extern "C" {...}
    

    (may not an option if they're from a third party), or call the mangled name directly if you can get it to work. It may be easier to get the third party to provide a non-mangled interface to the functionality.

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

    Correct EntryPoint string could be found in ".lib" file that comes along with main unmanaged dll.

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

    I'd write a wrapper using C++/CLI. This wrapper will be able to include the .h files and link to the .lib files you got from the third party vendor. Then it is both easy and safe to write a managed interface for your C# program.

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

    You could try using the unmangled name while specifying a CallingConvention in the DllImport

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

    Solved - at least to the point where the program does not break and actually returns me a bool value.

    The key, I guess, was to specify the entry point as the 'mangled' name

        [DllImport(@"cnOCRsdk.dll", EntryPoint="?recoCHN_P_Name@CcnOCRsdk@@QAE_NPADPAURECO_DATA@@@Z")]
        public static extern bool recoCHN_P_Name(ref string imgPath, ref RECO_DATA o_data);
    

    After that I got some other errors but the 'unable to find entry point' went away.

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

    We had this problem .we change EntityFramework.core to EntityFrameWork 6.4.4 and after that the program worked fine. you most change you're Framework Version.

    0 讨论(0)
提交回复
热议问题