Click here to Skip to main content
15,860,859 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
I have a project called "ME"
and then i added 5 more projects in it.
In that i have 2 projects "X" and "Y" respectively

In a class in "Y" project I added a new class and i that i wanted to add a reference to "X" project.But when i tried it i got an error stating.."A reference to "X" project could not be added.Adding this project as a reference would cause a circular dependency"

What do i do now.. i really need to access my file from another project and i also cant copy and paste the .cs file i need!

Somebody please help me!

thank you.
Posted
Comments
jdarknight 14-May-12 5:17am    
A Project design should not be having circular reference. So revisit your design.

1 solution

I am not sure about the design you are following but if you ask me I would do this.

First analyze the things that will be required by multiple projects or websites and put them in a class library project. All my projects will then use the class library project.

I am assuming you might have done the same thing but if you are getting tempted to make your code in class library refer to the project just for the sake of using some class from the project then - This is the first sign of a bad design, i suggest you to rethink your strategy and move the classes around to make it better.

Project dependency should always go in linear fashion and never in circular fashion. Since you are adding direct references VS is telling you the same thing.
 
Share this answer
 
Comments
Sipherz 14-May-12 5:26am    
So i am planing to restart my full project!
Is this the perfect solution??
AhsanS 14-May-12 5:31am    
Instead of restarting. Re-access the design of the project. And the things that are required by multiple projects should be moved to a common resource (library).
Sipherz 14-May-12 5:34am    
I could not understand!
Rahul Rajat Singh 14-May-12 5:33am    
AhsanS has replied already. just think about the classes you have that are forcing you to have the dependency between projects and move then to have proper dependencies.
Sipherz 14-May-12 5:35am    
Cool... Thank you guys!!!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900