C# DllImport library written on C++

前端 未结 3 905
一个人的身影
一个人的身影 2021-01-16 19:25

I\'m pretty new in C#. I have Dll written on C++ by myself and I\'m going to use functions from that dll in C# app.

So, I do the following when declare functions in

3条回答
  •  悲哀的现实
    2021-01-16 20:28

    public static __declspec(dllexport) int captureCamera(int& captureId);

    is that method? If it is function, it cannot be static, as static and dllexport are mutually exclusive.

    And the name is mangled. See http://en.wikipedia.org/wiki/Microsoft_Visual_C%2B%2B_Name_Mangling. If you can get the mangled name, and then provide the DllImport with it (EntryPoint=MANGLED_NAME), it should work.

    You can provide linker with .def file, containing definition of exported functions, and their names aren't mangled then:

    Project.def:

    EXPORTS
        captureCamera @1
    

提交回复
热议问题