[Mono-list] strange behavior while doing side-by-side execution
Jonathan Pryor
jonpryor@vt.edu
Thu, 25 Sep 2003 20:20:49 -0400
How are you compiling & running your program?
Mono doesn't have a Global Assembly Cache. Thus, there is no way to
install two different "versions" of the same assembly. At least, not
for "version" defined as "having
System.Reflection.AssemblyFileVersionAttribute specified in the
assembly."
You can always rename the assemblies, having (e.g.) first-1.dll and
first-2.dll, to correspond to the different library versions. That
works under mono, as expected.
Well, it *almost* works. I couldn't get your code to compile as-is,
because [first-1.dll]first.ClassFirst was not declared as "public," and
thus couldn't be used from MainApplication.exe. After changing
first.ClassFirst to be a public class, it could compile.
The one other change required was changing the Assembly.LoadFrom path,
as I'm doing this on Linux and C:\ doesn't exist, and I was loading
"first-2.dll", explicitly specifying the version to load.
- Jon
On Thu, 2003-09-25 at 09:09, Piyush Garyali wrote:
> Hello everybody,
>
> I found a strange behavior with mono when I ran the following code
> snippet for side-by-side execution.
>
> <first.dll version 1.0.1>
> using System;
> namespace first
> {
> class ClassFirst
> {
> public void Print()
> {
> Console.WriteLine("This is version 1");
> }
> }
> }
>
> <first.dll version 1.0.2>
> using System;
> namespace first
> {
> class ClassFirst
> {
> public void Print()
> {
> Console.WriteLine("This is version 2");
> }
> }
> }
>
> <MainApplication.exe>
> using System;
> using System.Reflection;
> using first;
>
> namespace MainApplication
> {
> class Class1
> {
> static void Main()
> {
> // creating instance from the version 1.0.1
> assembly
> ClassFirst cf = new ClassFirst();
> cf.Print();
>
> // loading the version 1.0.2 dll
> Assembly ass =
> Assembly.LoadFrom("C:\\NewVersion\\first.dll");
> type [] t = ass.GetTypes();
> object o = System.Activator.CreateInstance(t[0]);
> MethodInfo method = t[0].GetMethod("Print");
> method.Invoke(o, null);
>
> }
> }
> }
>
> Output on MS-CLR:
> This is version 1
> This is version 2
>
> Output on mono-0.25
> This is version 1
> This is version 1
>
>
> <..>
>
> I can't figure out any reason as to why this thing is not working
> on mono.
> Is it a bug or am I missing something ??
>
> -pG-
> ___________________________________________________
> Television meets Accounts; Jyoti Weds Rajaram.
> Rediff Matchmaker strikes another interesting match !!
> Visit http://matchmaker.rediff.com?1
>
> _______________________________________________
> Mono-list maillist - Mono-list@lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-list