skimania
skimania

Reputation: 917

Why does Visual Studio 2010 keep adding a "reference to self" in my class library?

Sometimes, VS wont let me do edit and continue, and it turns out it's because my project Eric.Controls has a reference to Eric.Controls. It's a project reference, which I never added. Steps to reproduce are inconsistent, but generally, i think it happens when I use the designer and add a control from a different project which I reference.

This occasionally also causes me to be unable to compile at all until I restart Visual Studio which has the target executable locked.

First of all, why would VS even allow a project to reference itself?

Any ideas?

I'm happy to answer any questions which could lead to an answer.

Upvotes: 7

Views: 2092

Answers (3)

skimania
skimania

Reputation: 917

Found the answer!

If you use solution folders, and you have your project that contains the control in a solution folder, when you drag a control from the toolbox on, it adds the reference to that library.

Solution: don't put control libraries in solution folders.

Upvotes: 4

Matt Brunell
Matt Brunell

Reputation: 10389

Yeah, I've noticed this too. It is is a visual studio bug: http://connect.microsoft.com/VisualStudio/feedback/details/613502/automatically-add-self-reference

It happens when you drag something onto a designer from the toolbox. To work around it just delete the self reference.

Upvotes: 6

Hubi
Hubi

Reputation: 1639

I had the same problem. In my case, the designer was to blame. The designer added sometimes file references to my projects. Especially when DataBinding and Forms is used.

P.S.: The file references displayed by namespace and project references are displayed by project name in the references folder.

Upvotes: 0

Related Questions