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.
TypeLoadException: Parent class failed to load, due to: Could not load list of method overrides assembly:/Users/kirill/MonoRepro/CantLoadType/CantLoadType/bin/Debug/Microsoft.CodeAnalysis.EditorFeatures.dll type:SuggestedAction member:<none>
1. git clone https://github.com/KirillOsenkov/MonoRepro
2. Open ~/MonoRepro/CantLoadType/CantLoadType.sln and run
Expected: works fine on Windows
System.TypeLoadException: Parent class failed to load, due to: Could not load list of method overrides assembly:/Users/kirill/MonoRepro/CantLoadType/CantLoadType/bin/Debug/Microsoft.CodeAnalysis.EditorFeatures.dll type:SuggestedAction member:<none>
at (wrapper managed-to-native) System.RuntimeType.GetPropertiesByName_native(System.RuntimeType,intptr,System.Reflection.BindingFlags,bool)
at System.RuntimeType.GetPropertiesByName (System.String name, System.Reflection.BindingFlags bindingAttr, System.Boolean icase, System.RuntimeType reflectedType) [0x0001b] in <4656b2b94f914437bce672312dd9e44b>:0
at System.RuntimeType.GetPropertyCandidates (System.String name, System.Reflection.BindingFlags bindingAttr, System.Type types, System.Boolean allowPrefixLookup) [0x00010] in <4656b2b94f914437bce672312dd9e44b>:0
at System.RuntimeType.GetProperties (System.Reflection.BindingFlags bindingAttr) [0x00000] in <4656b2b94f914437bce672312dd9e44b>:0
at System.Type.GetProperties () [0x00000] in <4656b2b94f914437bce672312dd9e44b>:0
at CantLoadType.MainClass.Reflect (System.Type type) [0x00002] in <45034b6cbe1045c0841d345de8769b94>:0
at CantLoadType.MainClass.Main (System.String args) [0x00020] in <45034b6cbe1045c0841d345de8769b94>:0
All the assemblies in question are checked in under /CantLoadType/CantLoadType/lib
The "root" assembly is Microsoft.CodeAnalysis.EditorFeatures.dll.
The weirdness starts around the type SuggestedAction:
I can reproduce with Mono 220.127.116.11 (2017-10/efce3b256a5).
To reproduce, run:
> git clone https://github.com/KirillOsenkov/MonoRepro
> cd MonoRepro
> msbuild /t:Build CantLoadType/CantLoadType.sln
> msbuild /t:Run CantLoadType/CantLoadType.sln
This is a good opportunity to rewrite mono_class_get_overrides_full not to swallow the MonoError messages.
This is happening because ImageMoniker is defined by multiple assemblies: Microsoft.CodeAnalysis.EditorFeatures.dll and Microsoft.VisualStudio.Language.Intellisense.dll which are then identified using type equivalence (TypeIdentifierAttribute).
Embedded interop types / type equivalence is not supported by Mono and would require a lot of work to add.
SuggestedAction provides an implementation for ISuggestedAction.IconMoniker but with a return type of "ImageMoniker from EditorFeatures.dll" whereas ISuggestedAction is defined with a return type of "ImageMoniker from Intellisense.dll". This confuses mono when it's trying to work out the method overrides from SuggestedAction.
We have a PR open to improve the assertion message to report more of the details of why loading method overrides failed: https://github.com/mono/mono/pull/6069
That's very bad news. Aleksey, can you suggest any workaround or guidance here please?
ImageMoniker is pretty ubiquitous in Visual Studio API and it's embedded into many assemblies. Is there any way to still use these assemblies in Mono?
The Visual Studio team has agreed on a workaround for this issue - a new type that is not from an interop assembly.