https://bugzilla.novell.com/show_bug.cgi?id=643151
https://bugzilla.novell.com/show_bug.cgi?id=643151#c0 Summary: Assembly.ReflectionOnlyLoadFrom() can't load mscorlib.dll from a different runtime. Classification: Mono Product: Mono: Class Libraries Version: SVN Platform: x86-64 OS/Version: openSUSE 11.3 Status: NEW Severity: Enhancement Priority: P5 - None Component: CORLIB AssignedTo: mono-bugs@lists.ximian.com ReportedBy: jpr...@novell.com QAContact: mono-bugs@lists.ximian.com Found By: --- Blocker: --- User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US) AppleWebKit/534.3 (KHTML, like Gecko) Chrome/6.0.472.63 Safari/534.3 Assembly.ReflectionOnlyLoadFrom() is unable to load an mscorlib.dll from a different runtime version. For example, consider the program: using System; using System.Reflection; class Test { public static void Main (string[] args) { foreach (string file in args) { try { var a = Assembly.ReflectionOnlyLoadFrom (file); Console.WriteLine ("File: {0}", file); Console.WriteLine ("\tFullName: {0}", a.FullName); Console.WriteLine ("\tLocation: {0}", a.Location); } catch (Exception e) { Console.WriteLine ("error: Could not load file '{0}': {1}", file, e.Message); } } } } Run it: $ mono load.exe /usr/lib/mono/1.0/mscorlib.dll /usr/lib/mono/2.0/mscorlib.dll File: /usr/lib/mono/1.0/mscorlib.dll FullName: mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 Location: /usr/lib/mono/2.0/mscorlib.dll File: /usr/lib/mono/2.0/mscorlib.dll FullName: mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 Location: /usr/lib/mono/2.0/mscorlib.dll Notice that we always get the 2.0 version (because load.exe was build with gmcs). If we build the app with dmcs, we always get the 4.0 version. Compare with .NET execution: Z:\tmp>load.exe C:\Windows\Microsoft.NET\Framework\v4.0.30319\mscorlib.dll File: C:\Windows\Microsoft.NET\Framework\v4.0.30319\mscorlib.dll FullName: mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77 a5c561934e089 Location: C:\Windows\Microsoft.NET\Framework\v4.0.30319\mscorlib.dll Z:\tmp>load.exe C:\Windows\Microsoft.NET\Framework\v2.0.50727\mscorlib.dll File: C:\Windows\Microsoft.NET\Framework\v2.0.50727\mscorlib.dll FullName: mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77 a5c561934e089 Location: C:\Windows\Microsoft.NET\Framework\v2.0.50727\mscorlib.dll Notice that, when load.exe is built with a v4.0 compiler, we're able to load a 2.0 mscorlib.dll as well as a 4.0 assembly. Alas, not all is roses in .NET land; if you build load.exe with a 2.0 compiler and load a 4.0 mscorlib.dll: Z:\tmp>load.exe C:\Windows\Microsoft.NET\Framework\v4.0.30319\mscorlib.dll error: Could not load file 'C:\Windows\Microsoft.NET\Framework\v4.0.30319\mscorl ib.dll': Could not load file or assembly 'file:///C:\Windows\Microsoft.NET\Frame work\v4.0.30319\mscorlib.dll' or one of its dependencies. This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded. So, ideally Assembly.ReflectionOnlyLoadFrom() could load *any* mscorlib.dll into *any* runtime (instead of always just returning the mscorlib.dll that's already loaded into the process). Failing that, it would be nice if we could get .NET 4.0 behavior and be able to load previous runtime versions. (Now, why care? Mostly so that compiler writers can target different runtime versions from what the compiler is executing on without needing to rewrite large fractions of their compiler to use Mono.Cecil...) Reproducible: Always Steps to Reproduce: 1. 2. 3. -- Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are the QA contact for the bug. You are the assignee for the bug. _______________________________________________ mono-bugs maillist - mono-bugs@lists.ximian.com http://lists.ximian.com/mailman/listinfo/mono-bugs