Unable to find an entry point when calling C++ dll in C#

前端 未结 3 2208
感情败类
感情败类 2020-12-15 18:48

I am trying to learn P/Invoke, so I created a simple dll in C++

KingFucs.h:

namespace KingFuncs
{
    class KingFuncs
    {
    public:
        stati         


        
3条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-15 19:18

    The problem is that you are declaring the C++ "function" inside a C++ class and are telling P/Invoke to use StdCall.

    Try to declare a C++ function outside a class and and export it like you did. Then your code should work.

    If you really must have a C++ function inside a class, take a look at CallingConvention.ThisCall. But then you are responsible for creating your unmanaged class instance and pass it as the first parameter of your P/Invoke call

提交回复
热议问题