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

2019-07-24 11:26发布

This question already has an answer here:

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条回答
乱世女痞
2楼-- · 2019-07-24 12:10

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.

查看更多
登录 后发表回答