by Michael Hodgdon posted on April 9 2010 03:52
Anyone that has ever consumed Interop assemblies from managed code has experienced some of the headaches with the old ways of coding Microsoft solutions. Some of those bigger issues are dealing with DLL hell and having to deploy and rely on those exact assembly versions availability on the target system. Add into the equation many different target environments and you have a real mess on your hands. The CLR team has added lots of great new features into .NET 4.0, one of those features is embedding Interop Types in your .net projects. And ... it's really easy to do!
First lets paint a bit of a scenario. You are working with a solution that must work with the Excel Interop classes. You must first start by adding the assemblies as a reference into your project. Now you code away and finish your solution. Once you deploy you realize that two of your systems don't have the assemblies installed at all, a third has different versions of the assemblies, and the final system is happy. 1 out of 4 is pretty bad and I am sure your users will have the same reaction! You could deploy those Interop assemblies along with your application but that is a bit messy as well given different deployment models and potential DCOM issues.
With Embedded Interop Types you can include your interfaces and functionality required for those Interop assemblies by simply checking off the embed on that assembly reference. The following screen shot demonstrates.

Now, if you load up that application, and look at the loaded assemblies, you will find that no Interop assemblies are loaded and you are working completely within your managed code. No need to rely on those target assemblies on the system. You can read more at: Type Equivalence and Embedded Interop Types
{ Happy Coding }