how to use c++ libraries(.lib) in c# WPF project [duplicate]

冷暖自知 提交于 2019-12-24 09:18:10

问题


I have a library(.lib) which as been implemented in VC++. I want to include or use this library in c# wpf project how can i achieve it.


回答1:


You can use marshalling to access C++ code in your C# code.

Have a look at MSDN, too.

An example

[DllImport("example.dll")]
static public extern void DoSomething(int value);

and you can use your method in your C# code like usual

DoSomething(42);

Can be a bit confusing because you have to "map" the C++ types to C# and reverse.



来源:https://stackoverflow.com/questions/43116241/how-to-use-c-libraries-lib-in-c-sharp-wpf-project

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!