CHAPTER 16 DYNAMIC TYPES AND THE DYNAMIC LANGUAGE RUNTIME
Figure 16-7. PIAs are listed in the .NET tab of the Add Reference dialog box
Embedding Interop Metadata
Before the release of .NET 4.0, when a C# application made use of a COM library (PIA or not), you
needed to ensure the client machine had a copy of the interop assembly on their computer. Not only did
this increase the size of your application installer package, but the install script had to check that the PIA
assemblies were indeed present, and if not, install a copy to the GAC.
However, under .NET 4.0 and higher, you can now elect to embed the interoperability data directly
within your compiled .NET application. When you do so, you are no longer required to ship a copy of the
interoperability assembly along with your .NET application, as the necessary interoperability metadata
is hardcoded in the .NET program.
By default, when you select a COM library (PIA or not) using the Add References dialog, the IDE will
automatically set the Embed Interop Types property of the library to True. You can see this setting first
hand by selecting a referenced interop library in the References folder of the Solution Explorer, and then
investigating the Properties window (see Figure 16-8).
614