无法沉默嵌入互操作警告

首先,我需要使用第三方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引用。 一切都看起来很好,直到我现在去客户机,当突然应用程序抛出这个:

 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. 

所以,我想这不会发生(虽然我不确定为什么删除嵌入在stole上的interop会产生使图书馆完全不可用的效果)。

好吧,让我们走另一条路,用Embed Interop标记所有内容。 OOPS! 编译错误:

 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 

那么,有关如何摆脱警告并拥有可以构建和运行的东西的任何建议吗?

UPDATE

Hans Passant发表评论作为答案确实解决了这个问题。 如果他将其作为答案重新发布,我会接受它。 不幸的是,我也遇到了标准问题,其中设置为Copy Local的DLL很好地复制到其项目的发布文件夹中,但是不会移动到解决方案的最终版本文件夹(单独的可执行文件)。 我现在通过在我的可执行文件中添加对stdole的引用来解决这个问题。 我想这可能已经够好了。

Hans Passant的回答:

您不能嵌入ActiveX组件的类型。 目标计算机缺少PIA for stdole,尝试将Copy Local属性设置为true并复制生成的stdole.dll。

如果在VS10中创建新项目,它可能使用.NET framework 4客户端配置文件作为默认值,您可以在项目属性 – >应用程序选项卡页面中将目标框架设置为.NET Framework 4。