Circular References in Visual Studio

G

Guest

Visual Studio doesn't allow circular references between projects. I have a
situation where I need to allow 2 projects to reference each other.
Is there any way to make Visual Studio allow this?

I realize the best way is to restructure the solution so the circular
reference isn't necessary, which I intend to do. But at the moment, I'm
looking for a quicker work-around if there is one.
Thanks....
Keith F.
 
G

Guest

Nope. Look at the problem a little closer and you'll see why.

Say you have projects A and B.

A needs something from B and B needs something from A.
A is compiled first, so it goes and grabs the contents of B as it is linked.
In this process it checks B for any dependencies and finds A. As a result
it grabs the contents of A and looks for dependencies and finds B... See
where this is headed?

Same reason if you have two classes C and D. And C is a child of D, that is
C inherits D. D cannot also inherit C. This is sort of the same idea.

Inheritance / references are simply ways of reusing code. What I would
suggest is putting these reused controls in a separate 'class library' then
have both A and B reference the new library L.

HTH
 
G

George

Do not reference project.

Reference compiled DLL.

It will be a quick workauround.


George
My Site - Body Jewelry
Visual Studio doesn't allow circular references between projects. I have a
situation where I need to allow 2 projects to reference each other.
Is there any way to make Visual Studio allow this?

I realize the best way is to restructure the solution so the circular
reference isn't necessary, which I intend to do. But at the moment, I'm
looking for a quicker work-around if there is one.
Thanks....
Keith F.
 
C

Cowboy \(Gregory A. Beamer\) [MVP]

George has an interesting solution which will work, but "working" is a
relative term here. You could end up consuming resources if you truly run
circles.

One other possibility, which adds a bit of weight, but can add a safety
measure, is creating a passthrough class with the method signatures
necessary from the other project. Realize that true circular references will
still be dangerous, even with a passthrough class, if you do not add a
safety net if it starts running in circles.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

************************************************
Think Outside the Box!
************************************************
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Staff online

Members online

Forum statistics

Threads
473,769
Messages
2,569,577
Members
45,052
Latest member
LucyCarper

Latest Threads

Top