I am facing this error with C# (wpf). This link has not been useful
Cannot be used across assembly boundaries because it has a generic type parameters that is an embedded interop type
Just to explain the structure of my program I can tell that:
I am using a library made by an external company. We can call it PCDLRN
In the solution I have a project made by me which incluse the types in the previous lib. In my library I define:
public ObservableCollection<PCDLRN.DimensionCmd> obcPcdlrnDimensionCommands = new ObservableCollection<PCDLRN.DimensionCmd>();
in order to by used in my main program. So in short:
PCDLRN->MYLIB obcPcdlrnDimensionCommands --> MY PROGRAM myPcd.obcPcdlrnDimensionCommands
in my program I want to access the aforementioned ObservableCollection but it doesn't build giving the error in the title.
--EDIT--- As suggested I have changed from embedded = true to false by changing the prop as in picture but the error remains
As WasGoodDone remarked, you need to use the same class for both (all) assemblies you use for generics.
In other words, if you have assembly1
, that references some interopAssembly
, and assembly2
, that references the same interopAssembly
, and you switch embedded interop type
to true
, then you will have two copies of types from interopAssembly
.
If you want to use some cross-references from assembly1
to assembly2
, .NET can't resolve it, because from their point of view, the classes are different.
When you switch the embedded option off, your assembly will reference the other assembly which contains the interop types. And in this way you can use the interop types in different libraries.
So, if you have the problem described above, it means that you have at least two assemblies referencing PCDLRN, and you must switch off embedded interop type
in all of them.
Embed Interop types
was not shown on the property pages for my assembly (as in the question above), so I edited the project files directly to fix this problem:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With