Igor Ševo
Igor Ševo

Reputation: 5525

Using a C# class from a managed C++ project

I have a solution with a managed C++ project and a C# project. The C# project is a class library project containing the GUI classes I use from the C++ project. This works well, but building results in two DLLs.

Is there a way of using the C# objects from the C++ project without having a dynamically linked library generated by the C# project (is there a way to embed the C# types into the managed C++ project)?

I am using Visual Studio 2015.

Upvotes: 1

Views: 94

Answers (1)

codekaizen
codekaizen

Reputation: 27429

There is a way, but it is far outside the tooling you are using to be able to accomplish it.

You can use command line tooling to create a multi netmodule assembly.

Managed assemblies are built of one or more "netmodules". Typically in a C# project, there is only one netmodule, and the C# compiler builds it and then links it into the assembly it produces. By using the command line tools, you can build only a module, then link it with the C++ module into an assembly.

Upvotes: 1

Related Questions