標籤: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/