Bug 10126 - Module initializer and assembly resolve
Summary: Module initializer and assembly resolve
Status: CONFIRMED
Alias: None
Product: Runtime
Classification: Mono
Component: General (show other bugs)
Version: unspecified
Hardware: PC Windows
: Normal enhancement
Target Milestone: Future Cycle (TBD)
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2013-02-07 11:45 UTC by Erik Källén
Modified: 2017-07-14 23:56 UTC (History)
4 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:


Attachments
Program to demonstrate the behavior (5.38 MB, application/x-msdownload)
2013-02-07 11:45 UTC, Erik Källén
Details


Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and 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 Links.

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 for Bug 10126 on GitHub or Developer Community if you have new information to add and do not yet see a matching new report.

If the latest results still closely match this report, you can use the original description:

  • Export the original title and description: GitHub Markdown or Developer Community HTML
  • Copy the title and description into the new report. Adjust them to be up-to-date if needed.
  • Add your new information.

In special cases on GitHub you might also want the comments: GitHub Markdown with public comments

Related Links:
Status:
CONFIRMED

Description Erik Källén 2013-02-07 11:45:06 UTC
Created attachment 3342 [details]
Program to demonstrate the behavior

The attached program has all its references embedded as resources. It also contains a module initializer that adds an AppDomain.AssemblyResolve event handler to load these assemblies. This operation works in .net, but it fails on Mono 3.0.3
Comment 1 Sergey Alekseev 2014-02-07 06:06:53 UTC
I believe this bug is present for ages.

I tried to test it with 3.2.6:

$ MONO_LOG_LEVEL=info MONO_LOG_MASK=asm mono sc.exe
Mono: Assembly Loader probing location: '/opt/mono-3.2.6/lib/mono/4.5/mscorlib.dll'.
Mono: Image addref mscorlib[0x9f36f28] -> /opt/mono-3.2.6/lib/mono/4.5/mscorlib.dll[0x9f36590]: 2
Mono: Assembly Loader probing location: '/opt/mono-3.2.6/lib/mono/4.5/mscorlib.dll'.
Mono: Assembly Loader loaded assembly from location: '/opt/mono-3.2.6/lib/mono/4.5/mscorlib.dll'.
Mono: Assembly mscorlib[0x9f36f28] added to domain sc.exe, ref_count=1
Mono: Assembly Loader probing location: 'sc.exe'.
Mono: Image addref sc[0xb5500590] -> /home/vagrant/test/sc.exe[0x9f359d0]: 3
Mono: Assembly sc[0xb5500590] added to domain sc.exe, ref_count=1
Mono: Assembly Loader loaded assembly from location: 'sc.exe'.
Mono: Assembly Loader probing location: 'sc.exe'.
Mono: Assembly Ref addref sc[0xb5500590] -> mscorlib[0x9f36f28]: 2
Mono: Assembly Loader probing location: '/home/vagrant/test/Saltarelle.Compiler.dll'.
Mono: Assembly Loader probing location: '/opt/mono-3.2.6/lib/Saltarelle.Compiler.dll'.
Mono: Assembly Loader probing location: '/opt/mono-3.2.6/lib/mono/4.5/Facades/Saltarelle.Compiler.dll'.
Mono: Assembly Loader probing location: '/home/vagrant/test/Saltarelle.Compiler.exe'.
Mono: Assembly Loader probing location: '/opt/mono-3.2.6/lib/Saltarelle.Compiler.exe'.
Mono: Assembly Loader probing location: '/opt/mono-3.2.6/lib/mono/4.5/Facades/Saltarelle.Compiler.exe'.
Mono: The following assembly referenced from /home/vagrant/test/sc.exe could not be loaded:
     Assembly:   Saltarelle.Compiler    (assemblyref_index=1)
     Version:    2.0.0.0
     Public Key: (none)
The assembly was not found in the Global Assembly Cache, a path listed in the MONO_PATH environment variable, or in the location of the executing assembly (/home/vagrant/test/).

Mono: Failed to load assembly sc[0xb5500590]

Mono: Could not load file or assembly 'Saltarelle.Compiler, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies.

Unhandled Exception:
System.IO.FileNotFoundException: Could not load file or assembly 'Saltarelle.Compiler, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies.
File name: 'Saltarelle.Compiler, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null'
[ERROR] FATAL UNHANDLED EXCEPTION: System.IO.FileNotFoundException: Could not load file or assembly 'Saltarelle.Compiler, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies.
File name: 'Saltarelle.Compiler, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null'



I've been trying to use this feature for quite some time. I'm using Costura.Fody to embed assemblies.
And it seems like exception is thrown somewhere after /mono/metadata/assembly.c:1108 (mono_assembly_load_reference)
Comment 2 Rodrigo Kumpera 2017-07-14 23:56:31 UTC
Mono doesn't handle module ctors correctly.