Calling Unmanaged C ++ Code from C #

I have zero experience in C ++, but I have experience in C # for several years.

Are there any examples showing how I can create a method in a C ++ program that is then called from a C # program using a DLL?

Greetings

+4
source share
3 answers

Using p / invoke, you can call C ++ code from C #.

Read the following: Win32 DLL call in C # with P / Invoke

Another small but good article: Using P / Invoke to access the Win32 API

-

EDIT:

This aritcle explains how to create a DLL in C and then use it with C #

+7
source

You can also try compiling C ++ code in Visual Studio on VC ++, which is plain old .NET. Avoid p / invoke if the code is compatible.

0
source

Create some function in C ++ using "extern "C"" to avoid changing the name of C ++, and then use PInvoke, as suggested by Nawaz, is the best way.

0
source

Source: https://habr.com/ru/post/1339628/


All Articles