Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 230
skimania Avatar asked Feb 29 '12 15:02

skimania


People also ask

How do I resolve a reference problem in Visual Studio?

To fix a broken project reference by correcting the reference path. In Solution Explorer, right-click your project node, and then select Properties. The Project Designer appears. If you're using Visual Basic, select the References page, and then click the Reference Paths button.

Where are Visual Studio references stored?

SOLUTION. When you add your first test to a new test project in Visual Studio, references to the required assemblies are automatically referenced. By default, Visual Studio references assemblies stored in the GAC (Global Assembly Cache) with their specific version number.

What is add reference in Visual Studio?

A reference is essentially an entry in a project file that contains the information that Visual Studio needs to locate the component or the service.


1 Answers

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.

like image 151
Matt Brunell Avatar answered Sep 20 '22 09:09

Matt Brunell