Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot add reference on Visual Studio 2017 project

I'm using Visual Studio 2017 and trying to add a new reference between two projects, however I get following error when I click on "Add Reference..."

Cannot find an instance of the Microsoft.VisualStudio.Shell.Interop.IVsReferenceManager service.

The first project is Asp.Net Core, and the second project is a .NET Core Class Library.

like image 936
user428745 Avatar asked May 24 '17 12:05

user428745


People also ask

How do I enable references in Visual Studio?

Press Shift + F12 to find all references.

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.


2 Answers

I had this issue with all my projects after installing another version of Visual Studio.

I fixed it by following 宝宝徐's advice here, namely running the following commands in command prompt:

CD C:\Program Files\Microsoft Visual Studio\2017\Community\Common7\IDE\PublicAssemblies
gacutil -i Microsoft.VisualStudio.Shell.Interop.11.0.dll

I found out that on my machine (Windows 10 x64), apparently gacutil is no longer bundled with new versions of Windows, so retrieved it from a previously installed Microsoft Windows SDK which I found at C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin, although I think you may need to install it first. There are some thoughts here about finding gacutil on Windows 10.

After this, I was able to add references to projects again.

Hope that helps someone.

like image 159
TernaryTopiary Avatar answered Oct 02 '22 16:10

TernaryTopiary


You can go into the csproj of the project you wish to add the reference to and add the following xml

<ItemGroup>
 <ProjectReference Include="..\path\to\your\other.csproj" />
</ItemGroup>

That will add the reference to the other project.

like image 25
TerribleDev Avatar answered Oct 02 '22 17:10

TerribleDev