Code Simplified – Viral Sarvaiya

Code Simplified – Viral Sarvaiya, Web Developer Friends, dot net Developer, Sql Server Developer

Interop type cannot be embedded. Use the applicable interface instead

Posted by Viral Sarvaiya on August 2, 2011

Today i face one more difficulty in my current project,

i am useing .net 4.0 framework with WPF application.

In this application i am adding one dll file that communicate with COM port and i get error “Interop type cannot be embedded. Use the applicable interface instead.”.

this code is perfactly run with .net 3.5 framework but not in 4.0.

and i get the solution for that as below.

Common Language Runtime in .Net 4.0 supports embedding of COM types information directly into managed assemblies in order to simplify deployment process. Managed assemblies need not have to read type information from interop assemblies any more.

In the managed assembly  you can embaded only COM type metadata so it will only works with interfaces, structures, enums and delegates

so what to do for this problem? the solution is “use interfaces instead of classes” or “simply copy constant values from the class definition locally and use them instead.”

hope this will helps you..

thanks

Advertisements

5 Responses to “Interop type cannot be embedded. Use the applicable interface instead”

  1. PatTormey said

    THANKS Viral.. Saved my day..
    Pat NH USA

  2. Pasquaz said

    me too…

  3. Naku said

    I had VB6 dll. One day I wanted to use that(VB6 dll) for C#.net project(.net 4 framework). Once dll added, I couldn’t create object using dll. these error message was come. I did spent two days for solution… Ur article is very useful. You save our time.
    thank for ur answer

  4. Viral Sarvaiya said

    Hi to all,

    Happy to know that my work is very helpful to others and save days in which i spent to get solution.

    Thanks for the appreciation.

  5. narasimha said

    Hi Viral,
    Given solution worked for me.

    Thanks.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: