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
Developer Community or GitHub 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.
* Loading assemblies in reflection only mode does not work in watchOS extensions.
1) domain->search_path is NULL here: https://github.com/mono/mono/blob/d8d1fe64c14111dab63a99c3670115928dc6226b/mono/metadata/appdomain.c#L1899-L1900 (this is where execution differs from a normal iOS project)
2) domain->search_path is NULL because setup->application_base is NULL here: https://github.com/mono/mono/blob/d8d1fe64c14111dab63a99c3670115928dc6226b/mono/metadata/appdomain.c#L1221
3) setup->application_base is NULL because prepare_thread_to_exec_main isn't executed: https://github.com/mono/mono/blob/d8d1fe64c14111dab63a99c3670115928dc6226b/mono/metadata/object.c#L4720
4) and prepare_thread_to_exec_main isn't executed because this is an extension (library) project, without a Main function.
I suppose Xamarin.iOS needs to call some API to setup domain->search_path/setup->application_base properly, so this is a request to get that API implemented (I couldn't find anything existing that looked like it would work).
This causes mscorlib tests using reflection only assembly loading to fail:
[FAIL] FieldInfoTest.GetValueOnRefOnlyAssembly : An unexpected exception type was thrown
[FAIL] FieldInfoTest.NonPublicTests : System.IO.FileNotFoundException : Could not load file or assembly 'mscorlibtests1, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies
[FAIL] FieldInfoTest.SetValueOnRefOnlyAssembly : An unexpected exception type was thrown
[FAIL] MethodInfoTest.InvokeOnRefOnlyAssembly : System.IO.FileNotFoundException : Could not load file or assembly 'mscorlibtests1, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies
Can you work on this one?
I can add an --application-base= command line option which can be set using mono_jit_parse_options (). Would that be enough ?
I believe that would work (I can test any PRs before merging them to make sure it works as intended).
Turns out there is already an embedding function named
mono_domain_set_config () that does this.
Looks like my grep skills need to improve :(