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 23187 [details]
If a ResolveEventHandler is installed while we are looking for the arguments of custom attributes, we may call ono_assembly_metadata_foreach_custom_attr on a dynamic assembly, which triggers an assertion:
* Assertion at custom-attrs.c:1947, condition `!image_is_dynamic (image)' not met
1. download and unzip the attached file.
2. run make
Some manner of exception
the assert from above.
The function mono_assembly_metadata_foreach_custom_attr is called by the loader to look for ReflectionAssemblyAttribute attributes. It did not expect to be called with a dynamic assembly (as the ResolveEventHandler in the example does).
The solution is to check if the assembly is dynamic and if so go through its attributes using the normal MonoCustomAttrInfo* APIs. (I think this is okay to do because the dynamic assembly will have all of its MonoClasses existing already so it won't trigger another loader event.)
Hm. Interestingly, .NET Framework (and .NET Core 2.0) seems to ignore ReferenceAssemblyAttribute when it's set on an AssemblyBuilder and happily runs the generated assembly. So we should really do two things:
1. (bugfix) Not even bother checking for the ReferenceAssemblyAttribute when the assembly is dynamic.
2. (feature enhancement) Teach mono_assembly_metadata_foreach_custom_attr to iterate over dynamic assemblies.
Fixed on mono master https://github.com/mono/mono/commit/6559b16c146623f16402c3504c19f94e0c0f4d7c
Fixed on mono 2017-06 https://github.com/mono/mono/commit/04419ee95be98831e0cad46135f38cd705630486