我应该使用.NET应用程序部署Interop.x.dll文件吗? [英] Should I deploy Interop.x.dll files with .NET application?

查看:68
本文介绍了我应该使用.NET应用程序部署Interop.x.dll文件吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一个.NET应用程序,该应用程序使用不同DLL中的COM对象,该应用程序的VB6部分中也使用了该对象。引用COM库时,Visual Studio 2012将创建一个Interop.x.DLL并引用它。我应该从构建计算机分发Interop.x.DLL还是使用某些.NET命令行工具重新生成它?什么工具部署引用COM的.NET应用程序的最佳实践是什么?

We have a .NET app that consumes COM-objects in different DLLs, also used in the VB6 part of our app. When referencing a COM library, Visual Studio 2012 creates an Interop.x.DLL and references that instead. Should I be distributing Interop.x.DLL from the build machine or regenerating it using some .NET command-line tool? What tool? What is the best practice for deploying a .NET app that references COM?

推荐答案

不,自VS2010以来不再需要.NET 4.0。您只需将互操作程序集引用的嵌入互操作类型属性设置为True。默认设置。

No, that is not necessary anymore since VS2010 and .NET 4.0. You simply set the Embed Interop Types property of the interop assembly reference to True. The default setting.

启用此选项后,互操作类型将复制到您自己的程序集中,就像您已经编写了 [ComImport] 亲自声明。并且只有您在代码中实际使用的代码。对于大型组件而言,此功能最有价值,尤其是Microsoft.Office.Interop程序集非常大。但是对于小型组件当然也总是很方便,因为您不必再​​部署互操作程序集。

With this option in effect, the interop types get copied into your own assembly, as though you had written the [ComImport] declarations yourself by hand. And only the ones you actually use in your code. The feature pays off most for large ones, the Microsoft.Office.Interop assemblies in particular are very large. But of course always handy as well for small components since you don't have to deploy the interop assembly anymore.

这篇关于我应该使用.NET应用程序部署Interop.x.dll文件吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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