Click here to Skip to main content
15,888,968 members
Please Sign up or sign in to vote.
3.00/5 (2 votes)
See more:
I have two proper developed projects now i want a project, more precisely a third project with only 1 form containing two button controls for navigation to each of my developed projects.

In such scenerio i use the technique of adding both the two project's (class library) solution files to third project, but when i add references it will gave me error that is "This dependency cannot be added because it will create a circular dependency"....

Anyone can help me or gave me a better idea...?
Thanx : Ghalib Mirza.
Posted
Updated 4-Dec-21 2:31am
Comments
George Jonsson 29-Jun-14 0:05am    
Too little information.
You need to analyze the references you have in each project.
PIEBALDconsult 29-Jun-14 0:23am    
Probably a good time for an Interface.

You can't do that:
You have two projects P1 and P2 which have references to a third project P3.
If you add a reference to P1 in P3 then compilation becomes impossible: as soon as you compile P1 and produce a new binary, you have to recompile P3 because it depends on the binary file and the changes may impact it. This creates a new P3 binary, which means that P1 and P2 need to be recompiled - which creates a new binary, so P3 needs ....

See what VS is saying? You can't create circular dependencies because they prevent compilation working ever again!

If your P3 needs access to P1 and P2 for navigation, then it needs a reference: but P1 and P2 do not. If you have other code within P3 that P1 and P2 need, then extract it to P4 and have all three projects refer to it.

You definitely shouldn't have P1 and P2 knowing about the classes that create and display them - thats very much against the OOPs principles!
 
Share this answer
 
Comments
Ghalib Mirza 29-Jun-14 22:01pm    
@OriginalGriff Sir im doing the same as you said... i only adding reference of P1 to P3 (OK) and P2 to P3 (Error)...
Dave Kreskowiak 4-Dec-21 9:59am    
It would appear you still have a reference in the P2 project to P3. That will prevent you from adding the reference in P3 to P2.
Try open your project .csproj that cause that warning, add below Code to manually add the reference:
Note:
- Make sure the path is correct.
- Change every TheReferenceProject below into the actual project name that you wanna add for reference.

<ItemGroup>
	<Reference Include="TheReferenceProject">
		<HintPath>$(SolutionDir)TheReferenceProject\bin\$(Configuration)\TheReferenceProject.dll</HintPath>
	</Reference>
</ItemGroup>
 
Share this answer
 
v2
Comments
Dave Kreskowiak 4-Dec-21 9:56am    
A very bad idea. You should re-read OrignalGriff's post and, hopefully, figure out why it's a bad idea.

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