Visual Studio 2010 has a new feature, Embed Interop Types, that can simplify app deployment and solve those pesky issues that can arise when using COM Interop and Primary Interop Assemblies (PIAs). If you’ve ever had to ship multiple versions of an app that automates Microsoft Office where the only difference between your published versions is the version of PIA (to match different Office versions), then this feature is for you.
You enable type embedding when you reference an assembly. In VS, you set Embed Interop Types property to true (default). Command-line compiler equivalent is the new /link compiler option. You can read all about the feature here: /link compiler option (C#), /link compiler option (VB). There’re couple of walkthrough available:
- Embedding Type Information from Microsoft Office Assemblies (C# and Visual Basic)
- Embedding Types from Managed Assemblies (C# and Visual Basic) (it’s not just for COM Interop)