Interesting find! The compiler forgets to take the assembly identity into account when doing the type checking. If you look at the IL code for Client.Main it is obvious what is going wrong:
IL_0000: newobj instance void [foo]Foo::.ctor() IL_0005: stloc.0 IL_0006: ldloc.0 IL_0007: ldstr "Craig" IL_000c: stfld string [foo]Foo::firstname IL_0011: ldloc.0 IL_0012: ldstr "Andera" IL_0017: stfld string [foo]Foo::lastname IL_001c: newobj instance void [a]A::.ctor() IL_0021: stloc.1 IL_0022: newobj instance void [b]B::.ctor() IL_0027: stloc.2 IL_0028: ldloc.1 IL_0029: ldloc.0 IL_002a: callvirt instance void [a]A::UseFoo(class [foo_4]Foo) IL_002f: ldloc.2 IL_0030: ldloc.0 IL_0031: callvirt instance void [b]B::UseFoo(class [foo]Foo) IL_0036: ret The [foo]Foo type is different from [foo_4]Foo and yet an instance of one is passed to a method expecting the other. BTW, foo_4 is an alias that ILDASM use to distinguish between the two different assemblies both named foo. Has anyone reported this bug to Microsoft? Regards, Jeroen > -----Original Message----- > From: Moderated discussion of advanced .NET topics. > [mailto:[EMAIL PROTECTED]] On Behalf Of Craig Andera > Sent: Wednesday, September 18, 2002 15:55 > To: [EMAIL PROTECTED] > Subject: Re: [ADVANCED-DOTNET] CAS: what's the diff between > FullTrust and Everything permission sets? > > > If you want to see an example of the horrendous consequences of > unverifiable code, go to > > http://staff.develop.com/candera/clrversion.htm > > This bug still exists in both the C# and VB.NET compilers - and I > consider it a very serious one that many people are going to run into. You can read messages from the Advanced DOTNET archive, unsubscribe from Advanced DOTNET, or subscribe to other DevelopMentor lists at http://discuss.develop.com.