Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the difference setting Embed Interop Types true and false in Visual Studio?

People also ask

What does embed interop types mean?

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.

How do I set the Embed Interop Type property?

Select the TestStand Interop Assembly reference in the references section of your project in the Solution Explorer. Find the Embed Interop Types property in the Property Browser, and change the value to False.

What is primary interop assemblies?

An interop assembly is a managed . NET equivalent of a COM type library. An Interop Assembly that is distributed by the owner of the original COM server is called a primary interop assembly (PIA). Primary Interop Assemblies are always digitally signed by the publisher of the original unmanaged assembly.


This option was introduced in order to remove the need to deploy very large PIAs (Primary Interop Assemblies) for interop.

It simply embeds the managed bridging code used that allows you to talk to unmanaged assemblies, but instead of embedding it all it only creates the stuff you actually use in code.

Read more in Scott Hanselman's blog post about it and other VS improvements here.

As for whether it is advised or not, I'm not sure as I don't need to use this feature. A quick web search yields a few leads:

  • Check your Embed Interop Types flag when doing Visual Studio extensibility work
  • The Pain of deploying Primary Interop Assemblies

The only risk of turning them all to false is more deployment concerns with PIA files and a larger deployment if some of those files are large.


I noticed that when it's set to false, I'm able to see the value of an item using the debugger. When it was set to true, I was getting an error - item.FullName.GetValue The embedded interop type 'FullName' does not contain a definition for 'QBFC11Lib.IItemInventoryRet' since it was not used in the compiled assembly. Consider casting to object or changing the 'Embed Interop Types' property to true.