Reputation: 926
I have a piece of unmanaged native C++ code (one class) that I want to integrate into a C# .NET assembly.
I (think) I know I have two options for doing this:
Let's suppose I want to go for option 2 and use Visual Studio Express 2015 IDE GUI, without calling directly the compilers from command line.
Do I need to make two separate projects for the two C# (project "C#") and C++/CLI-C++/native (project "C++") parts, then reference (add reference) the DLL output file of project "C++" from project "C#" and link it statically? Is this the only way or could C++ source files be integrated directly into project "C#" by specifying a different compiler and different compiler options for each of them?
Upvotes: 3
Views: 7372
Reputation: 9835
If you pick option 2. You have to create 3 projects:
Add a reference of the wrapper to your C# project and add a reference of the native project to your wrapper. You can, however, add your native C++ code directly to the wrapper and remove the 3rd project. But afaik you can't use the wrapper in other native C++ projects then.
You can't add C++ code directly to C#, so you have to go with one of your mentioned options.
Upvotes: 3
Reputation: 784
If you go with option 2 you need a separate C++/CLI project that you must reference from c# project.
I suppose that "link it statically" means to add the assembly reference, which isn't the same thing.
Upvotes: 2