2

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,

David Yaw
  • 27,383
  • 4
  • 60
  • 93
monnoliv
  • 21
  • 1
  • 1
  • 2

5 Answers5

6

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.

David Yaw
  • 27,383
  • 4
  • 60
  • 93
0

You need to add a reference into your project. In Visual Studio, right-click your project, then select "References".

0

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

Link : http://support.microsoft.com/kb/828736

Aghilas Yakoub
  • 28,516
  • 5
  • 46
  • 51
0

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...

Mayank Pathak
  • 3,621
  • 5
  • 39
  • 67