本文介绍了将C#dll导入C ++托管代码(.NET)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Visual Studio2010。我已经用C#编写了一个dll,然后是托管dll。
现在由于某种原因,我需要用C ++编写一个软件(然后也可以管理.NET)。
我需要将C#dll导入我的C ++ .NET代码。
我不知道要怎么做,我进行了几次搜索,但似乎没有解决这个问题。例如,在C#中我没有包含文件,那么我的C ++(.NET)Projet如何知道dll中的类和函数?
谢谢,

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,

推荐答案

在Visual Studio中,调出C ++ / CLI项目的属性,请转到常见单击左侧树中的属性/框架和参考,然后单击添加新参考按钮。这样会弹出一个标准的添加引用对话框,您可以从一个C#项目中获得该对话框,只需选择您的C#DLL或在同一解决方案中引用一个C#项目即可。

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.

这篇关于将C#dll导入C ++托管代码(.NET)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-03 07:22