Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Reference could not be added because of same name

Tags:

Since the update to VS 2013 I have the behaviour that I cannot add a reference to 2 projects with the same name. I did the following:

  1. Added 3 solution folders A, B and C.
  2. Added a project of type class library "Core" to both A and B folder.
  3. Added a project of type ConsoleApplication to folder C.

The resulting structure looks like this:

Solution  + A    + Core  + B    + Core  + C    + ConsoleApp 

In the project properties of A the following is entered:

  • Assembly name: A.Core
  • Default namespace: A.Core

and in B:

  • Assembly name: B.Core
  • Default namespace: B.Core

After I added a reference to A.Core in C.ConsoleApp and I try to reference to B.Core to the console I get the error:

A reference to 'Core (B.Core)' could not be added. A reference to the component 'Core' already exists in the project.

The solution was created with VS 2012 and shows this behavior since upgrade. What do I have to setup inside the console?

Edit: I published a screencast on Youtube to explain the problem and placed a bug at Microsoft-Support. I still think, this is a bug.

like image 604
Alexander Schmidt Avatar asked Nov 22 '13 17:11

Alexander Schmidt


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.

How do I change the reference properties in Visual Studio?

Right click on the project file in Solution Explorer and select 'Edit Project File' and manually fix the reference hint paths (the project file is XML). Save, and right-click the project file in Solution Explorer again and select 'Reload Project'.


2 Answers

The issue is that the reference name takes on the project name. It's still referencing the DLL by the appropriate name (A.Core.dll or B.Core.dll), but the reference uses the project name inside VS:

enter image description here

If you look at the project file after adding a reference to A.Core, you'll see this:

<ProjectReference Include="..\ClassLibrary1\Core.csproj">   <Project>{16c42795-f703-4673-98e4-98758c09f9e0}</Project>   <Name>Core</Name> </ProjectReference> 

Change the Name value to A.Core and you'll be unblocked. (B.Core will still show up as "Core" until you edit it as well.)

like image 132
Jimmy Avatar answered Oct 18 '22 15:10

Jimmy


Remove the reference to that dll and then reapply it. it worked for me.

like image 32
Harry Avatar answered Oct 18 '22 13:10

Harry