use*_*861 6 c# activex stdole visual-studio-2010
首先,我需要使用第三方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.
Run Code Online (Sandbox Code Playgroud)
很容易,我会遵循这个建议,并为嵌入式引用设置Embed Interop Types为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.
Run Code Online (Sandbox Code Playgroud)
所以,我想这不会发生(虽然我不确定为什么删除嵌入在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
Run Code Online (Sandbox Code Playgroud)
那么,有关如何摆脱警告并拥有可以构建和运行的东西的任何建议吗?
UPDATE
Hans Passant发表评论作为答案确实解决了这个问题.如果他将其作为答案重新发布,我会接受它.不幸的是,我也遇到了标准问题,即将设置为Copy Local的DLL很好地复制到其项目的发布文件夹中,但不会移动到解决方案的最终版本文件夹(单独的可执行文件).我现在通过在我的可执行文件中添加对stdole的引用来解决这个问题.我想这可能已经够好了.
汉斯·帕桑特 的回答:
您不能嵌入 ActiveX 组件的类型。目标计算机缺少 stdole 的 PIA,请尝试将“复制本地”属性设置为 true 并复制生成的 stdole.dll。
归档时间: |
|
查看次数: |
7836 次 |
最近记录: |