-1

I have an multi Module Project. Here we are passing System::Object^ from one exe to code from another DLL. When I am trying to convert that Object to its type(Here we have the same definition) in DLL, I am getting the below error...

[A] can not be cast to [B]; A originates from one assembly , b from another

I tried through some documents but could not crack through.

Both the below code giving that conversion error

LocalClassType ^x1 = LocalClassType (x);
LocalClassType ^x2 = cli::safe_cast<LocalClassType  ^>(x)

Can anyone please suggest or guide me through the document where I can convert correctly.

walnut
  • 21,629
  • 4
  • 23
  • 59
  • There is no conversion, it is a bug. Types from different assemblies are fundamentally incompatible, regardless if they have the same namespace and type name. That type identity rule is only relaxed for COM types. You must use the correct reference. – Hans Passant Nov 05 '19 at 11:33

1 Answers1

0

I was able to resolve the issue, and cast it using static_cast

LocalClassType ^x2 = static_cast<LocalClassType  ^>(x)