call unmanaged C++ code from C# using pinvoke

后端 未结 3 1319
南旧
南旧 2021-01-05 13:23

I have a unmanaged C++ dll for which I do not have access to code but have all methods declarations for.

Lets for simplicity say that .h looks like this:

<         


        
3条回答
  •  [愿得一人]
    2021-01-05 14:04

    To use a class from native C++ from C# you need a C++/CLi wrapper in between, as mentioned by by previous answers. To actually do that, it is not very straight forward. Here is I link that tell you how to do it at a high level: C++/CLI wrapper for native C++ to use as reference in C#.

    If you are quite new to this (like me), you might stumble on 1) -- the linking part. To solve that, you can see how I did here (see my question portion): Link error linking from managed to unmanaged C++ despite linking to .lib file with exported symbols

提交回复
热议问题