Circular dependency in C#

Hi everyone,
I create a blank solution, then create two class projects in it. It's a requirement that i must create a reference from each project to the other. But VS doesn't allow me to do it. It said that it makes the circular dependency problem. I know what it means.
Some people told me that i can create another assembly to solve the problem.
But for some reasons, i still want to keep some classes in its asembly now.
Please help me to solve it.
Thanks in advance
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

There is no way around this, you are going to have to redesign your layer architecture. Maybe you can explain your exact dependencies and we can work through whether or not it is an ideal design.

For example:

A is the first class project, which has classes P, Q, R.
B is the second class project which has classes X, Y, Z.

Class P uses class X and class Q.
Class X uses class Q.

Assuming this was, in the first place, a good class aggregation design, then you would have to move Q into a third assembly which A and B both referenced.

Can you give details of your classes and the reasons you are cross-referencing the two assemblies?

Basically you need a managerial assembly.  A project of which it's sole purpose to gather and distribute resources from the other projects.  If your solution will ever need to be updated, this design will make for an efficient upgrade.

Alot of the constraints set in compiler are by design, stemming from universal coding standards.
This is a serious Code Smell (

You should never get yourself into this situation. And if you find yourself in this situation, there are usually several easy ways out of it depending on what the particular circumstances are.

Let's start at the beginning...
Why is it that you need to have the projects co-dependent?
Cloud Class® Course: Microsoft Exchange Server

The MCTS: Microsoft Exchange Server 2010 certification validates your skills in supporting the maintenance and administration of the Exchange servers in an enterprise environment. Learn everything you need to know with this course.

huongltAuthor Commented:
My work was that I created a blank solution, then I created two class projects: one is Sample.BUL and the other is Sample.Entity representing for my business logic and my entities.
Some classes in the BUL layer needs to use entity classes, then I added a reference from the Sample.BUL to Sample.Entity. VS.NET allowed me to do so.
But then some classes in the Entity layer needs to use business classes, I added a reference again from the Sample.Entity to Sample.BUL, but in this casse VS.NET warned me that this would cause circular dependency problem.
I've tried some other ways to solve it, but nothing happen
For some reasons, i still want to put these classes in its assembly now.
Pls, help me
Thanks a lot
Ok, that's your problem.

If you have a proper tiered design (which is what it sounds like you're trying to do), the entity layer should NEVER need to hit the BUL layer. If it does, then you designed something wrong somewhere.

I strongly suggest you get the book Domain Driven Design (a.k.a. DDD, book url = and properly set up your domain, aggregates, and repositories to act upon the entities in your aggregates.

The whole Windows DNA n-tier design of the 90's is really bad and has been replaced (or extended) with far better models that work with a lot of the software out there (such as Object-relational mappers like NHibernate).

Scott Bellware (a strong blogger on Domain-driven design, NHibernate, Test-driven development - TDD, etc) has a neat series of blog posts where he goes through the process of creating an application using DDD, TDD, and NHibernate.

It starts here:

This is part 4 or 5 where he talks about Repositories, Biz logic, and persistence which may be especially interesting to you:


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
huongltAuthor Commented:
Well, I reviewed my design and made some changes to it. Now it's fine.
Thanks very much for your support
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.