Use C++ dll from C#

2019-08-10 09:54发布

问题:

I have a C# GUI, and a dll I compiled in matlab for C++. I would like to call from my C# code to the dll functions. I tried first to convert the C# code to CLI, but then saw it is not recommended. Can I create one solution with 2 projects - one the C# GUI and one - wrap the c++ dll with C++ code and call it from the C# ?

Any reference will be appreciated.

Thanks

回答1:

You can use C++ dll's in C# by using [DllImport] attribute, it is described in this MSDN thread.