C# - 設定DLL的屬性Embed Interop Type 設為False

來源:互聯網
上載者:User

標籤:blog   http   strong   os   2014   cti   

錯誤:

Error msg: A reference was created to embedded interop assembly. because of an indirect reference to that assembly created by assembly. Consider changing the ‘Embed Interop Types‘ property on either assembly.

 

解決方案:

      將DLL的屬性Embed Interop Type 設為False.  否則會引起互操作類型異常。

  當設定為True時,該COM組件的互動類型資訊將在編譯時間被嵌入到項目的類庫中。

  當設定為False時,該COM組件的互動類型都需要一個額外的Primary Interop Assemblies(PIA)來提供。但是Net中已經將其封裝了,對開發人員而言是透明的。 參考

 

官方解釋:

http://msdn.microsoft.com/en-us/library/ff182188.aspx

A reference was created to embedded interop assembly ‘<assembly1>‘ because of an indirect reference to that assembly from assembly ‘<assembly2>‘. Consider changing the ‘Embed Interop Types‘ property on either assembly.

 

You have added a reference to an assembly (assembly1) that has the Embed Interop Types property set to True. This instructs the compiler to embed interop type information from that assembly. However, the compiler cannot embed interop type information from that assembly because another assembly that you have referenced (assembly2) also references that assembly (assembly1) and has the Embed Interop Types property set to False.

                   Note                

Setting the Embed Interop Types property on an assembly reference to True is equivalent to referencing the assembly by using the /link option for the command-line compiler.

Error ID: BC40059

To address this warning
  • To embed interop type information for both assemblies, set the Embed Interop Types property on all references to assembly1 to True.

  • To remove the warning, you can set the Embed Interop Types property of assembly1 to False. In this case, interop type information is provided by a primary interop assembly (PIA).

 

其他參考:

http://stackoverflow.com/questions/8156488/what-does-reference-was-created-to-embedded-interop-assembly-mean

http://blogs.clariusconsulting.net/kzu/check-your-embed-interop-types-flag-when-doing-visual-studio-extensibility-work/

http://bbs.csdn.net/topics/390599484

http://blogs.clariusconsulting.net/kzu/check-your-embed-interop-types-flag-when-doing-visual-studio-extensibility-work/

 

 

 

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.