473,786 Members | 2,765 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Circular reference

Hi

I Have a solution with about 50 projects and each project have References to
1 to n of the projects in the solution. I try go to a project and try to add
a reference to another project and I get a Circular Reference" error and
cannot reference the project.

Is there any way to find out the what Method or Project is causing the problem
If I am on Project A tring to add Project B - I checked that A doesn't
include B and B doesn't include A - it must be some other project that is
referenced and calling someone else.

Just looking for a suggestion to track down the culprit :-)
Thanks

Mar 28 '07 #1
3 3745
It is actually pretty easy to list the entire reference tree for an
assembly, either through reflection (if compiled) or through parsing
the csproj files (if not). I have samples of both, but they are tied
into other code that I don't want to have to remove - but you may find
this useful for pulling it apart. Note that you need to be a little
careful : the 2 core MS libs at the bottom are themselves circular, so
you need to check against that when enumerating.

Get an Assembly either from a known Type or from the startup Assembly.
From an Assembly you can use GetReferencedAs semblies() to get the
references, which you can then attempt to load via the static
Assembly.Load method (which IIRC returns the existing Assembly if it
is already loaded) - but note that this can throw an exception if the
necessary reference isn't found.

I would probably just use the above to output the tree of your problem
assembly (where you can't add the reference), which should quickly
reveal why... no more that 20 minutes coding I'd guess.

Marc
Mar 28 '07 #2
Hi,
According to your description, I understand you want know how to track down
the "Circular Reference" error.

For example: we have three Projects: ProjectA, ProjectB, ProjectC.
ProjectA has a reference to ProjectB, (ProjectA->ProjectB)
ProjectB has a reference to ProjectC. (ProjectB->ProjectC)
When we are on ProjectC trying to add referece to ProjectB, we will receive
an error massage "Circular Reference". (Because ProjectB has a reference to
ProjectC)
Additionally, if we are going to add referece to ProjectA, we will also
receive the same error meassage "Circular Reference".
(ProjectA->ProjectB->ProjectC).

Apparently, I think the second scenario is similar to your solution.
To trouble down such issue, as Marc said, add some code to draw a
dependence tree of your project.
Another choice, you may use the feature "Project References" in Visual
Studio 2005 IDE.
Right Click your Project, Select "Project dependences..." option in context
menu.
If there is a Circular Reference between two projects, there must have the
same project entry in Project dependences dialog.
In this scenario, it is ProjectB.

By the way, I think "Reflector" is also a good option. Thanks for Marc's
suggestion.:)

Hope this helps. If you have anything unclear, please feel free to update
here and I'm glad to assist you.

Have a great day,
Sincerely,
Wen Yuan
Microsoft Online Community Support
=============== =============== =
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
=============== =============== =
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Mar 28 '07 #3
The best tool to find circular references not only bewteen assemblies but
also between namespaces or types or methods is NDepend
http://www.NDepend.com

Have a glance at this 4mn demo:
http://s3.amazonaws.com/NDependOnlin...ewlet_swf.html

Patrick
"Marc Gravell" <ma**********@g mail.coma écrit dans le message de news:
uY************* *@TK2MSFTNGP04. phx.gbl...
It is actually pretty easy to list the entire reference tree for an
assembly, either through reflection (if compiled) or through parsing the
csproj files (if not). I have samples of both, but they are tied into
other code that I don't want to have to remove - but you may find this
useful for pulling it apart. Note that you need to be a little careful :
the 2 core MS libs at the bottom are themselves circular, so you need to
check against that when enumerating.

Get an Assembly either from a known Type or from the startup Assembly.
From an Assembly you can use GetReferencedAs semblies() to get the
references, which you can then attempt to load via the static
Assembly.Load method (which IIRC returns the existing Assembly if it is
already loaded) - but note that this can throw an exception if the
necessary reference isn't found.

I would probably just use the above to output the tree of your problem
assembly (where you can't add the reference), which should quickly reveal
why... no more that 20 minutes coding I'd guess.

Marc

May 6 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
410
by: Vera | last post by:
I have two assemblies that each consist of several classes. Each object instantiated from those classes can have one or more child- and/or parentobjects that are also instantiated from those classes. Most relationships exist within one assembly, but relationships between assemblies may sometimes occur. For each relationship, I have to make sure that an object from Class1 knows that it can have an object from Class2 as one of its children....
2
7984
by: Earth Worm Jim | last post by:
I have been able to get simple circular references to be serialized in xml by using the ImportTypeMapping method on the SoapReflectionImporter class. But I am unable to serialise circular references when the circular reference is contained with in a collection class, specifically I am using a custom ArrayList object. I keep getting a StackOverFlow Exception from the XmlSerializer class when attempting the serialisation. The classes...
11
9056
by: Steve Jorgensen | last post by:
I just came up with a really tidy little solution to the VB/VBA circular reference issue. It only works with Access 2000 or newer, but that's about the only down-side. The issue... You need an object model that includes a container object, and the object in the container need to interact with the container itself. The problem is that, to access the container, each item needs a reference to the container, and that constitutes a...
6
2831
by: T Koster | last post by:
After a few years of programming C, I had come to believe that I finally knew how to correctly organise my structure definitions in header files for mutually dependent structures, but I find myself stumped again with this little love triangle. Here is some background: m_commands.h defines - struct command_callbacks, which contains - a struct conn * reference - struct command, which contains - a struct command_callback reference
12
7064
by: Frank Rizzo | last post by:
I have a circular reference between 2 classes in the same project (i.e. each class refers to the other). The app runs fine and I am seeing no issues, which kind of surprised me. Are there any issues that I am not seeing (performance wise or garbage collection wise) with circular references? Thanks.
6
5081
by: Stephen Robertson | last post by:
We are currently in a dead end with a circular reference issue using vb.net, and are hoping someone might help us resolve it. Idea... We have frmmain calling frmperson (dim f as new frmperson) in search (no record) mode. When the search is executed, frmperson calls frmsearchresult (dim f as new frmsearchresult) which is a listing of persons. From frmsearchresults, frmperson is called (dim f as new frmperson) with the resulting...
3
3652
by: Solution Seeker | last post by:
Hi All, I am here with a Query and need a Solution for it. The Query is as Follows, We have 3 Projects in a Solution - Say UI, CMN and PRD First One Deals with UI Forms Second One Deals with Common Functions that are needed for the Solution
8
4154
by: nyhetsgrupper | last post by:
I have written a windows service and want to expose a web based user interface for this service. I then wrote a class library containing a ..net remoting server. The class library have a method named StartRemotingServer(). To be able to call this method from the windows service I need to reference the remoting class library, but for the class library to be able to access the internal structures of the windows service the class library...
3
2927
by: =?Utf-8?B?UGF1bCBIYWxl?= | last post by:
Moving all User Controls to a single directory has solved my problem - Thanks Eliyahu. That said, I still got one Circular ref error yesterday, rebuilt again and the build was fine? Far far better than the amount of errors I was originally getting on builds before I consilidated by UC's though :-) "Paul Hale" wrote:
0
9496
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10164
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10110
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9961
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7512
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6745
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5397
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5534
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2894
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.