Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / CLR / August 2004

Tip: Looking for answers? Try searching our database.

class definiton if different dll's

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
DM - 25 Aug 2004 09:53 GMT
Hello.

        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?

        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?

Signature

DM

Jon Skeet [C# MVP] - 25 Aug 2004 09:58 GMT
>          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?
[quoted text clipped - 3 lines]
> 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
[quoted text clipped - 4 lines]
>
>          Will it work?

No - you have to create the third assembly, basically.

Signature

Jon Skeet - <skeet@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too

"Rick Byers [MSFT]" - 31 Aug 2004 17:55 GMT
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

Signature

This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------

> >          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?
[quoted text clipped - 17 lines]
>
> No - you have to create the third assembly, basically.

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.