首先,我有一个第三方ActiveX控件,我需要使用。
接下来,我必须使用stdole库来为第三方控件提供一些图像。在默认设置下编译时,会收到一些警告:
warning CS1762: A reference was created to embedded interop assembly 'c:\Windows\assembly\GAC\stdole\7.0.3300.0__b03f5f7f11d50a3a\stdole.dll' because of an indirect reference to that assembly created by assembly 'XXX\obj\x86\Release\Interop.ThirdPartyControl.dll'. Consider changing the 'Embed Interop Types' property on either assembly.
warning CS1762: A reference was created to embedded interop assembly 'c:\Windows\assembly\GAC\stdole\7.0.3300.0__b03f5f7f11d50a3a\stdole.dll' because of an indirect reference to that assembly created by assembly 'XXX\obj\x86\Release\AxInterop.ThirdPartyControl.dll'. Consider changing the 'Embed Interop Types' property on either assembly.很简单,我将遵循这个建议,并为stdole引用将Embed类型设置为false。在我现在转到客户端机器之前,一切看起来都很好,这时应用程序突然出现了这样的情况:
Could not load file or assembly 'stdole, Version=7.0.3300.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.所以,我想这是不可能的(虽然我不知道为什么删除stdole上的嵌入互操作会使库完全找不到)。
那么,让我们走另一条路,用Embed true标记所有内容。糟了!编译错误:
Error 2 Cannot embed interop types from assembly 'XXX\obj\x86\Release\AxInterop.ThirdPartyControl.dll' because it is missing either the 'ImportedFromTypeLibAttribute' attribute or the 'PrimaryInteropAssemblyAttribute' attribute XXX\obj\x86\Release\AxInterop.ThirdPartyControl.dll XXX
Error 1 Cannot embed interop types from assembly 'XXX\obj\x86\Release\AxInterop.ThirdPartyControl.dll' because it is missing the 'GuidAttribute' attribute XXX\obj\x86\Release\AxInterop.ThirdPartyControl.dll XXX那么,对于如何消除警告,有什么可以构建和运行的东西,有什么建议吗?
更新
汉斯·帕桑特()发表了一个确实解决了这个问题的答案,作为评论。如果他把它重新贴出来作为回答,我会接受的。不幸的是,我还遇到了一个标准问题:将复制本地的DLL很好地复制到其项目的发布文件夹中,但不会移动到解决方案的最终发布文件夹(一个单独的可执行文件)。现在,我已经通过在可执行文件中添加对stdole的引用来解决这个问题。我想这可能已经足够了。
发布于 2013-03-29 04:29:48
汉斯·帕桑的回答:
不能嵌入ActiveX组件的类型。目标机器缺少stdole的PIA,尝试将设置为true,并复制生成的stdole.dll。
发布于 2013-10-08 08:18:58
如果您在VS10中创建了一个新项目,它可以使用.NET Framework4ClientProfile作为默认设置,您可以在项目属性->Application页面中将目标框架设置为.NET Framework4。
https://stackoverflow.com/questions/11102718
复制相似问题