简体   繁体   中英

Importing C# dll to C++ managed code (.NET)

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,

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.

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

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM