再次引用嵌入式互操作程序集 [英] References to embedded interop assemblies, again

查看:93
本文介绍了再次引用嵌入式互操作程序集的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将第三方图形包Olectra Chart包含到VB.Net项目中,但受到以下警告的困扰:-

I am including Olectra Chart, a third-party graphics package, into a VB.Net project, but am plagued with the following warnings:-

vbc:警告BC40059:已创建对嵌入式互操作的引用程序集"Interop.OlectraChart2D",因为间接引用程序集"AxInterop.OlectraChart2D"中的程序集.考虑更改任一程序集上的嵌入互操作类型"属性.

vbc : warning BC40059: A reference was created to embedded interop assembly 'Interop.OlectraChart2D' because of an indirect reference to that assembly from assembly 'AxInterop.OlectraChart2D'. Consider changing the 'Embed Interop Types' property on either assembly.

vbc:警告BC40059:已创建对嵌入式互操作的引用程序集"Interop.OlectraChart2D",因为间接引用程序集"MyClassLibrary"中的该程序集.考虑更改嵌入任一程序集上的Interop Types属性.

vbc : warning BC40059: A reference was created to embedded interop assembly 'Interop.OlectraChart2D' because of an indirect reference to that assembly from assembly 'MyClassLibrary'. Consider changing the 'Embed Interop Types' property on either assembly.

这些似乎防止必要的dll被包含在 bin 目录中,从而在运行时导致异常.

These appear to prevent the necessary dlls from being included in the bin directory, resulting in exceptions at run-time.

因此出现异常:-

System.IO.FileNotFoundException:无法加载文件或程序集'Interop.OlectraChart2D,版本= 6.0.0.0,文化=中性,PublicKeyToken = null"或其依赖项之一.系统无法查找指定的文件.文件名:'Interop.OlectraChart2D,版本= 6.0.0.0,文化=中性,PublicKeyToken =空'

System.IO.FileNotFoundException: Could not load file or assembly 'Interop.OlectraChart2D, Version=6.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified. File name: 'Interop.OlectraChart2D, Version=6.0.0.0, Culture=neutral, PublicKeyToken=null'

我已经在此处给出了答案此处,并尝试在属性面板中为 AxInterop.OlectraChart2D Interop.OlectraChart2D 的所有可能组合 Embed Interop Types 值,但它们均不能清除警告,而不会产生编译错误.

I have noted the answers given here and here, and have tried all possible combinations of Embed Interop Types values in the property panel for AxInterop.OlectraChart2D and Interop.OlectraChart2D but none of them clears the warnings without creating compilation errors.

将项目包含在不同的解决方案中会带来不同的警告:-

Including the project in a different solution brings different warnings:-

COM参考'OlectraChart2D'是ActiveX的互操作程序集控件"AxOlectraChart2D",但已被编译器标记为已链接/link标志.此COM参考将被视为参考并且不会被链接.

COM Reference 'OlectraChart2D' is the interop assembly for ActiveX control 'AxOlectraChart2D' but was marked to be linked by the compiler with the /link flag. This COM reference will be treated as a reference and will not be linked.

,但是输出 bin 目录很好.

我可以通过将dll从其他解决方案复制到 bin 目录中来清除运行时异常,但这对我来说似乎不对.有谁知道我该怎么做才能正确解决此问题?

I can clear the run-time exception by copying the dlls into the bin directory from other solutions but that doesn't seem right to me. Does anyone know what I should do to fix this properly?

推荐答案

我对此问题的回答也可能会解决您的问题:

my answer from this question might also solve your issue: Cannot be used across assembly boundaries because it has a generic type parameters that is an embedded interop type

答案:

我通过确保所有程序集都具有嵌入互操作性"来解决此问题键入"为FALSE.

I fixed this by making sure that all assemblies had "Embed Interop Types" to FALSE.

似乎通常在使用COM库时会设置参数默认为true.

It seems that usually when you use a COM library that parameter is set to true by default.

这篇关于再次引用嵌入式互操作程序集的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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