Back to list
Views:   11K
Replies:  3

Accessing an entity through a dll chain


Here is my scenario: I have three .dll class libraries, LibraryA, LibraryB, & Library C.
Library A references B and  B references to C, like so: LibraryA -> LibraryB-->LibraryC   .
In these libraries I have my classes, enums, structs, etc.
Sometimes I need an enum from library A and use it in library C. 
This creates a circular dependency, so  I cannot access this enum from library C.
How would I solve this problem?

Should I create a new common library, say LibraryD, which includes all of the shared items of Library A-B-C?

Thanks and best regards,
Volkan Genç, Jan 01, 2012
Reply 1

Yes. Create a new class library project and keep all your common functions inside this library and referenced it wherever required.

Sivakumar Sivaprakasam, Jan 04, 2012
Reply 2
Could you please explain your problem little more clear.
From your statement "Sometimes I need an enum from library A and use it in library C. "

I guess you mean libraryA.Enum is required by LibraryC?

If my guess is correct , considering the Chain you have put here, there may be a Cyclic Reference only if Library A tries to use an Enum defined in LIbrary C. In your case it should not be a problem.

Ideally if you want to expose an Enum defined in Library A to Library C you should have a public Property in Library A, which could be used by C.

Library A...

MyEnum _myEnum=MyEnum.DefaultValue;
public MyEnum MyEnumerator
 get{return _myEnum;}

Library A internally - at any instance may update _myEnum private variable so that Library C can only use A's Enum and not update it.

Tarriq Ferrose Khan, Jan 03, 2012
Reply 3

Your guess is right, you should create a new common library which will have common code which can be used in any other library.

Thanks & Regards,
Ankit Parikh
Ankit Parikh, Jan 03, 2012
Hi Ron Thanks for the help. P&P? Sorry, am new to design patterns and am missing the reference. It is a turn-based game. Doug
Apr 03, 2011

Stay Inspired!
Join other developers and designers who have already signed up for our mailing list.
Terms     Privacy     Licensing       EULA       Sitemap      
© Data & Object Factory, LLC.
Made with    in Austin, Texas.      Vsn 1.3.0