[Mono-list] strange behavior while doing side-by-side execution

Piyush Garyali Piyush Garyali" <piyush_garyali@rediffmail.com
28 Sep 2003 12:43:35 -0000


Hello Jonathan,

I reckon you misunderstood my question. I am aware of the fact 
that mono has not implemented a GAC. My question was more about 
the output of that particular program.

Even after changing the name of the dlls to "first1.dll" and 
"first2.dll" and keeping them in the same folder I fail to 
understand why mono still prints "This is version 1" for the 
second time when it ought to have printed "This is verison 2"

>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 mean, when I am loading the "first2.dll" using LoadFrom and 
creating an instance out of it, logically speaking, it ought to 
have given me the one from first2.dll so that when I invoke the 
Print() method it should have printed "This is verison 2"

I am using MSVS.Net(csc) for compiling the program and mono-0.25 
on Cygwin to run it. Sorry for the typo in the code.

-pG-



On Fri, 26 Sep 2003 Jonathan Pryor wrote :
>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
>

___________________________________________________
Television meets Accounts; Jyoti Weds Rajaram.
Rediff Matchmaker strikes another interesting match !!
Visit http://matchmaker.rediff.com?1