In C#, I’m developing a web application using the.NET 4.0 framework (beta2).
I receive the following problem when I try to utilize an assembly called “ActiveHomeScriptLib”:
There are no errors when I upgrade the framework to version 3.5.
What is an Interop Type, and why is this happening just when I’m using the 4.0 framework?
Asked by Jan
Primary interop assemblies (or rather, the parts you require) can be incorporated within your assembly in.NET 4.0, eliminating the need to deploy them alongside your application.
This assembly can’t be embedded for whatever reason, but it doesn’t appear to be a problem for you. Simply change “Embed Interop Types” to “False” in the assembly’s Properties tab in Visual Studio 2010.
EDIT: Also see Michael Gustus’s response, which suggests eliminating the Class suffix from the kinds you’re using.
Answered by Jon Skeet
The most common cause of this problem is code that attempts to instantiate a COM object. For instance, here’s a bit of code that starts Excel:
Excel.ApplicationClass xlapp = new Excel.ApplicationClass();
In most cases, all you have to do in.NET 4 is remove the ‘Class’ suffix and build the code:
Excel.Application xlapp = new Excel.Application();
An MSDN explanation can be found here.
Answered by Michael Gustus
It took me a bit to figure it out, too, like Jan. So, if you’re blinded by frustration, this is for you.
Answered by gideon
In Visual Studio 2012, this is where you set the Embed Interop.
Answered by VK_217
Adding to Jon’s right response.
The issue is that you’re using the new “Embed Interop Types” (or NoPIA) functionality in conjunction with the use of a class type. The “Embed Interop Types” feature removes the overhead of deploying a PIA (Primary Interop Assembly) by statically linking in all of the types from it into the referring assembly.
This feature is wonderful for most PIA kinds, but it does contain certain limitations. One of them is that you can’t embed classes (due to a problem with servicing). Misha has a lengthy blog post explaining why this is not permitted.
Answered by JaredPar
Post is based on https://stackoverflow.com/questions/2483659/interop-type-cannot-be-embedded