簡體   English   中英

無法沉默嵌入互操作警告

[英]Can't Silence Embed Interop Warnings

首先,我需要使用第三方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.

很容易,我會遵循這個建議,並為嵌入式引用設置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.

所以,我想這不會發生(雖然我不確定為什么刪除嵌入在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。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM