7

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.

Ignas
  • 4,092
  • 17
  • 28
user428745
  • 803
  • 1
  • 8
  • 12

5 Answers5

14

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.

TernaryTopiary
  • 436
  • 5
  • 17
  • 1
    This worked for me. I just copied the gacutil files over to the visual studio folder specified above(but in my case was for 2019) and then it worked. Thanks! – AxleWack Feb 05 '20 at 10:53
  • 1
    once command executed successfully, please restart visual studio – Somnath Kadam Mar 31 '20 at 11:22
4

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.

TerribleDev
  • 2,195
  • 1
  • 19
  • 31
  • 1
    And it is also possible to walk to work in the event your car doesn't start. This isn't a solution, just a workaround that will quickly get tiresome. – TernaryTopiary Jul 27 '18 at 09:33
  • 1
    You are right, it is a work around. Although it doesn't negate the fact that it does work for this case. Also, its how I've always managed my project references. I think GUI's are more tiresome than appending a line to a file. To each there own.... – TerribleDev Jul 28 '18 at 03:31
1

=>Run the "developer Command Prompt as administrator"

=>Goto the path "CD C:\Program Files (x86)\Microsoft Visual Studio\20XX\Enterprise\Common7\IDE\PublicAssemblies"

N.B : 20XX=2017,2019 etc and Enterprise=Enterprise,Community etc

=>Run gacutil -i Microsoft.VisualStudio.Shell.Interop.11.0.dll

=>Restart your pc

Rokive
  • 745
  • 9
  • 7
1

I had similar error after migrating Visual Studio 2017 project to Visual Studio 2019. In my case I used Visual Studio Installer and under features there was Visual Studio SDK which was unchecked. After installing that, problem gone.

Krzysztof Gapski
  • 528
  • 6
  • 10
0

In my case it was just easier to go to NuGet and Browse for Microsoft.VisualStudio.Shell.Interop.11.0 then add.

Terry H
  • 327
  • 5
  • 11