I'm using Visual Studio 2010. I've written a dll in C#, managed dll then. Now for some reason, I need to write a software in C++ (.NET then also managed). I need to import the C# dll into my C++ .NET code. I can't figure out to do this, I've made several search but this problem seems to not be covered. For example, in C# I don't have include file, then how my C++ (.NET) projet knows about classes and functions inside the dll? Thanks,
-
You just need to add only reference of that dll in your project, as George has replied.. – Mayank Pathak Sep 12 '12 at 12:07
-
I've already add the dll reference in the c++ project, then what's next? – monnoliv Sep 12 '12 at 12:13
-
then use that namespace or name of classes in your code... – Mayank Pathak Sep 12 '12 at 12:18
5 Answers
In Visual Studio, bring up the properties of the C++/CLI project, go to "Common Properties/Framework and References" in the tree at the left, and click the "Add New Reference" button. This will bring up the standard "Add Reference" dialog you can get from a C# project, just select your C# DLL or reference a C# project in the same solution.

- 27,383
- 4
- 60
- 93
You need to add a reference into your project. In Visual Studio, right-click your project, then select "References".
You add reference to you assembly, Set ComVisible attribute
to your assembly
Edit your AssemblyInfo.cs
[assembly: ComVisible(true)]
.Net Framework have MSIL langage in order to manage interoperability betwwen different langages

- 28,516
- 5
- 46
- 51
You just need to add only reference of that dll in your project, as George has replied. then use that namespace or name of classes in your code...

- 3,621
- 5
- 39
- 67
It is possible. Google search would gave you answers. Few links from Stackoverflow
How to use c# Dll in vc++? using c# dll in project c++
Hope this helps