doers anyone know of a good utility or program to interrogate a solution or a director开发者_运维知识库y for all projects and tell you where circular references are and possible compile in order..
I remember see one a while ago but i can't find it anywhere..
NDepend is an excellent tool that will do this and a lot more. Maybe it's overkill for what you want, but there's a trial version so have a look...
You could chase down the dependency tree via System.Reflection. As you build the tree, when adding a node, you would check to see if any parents of the node are the same project or assembly as the one you're adding. If true, throw an exception out to the user.
Throwing technical exceptions like this one are ok if your users will be people who know how assembly references and exceptions work - people like Developers :)
I know this is a late answer, but I found using GraemeF and tsilb's answers both showed no dependency between the two assemblies. It looks like if you reverse the order of dependencies (Assembly A references B, but you switch it to B referencing A), it leaves the dependency in the build order. To solve this, open the Properties dialog for your solution, go to Common Properties, and then Project Dependencies. Find the Assembly A and remove the dependency on Assembly B. This will allow you to add the reference normally.
If you use project references between the projects in your solution the correct build order will be determined automatically by Visual Studio (or MSBuild). This breaks of course if you use assembly references.. Also Visual Studio will stop you from adding circular project references.
I inherited a gigantic visual studio solution with a few circular reference paths. I wrote a linqpad script to help find the circular reference chain:
https://github.com/ronnieoverby/linqpad-utils/blob/master/Find%20circular%20references.linq
My implementation is probably naive, but it worked reasonably fast for me.
精彩评论