如何在VS 2013中将C#dll链接到C ++ / CLI项目 [英] How to link C# dll to C++/CLI project in VS 2013

查看:70
本文介绍了如何在VS 2013中将C#dll链接到C ++ / CLI项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Visual Studio 2013中有一个使用/ clr标志编译的Visual C ++项目,根据我的理解,这意味着它具有Microsoft的.Net兼容性并且与纯C ++不同。

I have a Visual C++ project in Visual Studio 2013 that is compiled with the /clr flag, which, as I understand it, means it has Microsoft's .Net compatibility and deviates from pure C++.

我需要添加C#库(System.IO.Packaging.dll和  DocumentFormat.OpenXml.dll)。在世界的哪个地方

I need to add in C# libraries (System.IO.Packaging.dll and DocumentFormat.OpenXml.dll). Where in the world

我在VC ++项目中的哪些地方将这些链接起来,因为似乎有多个地方。  我见过的最常见的是 

Where in the VC++ project do I link these in, as there seem to be multiple places.  The one I've seen referred to most is in 

属性 - >配置属性 - >链接器 - >输入 - >其他依赖关系

Properties->Configuration Properties->Linker->Input->Additional Dependencies

在该菜单中,我添加了这两个库,但没有在C ++代码中添加对它的任何引用。  编译会产生以下错误:

In that menu I added those two libraries, without yet adding any references to it in the C++ code.  Compiling produce the following error:

我有一个简单的C#项目,其中我使用这些库,链接就像包含它们一样简单。  在C ++中不是这样。  
$
我可以将这些库连接起来的方式是什么?  我是否还需要其他一些文件,比如头文件?

I had a simple C# project where I used these libraries and the linking was as easy as including them as a reference.  Not so in the C++.  
What's the way I can link these libraries in?  Do I need some other files too, like header files?

推荐答案

添加参考功能是也出现在C ++ / CLR中:
https:// msdn。 microsoft.com/en-us/library/hh708954(v=vs.120).aspx 。然后选择DocumentFormat.OpenXml.dll。要从
System.IO.Packaging 命名空间确定类所需的程序集,请查看文档。

The Add Reference feature is present in C++/CLR too: https://msdn.microsoft.com/en-us/library/hh708954(v=vs.120).aspx. Then select DocumentFormat.OpenXml.dll. In order to determine which assemblies are required for the classes from System.IO.Packaging namespace, check the documentation.


这篇关于如何在VS 2013中将C#dll链接到C ++ / CLI项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆