Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

Circular dependency problem
Hi all,

I have the following problem: I have 2 namespaces: NamespaceA in
ProjectA, and NamespaceB in ProjectB. NamespaceA contains class ClassA,
which contains a field of type NamespaceB.ClassB. And the other way
around: NamespaceB contains ClassB, containing a field of type
NamespaceA.ClassB. The compiler gives an error saying, that I am missing
the assembly references. So I add ProjectB to the references of
ProjectA, and after that try to add ProjectA to the references of
ProjectB, which Visual Studio does not enable me to do, saying, that
there would be a circular depency. How can I solve this problem?

Regards,

Krzysztof Kozlowski

Report this thread to moderator Post Follow-up to this message
Old Post
Krzysztof Kozłowski
05-14-05 09:04 PM


Re: Circular dependency problem
Could you be more specific as to what these classes are and what they
do?


Report this thread to moderator Post Follow-up to this message
Old Post
Bruce Wood
05-16-05 01:57 PM


Re: Circular dependency problem
> I have the following problem: I have 2 namespaces: NamespaceA in ProjectA,
> and NamespaceB in ProjectB. NamespaceA contains class ClassA, which
> contains a field of type NamespaceB.ClassB. And the other way around:
> NamespaceB contains ClassB, containing a field of type NamespaceA.ClassB.
> The compiler gives an error saying, that I am missing the assembly
> references. So I add ProjectB to the references of ProjectA, and after
> that try to add ProjectA to the references of ProjectB, which Visual
> Studio does not enable me to do, saying, that there would be a circular
> depency. How can I solve this problem?
>
> Regards,
>
> Krzysztof Kozlowski
>

The only way to do this is to use interfaces in at least one of the
projects. I am not sure how this would ever work though.

ClassA
ItemB
ItemA
ItemB1
ItemA1
... for ever

This is a bad thing. It seems like you have a base set of information that 2
classes need. The fact that C# does not create the actual class right away
saves you from that, but somehow you have to tell the ItemB that you do not
want to create an ItemA when you create it in a parent ItemA.

The following would seem a more logical class layout.

ClassA - all the items and information ClassBChild will have to access (or
your ClassB in existing class)
ClassB - all the items and information ClassAChild will have to access (or
your ClassA in existing class)

ClassAChild
ClassB item
ClassBChild
ClassA item



Report this thread to moderator Post Follow-up to this message
Old Post
Lorad
05-18-05 01:58 AM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

C# archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 10:17 AM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.