You can't do this because the identity ("name") of a class includes the
identity of the assembly it was loaded from. This is absolutely essential
for component development (and avoiding "dll hell").
Even if you could trick the CLR somehow, you really wouldn't want to do
this. It's a fundamental tennant of good OO-design that all communication
is done through mutually agreed upon interfaces ("contracts"). The
definition of the interface must be unique. If you duplicated the
interface in each of the two assemblies, then there would be nothing to
ensure that the two components were talking the same language. If you
really want this amount of loose coupling (and therefore the possibility of
failure at every interaction), the way to get it is to access the object
only through reflection ("late binding").
Rick
--
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
[quoted text, click to view] >
> DM <darek@m-core.pl> wrote:
> > I'm wondering is it possible to have excatly the same class
> > definied in different assebmlies and still be able to load all of them?
> > Let's say that I have assebly that contains definiton of a class
> > and the other one which also defines excatly the same class.
> > During program executions I load them by System.Reflections.
> > Will the objects created from the first assebmly considered
> > as being of the same type as objects created by the other one?
>
> No. Indeed, I believe you could even load the very same assembly twice
> (in some ways) and end up with two different sets of types.
>
> > I'm asking this because I would like to have 2 separate
> > assemblies which would be loaded by my main app, those two assemblies
> > should be able to exchange objects between themselvs (my apllication
> > is go-between of this process ). I don't want the class of objects
exchanged
> > to be known to main app, I would also prefer not to create the thrid
> > assembly conatining definiton of objects shared by the assemblies.
> >
> > Will it work?
>
> No - you have to create the third assembly, basically.
>
> --
> Jon Skeet - <skeet@pobox.com>
>
http://www.pobox.com/~skeet
> If replying to the group, please do not mail me too
>