首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >不能沉默地嵌入互操作警告

不能沉默地嵌入互操作警告
EN

Stack Overflow用户
提问于 2012-06-19 14:05:38
回答 2查看 8K关注 0票数 6

首先,我有一个第三方ActiveX控件,我需要使用。

接下来,我必须使用stdole库来为第三方控件提供一些图像。在默认设置下编译时,会收到一些警告:

代码语言:javascript
复制
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。在我现在转到客户端机器之前,一切看起来都很好,这时应用程序突然出现了这样的情况:

代码语言:javascript
复制
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标记所有内容。糟了!编译错误:

代码语言:javascript
复制
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的引用来解决这个问题。我想这可能已经足够了。

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2013-03-29 04:29:48

汉斯·帕桑的回答:

不能嵌入ActiveX组件的类型。目标机器缺少stdole的PIA,尝试将设置为true,并复制生成的stdole.dll。

票数 3
EN

Stack Overflow用户

发布于 2013-10-08 08:18:58

如果您在VS10中创建了一个新项目,它可以使用.NET Framework4ClientProfile作为默认设置,您可以在项目属性->Application页面中将目标框架设置为.NET Framework4。

票数 -2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/11102718

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档