[Mono-dev] Bug in Assembly.Load: overriding assembly location

Robin Neatherway robin.neatherway at gmail.com
Wed Feb 13 10:59:51 UTC 2013


I have found a mismatch in behaviour between mono and .NET

Mono version: Mono JIT compiler version 3.0.4 (master/e5fba9d Wed Jan 30
18:38:48 GMT 2013)
.NET version: 4.5 from VS2012

Running the simple program below which reads mscorlib.dll into memory and
then loads in with Assembly.Load causes Mono to afterwards return the
location of mscorlib as the empty string. On .NET the original location of
mscorlib is returned.


open System.Reflection
open System

let main args =
  let asmBytes =
  printfn "Location of mscorlib: '%s'"
  let assm = Assembly.Load(asmBytes)
  printfn "Location of mscorlib: '%s'"


Location of mscorlib: '/home/scratch/local_mono/lib/mono/4.5/mscorlib.dll'
Location of mscorlib: ''

On Windows I change ReadAllBytes to load
from @"C:\Windows\Microsoft.NET\Framework64\v4.0.30319\mscorlib.dll", and
the output is:

Location of mscorlib:
Location of mscorlib:

This causes problems if you try to do this during xbuild because some tasks
(in my case the Fsc task) try to find the mono location and call into
MonoLocationHelper.cs:47 which is below:

assemblyLocation = Path.GetDirectoryName (typeof

This line then returns the empty string and everything goes wrong from
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ximian.com/pipermail/mono-devel-list/attachments/20130213/2af9eecd/attachment.html>

More information about the Mono-devel-list mailing list