Notice (2018-05-24): bugzilla.xamarin.com is now in
Please join us on
Visual Studio Developer Community and in the
Mono organizations on
GitHub to continue tracking issues. Bugzilla will remain
available for reference in read-only mode. We will continue to work
on open Bugzilla bugs, copy them to the new locations
as needed for follow-up, and add the new items under Related
Our sincere thanks to everyone who has contributed on this bug
tracker over the years. Thanks also for your understanding as we
make these adjustments and improvements for the future.
Please create a new report on
GitHub or Developer Community with
your current version information, steps to reproduce, and relevant error
messages or log files if you are hitting an issue that looks similar to
this resolved bug and you do not yet see a matching new report.
Created attachment 19654 [details]
I made a small sample, it's work on Full NET but doesn't work on Mono.
I can reproduce with Mono 220.127.116.11 (2017-10/a3943e28cf8)
Just going to document what I learned so far:
1. The documentation for "Embed Interop Types" is https://docs.microsoft.com/en-us/dotnet/framework/interop/type-equivalence-and-embedded-interop-types?view=netframework-4.7 Basically, two interfaces in two different assemblies can have attributes applied that should convince the runtime to treat them as equivalent. In a way it doesn't even have anything to do with COM (if you apply the TypeIdentifierAttribute I think it works with purely managed types - I don't think you need to make the type COM visible at all), but the primary usecase is COM. The user-visible bit that makes it go is the System.Type.IsEquivalentTo method.
The weird part is that the two types being equated could be very different: they might
not be textually the same interface. The COM usecase is that you embed only the subset of the interface that's actually used in an assembly.
2. Mono's System.Type.IsEquivalentTo (implemented in System.RuntimeTypeHandle.IsEquivalentTo(RuntimeTypeHandle, RuntimeTypeHandle) ) always returns "false".
3. Moreover nothing in native really knows about Embed Interop Types / Type Equivalence. In particular casting and mono_class_is_assignable_from really makes no provisions for it. The good news is I think this is an entirely synthetic relation in that you don't have to do anything crazy like share a MonoClass* for the two types that are being identified. It's just allowing for more types to be considered inter-assignable/castable. I'm not yet clear on how method lookup will work out.
We don't support NoPIA and have no plans to do so.