Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does "reference was created to embedded interop assembly" mean?

Tags:

.net

.net-4.0

I am getting the following warning:

A reference was created to embedded interop assembly c:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\Accessibility.dll because of an indirect reference to that assembly created by assembly c:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\System.Windows.Forms.dll. Consider changing the 'Embed Interop Types' property on either assembly.`

My assembly contains a reference to both Accessibility.dll and System.Windows.Forms.dll. Why am I getting this warning?

Btw, the Accessibility.dll has 'Embed Interop Types=true' while System.Windows.Forms.dll has it set to false.

like image 367
AngryHacker Avatar asked Nov 16 '11 18:11

AngryHacker


People also ask

What is an interop assembly?

Interop assemblies are . NET Framework assemblies that bridge between managed and unmanaged code, mapping COM object members to equivalent . NET Framework managed members. Interop assemblies created by Visual Basic . NET handle many of the details of working with COM objects, such as interoperability marshalling.

What is embed interop types?

Embed Interop Types is a new feature of the . NET 4.0 Framework that allows you to include the attribute information that is normally stored in the Primary Interop Assembly (PIA) in the executable or dynamic-link library (DLL) instead.


Video Answer


1 Answers

Per the MSDN:

"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."

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.

This means you must change 'Embed Interop Types=true' on System.Windows.Forms.dll

or

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).

like image 54
KreepN Avatar answered Oct 04 '22 17:10

KreepN