Interop Type Cannot Be Embedded

Interop type cannot be embedded

.NET 4.0 allows primary interop assemblies (or rather, the bits of it that you need) to be embedded into your assembly so that you don't need to deploy them alongside your application.

For whatever reason, this assembly can't be embedded - but it sounds like that's not a problem for you. Just open the Properties tab for the assembly in Visual Studio 2010 and set "Embed Interop Types" to "False".

EDIT: See also Michael Gustus's answer, removing the Class suffix from the types you're using.

Cannot be embedded. Use the applicable interface instead

In your Project, expand the "References", find the Microsoft Office Interop reference. Right click it and select properties, and change "Embed Interop Types" to false.

Class cannot be embedded. Use the applicable interface instead

The 2nd error is caused by the first one. The Embed Interop Types feature only supports embedding interfaces, not classes. Other than just setting that option on the WIA reference to False and deploy the interop library, you could also fix it like this:

 WIA.CommonDialog wiaDiag = new WIA.CommonDialog();

Unintuitive but creating COM interfaces with the new operator is allowed. You need to prefix the namespace name because CommonDialog is ambiguous with the Winforms CommonDialog class.

Cannot Embed Interop Types from Assembly

Just so this isn't unmarked for the rest of eternity and for any potential future users with the same problem, the answer is, as suggested by @soohoonigan and @TnTinMn:

  • Clean and rebuild the solution.
  • If that doesn't work, remove the references, and re-add them again.


Related Topics



Leave a reply



Submit