A reference to could not be added.

While coding a solution with 3 project I run into a error. The error occurred while adding a reference. The error messages is:

a reference to xxxx could not be added. Adding this project as a reference cause a circular dependency

Lets have a example to work with

    project prCosutmFunctions
    Project prA
    project prB

prA add references prCosutmFunctions, there is no problem

prB add references prCosutmFunctions, here there it is a error.

The error is because there is a problem with the build order of the soulution. Go to the solution explorer and click right on the solution and choose “Project Build Order”. The project (prCosutmFunctions) that I want to include in both projects (prA, prB) needs to been above these projects.

If this is not the case remove all custom references in all the projects. Now start to set the references to the project you want to use in both projects.

If this is not the case try the next steps
1) remove all references
2) check that all dependency are unchecked
Solution > Project Dependencies
3) Add the reference to the shared project
In the example you need to add the reference to prCosutmFunctions in prA and prB

According to the above steps I found a reference that gave me the error

the article Visual Studio Circular Dependency Nonsense written by Chris Smith talks about a similar problem. It is also worth to take a look at this blog post

4 thoughts on “A reference to could not be added.”

Leave a Reply