How to use C # code in a C ++ project

I have code in C # that I want to use in another project (encoded in C ++). From what I researched, I need to create a .lib, but MSVS creates a .dll (I think ..). I think it is possible to use a DLL using LoadLibrary () over C ++, but it seems not very friendly.

1 - Can I create .lib in MSVS? If not, how can I create it.

2 - What is the best way to integrate code? Using .lib or using .dll + LoadLibrary ()?

+3
source share
4 answers

The easiest option, to be honest, is to use C ++ / CLI. This allows you to use both object systems (.NET, and traditional C ++ with a standard library of templates).

+3

++? , # dll .

+1

What you need is a C # compatible class: http://en.allexperts.com/q/C-3307/2008/2/Using-C-class-C.htm http://blogs.msdn.com /b/deeptanshuv/archive/2005/06/26/432870.aspx

+1
source

One possibility is to make C # managed by COM code compatible. Then use the standard COM api (QueryInterface etc.) to invoke C # COM code.

Sample code project can be useful http://www.codeproject.com/KB/cs/ManagedCOM.aspx

+1
source

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


All Articles