views:

150

answers:

1

Hello

Is there a way in Visual Studio 2005 to find all the references of a project?

I have a solution with multiple projects (dll's). When referencing in the project B the project A VS tells me that it can't add this reference, because of a "circular referencing".

However, the project A does not contain a direct reference to B. Apparently, there a intermediate references in A that references B.

A <=?= B (circular ref.)

A =?=> X(?) =?=> B ( maybe there is an X that references B)

How to find this X?

=== EDIT(For the curious) :) There is 63 projects in the solution.

+3  A: 

I highly recommend you look into using NDepend, which is a great way to find hidden dependencies. That tool will help you find all of the pain points in your code. Refactoring it is, ultimately, up to you.

The standard way of dealing with a circular dependency, where A references B and B references A, is to pull the items that are referenced by both A and B and put them into a separate assembly, C, such that A references C and B references C, but C does not reference either A or B.

Based on a read of your problem, my guess is that you have a lot of static methods or properties that you use all over the place. Get rid of them, or move them all to a single project that everything references. I prefer the former; static anything tends to be difficult to unit test.

mmm. interesting, interesting... what about "free" "workarounds"? :)

You have to refactor, there's no "workaround" for that. NDepend is just a tool that can help you find the painful areas; it's not going to do the work for you. Thankfully, it has a free trial that you can use to help you with your immediate problem.

If you don't want to use it, your only "workaround" would be to find the circular reference by searching through your code. One thing that might help you find the problem area would be to remove the reference to Project A from Project B and see what breaks, then compare it to what breaks when you remove the reference to Project B from Project A. The union of those lists should give you a starting point.

But you're going to have to refactor your code; there is no getting away from that.

Randolpho
+1: NDepend is a great starting point for a situation like this.
Greg D
mmm. interesting, interesting... what about "free" "workarounds"? :)
serhio
Free $$ do it all by hand. It's Time or $$, you choose.
Simeon Pilgrim
What about to analyze the generated by Visual Studio "Solution Generation" log?!.
serhio