Share via


ReferenceManagerPackage fails to install, VS 2017 Community edition

Question

Tuesday, April 4, 2017 1:12 PM | 3 votes

Hello - recently installed VS 2017 Community Edition. On starting a project (Console app) when I try to add a reference I get an error message saying the Reference Manager failed to load. It suggests a restart, but that doesn't help.  I also tried running "Repair" on the VS installer, still to no avail.  Here is the full error description from activitylog.xml:

Unexpected system error mode before loading package [ReferenceManagerPackage]

CreateInstance failed for package [ReferenceManagerPackage]Source: 'mscorlib' Description: Could not load type 'Microsoft.VisualStudio.Shell.Interop.IVsReferenceManager2' from assembly 'Microsoft.VisualStudio.Shell.Interop.11.0, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. System.TypeLoadException: Could not load type 'Microsoft.VisualStudio.Shell.Interop.IVsReferenceManager2' from assembly 'Microsoft.VisualStudio.Shell.Interop.11.0, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.    at System.Reflection.RuntimeAssembly.GetType(RuntimeAssembly assembly, String name, Boolean throwOnError, Boolean ignoreCase, ObjectHandleOnStack type)    at System.Reflection.RuntimeAssembly.GetType(String name, Boolean throwOnError, Boolean ignoreCase)    at System.Activator.CreateInstanceFromInternal(String assemblyFile, String typeName, Boolean ignoreCase, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes, Evidence securityInfo)    at System.AppDomain.CreateInstanceFrom(String assemblyFile, String typeName)</description>

80004005 - E_FAIL

Any help gratefully received!

Phil

All replies (21)

Thursday, April 6, 2017 8:02 AM ✅Answered | 28 votes

Hi Phil,

Please try solution as below:

1.Launch Developer Command Prompt for VS 2017

2.CD
C:\Program Files\Microsoft Visual Studio\2017\Community\Common7\IDE\PublicAssemblies

3.Run gacutil -i Microsoft.VisualStudio.Shell.Interop.11.0.dll

You should now see
Microsoft (R) .NET Global Assembly Cache Utility.  Version 4.0.30319.0
Copyright (c) Microsoft Corporation.  All rights reserved.

Assembly successfully added to the cache

Restart Visual Studio and hopefully all will be well and you can add references.

The file C:\Users\USER\AppData\Roaming\Microsoft\VisualStudio\15.0_cc9cc69a\ActivityLog.xml is useful for debugging any other assemblies that may be causing the issue. Annoyingly it's very tempting to click No when asked never to see the error message again, which will suppress the error and this path so I thought I'd post it here for reference.

Best Regards,

MSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.


Wednesday, April 5, 2017 7:46 AM | 1 vote

Hi Phil,

Thank you for posting in MSDN forum.

Please try steps as below:

1.Close all instances of Visual Studio

2.Delete everything in this folder:

C:\Users\username%\AppData\Local\Microsoft\VisualStudio\15.0_***\ComponentModelCache

3.Reboot your computer and restart Visual Studio in Safemode:

Navigate to path:

C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE

and run these commands: devenv.exe /safemode in command prompt.

Best Regards,

MSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.


Wednesday, April 5, 2017 9:37 AM

Thanks for your reply, but that hasn't solved the problem, I'm sorry to say.  I have also tried uninstalling and re-installing VS2017, but to no avail.

Incidentally, after uninstalling, and before re-installing, I opened another project I already had in VS2012. Or tried to... I got a message saying that it was targeting .NET Framework .NET v4.5 which wasn't installed !!!!  It gave me the option of changing the target framework to 4.5 - but what, if any, difference is there between 4.5 and v4.5 ???

Anyway, I re-0installed VS2017 and it solved that problem at any rate - my VS2012 projects open OK now (though the editor seems to have lost it's settings with regards which files were open.)

SO, not terribly impressed about al that. And now I am left with a broken version of VS2017 which I can't install without buggering up my VS2012 projects!

Unless you have at other ideas about how to fix VS2017....?

Thanks again though

 


Thursday, April 6, 2017 2:49 AM

Hi PhilUp,

Thank you for your update.

* >>I have also tried uninstalling and re-installing VS2017, but to no avail.*

From your description, the re-installation still has problem, before installing again, please make sure that the previous corrupted one was uninstalled completely.

 Please have a try with removing the existing VS 2017 that install failed before as below:

1. Go to Control Panel—Programs and Features, if there has ‘Microsoft Visual Studio 2017’, right click it and choose ‘Uninstall’

2. Try to delete the following installed folders:

3. Go to the folder: %ProgramData%\Microsoft\VisualStudio and delete the ‘Packages’ folder and ‘Setup’ folder if there has.

4. Go to the Visual Studio installation folder (normally under %ProgramFiles(x86)%\Microsoft Visual Studio) and delete the folder ‘2017’

After that, make sure windows update is up-to-date, clean up the %temp% folder and temporarily disable any antivirus software, reboot the computer and re-run the VS 2017 RTM installer as administrator again.

Best Regards,

MSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.


Thursday, April 6, 2017 7:57 AM

Hello

sigh... did all that, but still getting the same error. :(

Thanks again for your time though

Phil


Thursday, April 6, 2017 10:49 AM

Hello

I presume you meant "Program Files (x86)" in the path there.... when I run the command I get the message:

'gacutil' is not recognized as an internal or external command, operable program or batch file.

...?

*******  sorry - ignore that, I'm a wombat. Was using a Windows Command window, not the VS developer one.

All working now

thank you so much!

Phil


Wednesday, June 14, 2017 8:31 AM

Hi Lana,

As you have mentioned the Log file is useful for debugging, but I had clicked on "NO" when asked never to see the error message again. Is there any possible way to undo it?

Regards,
SN 


Tuesday, July 11, 2017 2:56 PM | 1 vote

I can't add references to my C# universal windows app. I tried what was posted above and all that came up was "failure adding assembly to cache: the system cannot find the file specified". I went into where the file should be located and it's definitely there.  I went into the activity log and here were the errors I got. 

668 ERROR

CreateInstance failed for package [ReferenceManagerPackage]Source: 'mscorlib' Description: Could not load type 'Microsoft.VisualStudio.Shell.Interop.IVsReferenceManager2' from assembly 'Microsoft.VisualStudio.Shell.Interop.11.0, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. System.TypeLoadException: Could not load type 'Microsoft.VisualStudio.Shell.Interop.IVsReferenceManager2' from assembly 'Microsoft.VisualStudio.Shell.Interop.11.0, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. at System.Reflection.RuntimeAssembly.GetType(RuntimeAssembly assembly, String name, Boolean throwOnError, Boolean ignoreCase, ObjectHandleOnStack type) at System.Reflection.RuntimeAssembly.GetType(String name, Boolean throwOnError, Boolean ignoreCase) at System.Activator.CreateInstanceFromInternal(String assemblyFile, String typeName, Boolean ignoreCase, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes, Evidence securityInfo) at System.AppDomain.CreateInstanceFrom(String assemblyFile, String typeName)

I would greatly appreciate any/all help!!!


Saturday, August 19, 2017 1:11 PM

Thanks Phil, the given solution works for me.


Thursday, January 11, 2018 6:31 PM

Thank you!


Saturday, February 24, 2018 12:15 AM

Hi

I had a similar error. I have a solution created in Windows 7 and Visual Studio Community 2017 (C#) and I opened it in Windows 10 and Visual Studio Community 2017 (C#).

I was using the Office.Excel reference in the Win7 PC. My Win10 PC did not have Office installed, so I installed it.

When I tried to compile the solution in Win10, it failed saying that the Office reference was still missing.

If I clicked on "Add reference..." that error window showed up.

So, after reading these posts I added the Interop DLL with gacutil. The paths varied so you may need to look for the files as I did. Make sure to run "cmd" as an Administrator.

C:\Program Files (x86)\Microsoft Visual Studio>dir /b/s Microsoft.VisualStudio.Shell.Interop*
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\PrivateAssemblies\Interop\Microsoft.VisualStudio.Shell.Interop.8.0.dll
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\PublicAssemblies\Microsoft.VisualStudio.Shell.Interop.10.0.dll
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\PublicAssemblies\Microsoft.VisualStudio.Shell.Interop.11.0.dll
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\PublicAssemblies\Microsoft.VisualStudio.Shell.Interop.12.0.dll
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\PublicAssemblies\Microsoft.VisualStudio.Shell.Interop.8.0.dll
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\PublicAssemblies\Microsoft.VisualStudio.Shell.Interop.9.0.dll
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\PublicAssemblies\Microsoft.VisualStudio.Shell.Interop.dll

C:\Program Files>dir /b/s gacutil.exe
C:\Program Files\Microsoft SDKs\Windows\v6.0A\bin\gacutil.exe

C:\WINDOWS\system32>"C:\Program Files\Microsoft SDKs\Windows\v6.0A\bin\gacutil.exe" /i "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\PublicAssemblies\Microsoft.VisualStudio.Shell.Interop.11.0.dll"
Microsoft (R) .NET Global Assembly Cache Utility.  Version 3.5.30729.1
Copyright (c) Microsoft Corporation. Reservados todos los derechos.

Ensamblado agregado correctamente a la caché

Monday, May 21, 2018 8:42 AM

Thank You this solved my issue. It took me a minute to find your solution but well well worth it.


Friday, May 25, 2018 2:01 PM

Many thanks, this did it for me after an hour or so of reinstalling.


Monday, July 30, 2018 8:46 AM

Thank you, this also works for me.


Friday, October 19, 2018 4:24 PM | 1 vote

I got this bug today 2018-10-19 with windows 10 and visual studio 2017

As many answered here, the solution is this:

1- Search cmd, scroll with arrow to the Developer Command Prompt for VS 2017, press ctrl-shift-enter to open in Admin mode or else it wont work.

2- CD to C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\Common7\IDE\PublicAssemblies

3- Run the following: gacutil -i Microsoft.VisualStudio.Shell.Interop.11.0.dll

You can thank Rob here:

https://developercommunity.visualstudio.com/content/problem/51166/referencemanagerpackage-failed-to-load.html


Wednesday, August 7, 2019 5:42 AM

do you have any thing for 2019 ?

aws toolkit installed but cant open .

c:\dir /b/s gacutil.exe
c:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.8 Tools\gacutil.exe
c:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.8 Tools\x64\gacutil.exe
c:\
c:\
c:\dir /b/s Microsoft.VisualStudio.Shell.Interop*
c:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\PrivateAssemblies\Interop\Microsoft.VisualStudio.Shell.Interop.8.0.dll
c:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\PublicAssemblies\Microsoft.VisualStudio.Shell.Interop.10.0.dll
c:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\PublicAssemblies\Microsoft.VisualStudio.Shell.Interop.11.0.dll
c:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\PublicAssemblies\Microsoft.VisualStudio.Shell.Interop.12.0.dll
c:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\PublicAssemblies\Microsoft.VisualStudio.Shell.Interop.8.0.dll
c:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\PublicAssemblies\Microsoft.VisualStudio.Shell.Interop.9.0.dll
c:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\PublicAssemblies\Microsoft.VisualStudio.Shell.Interop.dll

c:\
c:\
c:\"c:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.8 Tools\gacutil.exe" /i "c:\Program Files (x86)\Microsoft Visual Studio\2019\Community\Common7\IDE\PublicAssemblies\Microsoft.VisualStudio.Shell.Interop.12.0.dll"
Microsoft (R) .NET Global Assembly Cache Utility.  Version 4.0.30319.0
Copyright (c) Microsoft Corporation.  All rights reserved.

Assembly successfully added to the cache

c:\

-- error

SetSite failed for package [AWSToolkitPackage]Source: 'EnvDTE' Description: Error HRESULT E_FAIL has been returned from a call to a COM component. System.Runtime.InteropServices.COMException (0x80004005): Error HRESULT E_FAIL has been returned from a call to a COM component. at EnvDTE.Events.get_DebuggerEvents() at Amazon.AWSToolkit.VisualStudio.AWSToolkitPackage.<>c__DisplayClass67_1.<<InitializeAsync>b__0>d.MoveNext() End of stack trace from previous location where exception was thrown at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.VisualStudio.Threading.JoinableTask.<JoinAsync>d__68.MoveNext() End of stack trace from previous location where exception was thrown at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Amazon.AWSToolkit.VisualStudio.AWSToolkitPackage.<InitializeAsync>d__67.MoveNext() End of stack trace from previous location where exception was thrown at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.VisualStudio.Shell.AsyncPackage.<>c__DisplayClass19_0.<<Microsoft-VisualStudio-Shell-Interop-IAsyncLoadablePackageInitialize-Initialize>b__1>d.MoveNext() End of stack trace from previous location where exception was thrown at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.VisualStudio.Threading.JoinableTask.<JoinAsync>d__68.MoveNext() at Microsoft.VisualStudio.Services.VsTask.GetResult()


Saturday, September 7, 2019 12:02 PM

I followed all steps that you mentioned. but command prompt didn't show "Assembly successfully added to the cache". It shows "failure adding assembly to the cache: The system cannot find the file specified " please reply.


Saturday, September 7, 2019 1:28 PM

I tried it. and it gives me "failure adding assembly to the cache: the system cannot find the file specified. " please reply. I try to find solution 4 days, I still can't find the solution.


Sunday, September 8, 2019 8:48 PM

Thank you so much. I tried to solve this problem like 4 days. after I saw your answers I tried first two solutions several times but it didn't work for me. I uninstall and reinstall visual studio 2019 and 2017 like 3 times. it didn't work too. I followed this solution step by step it really worked. Thank you again.


Saturday, October 19, 2019 12:51 PM

very helpfully

thank you my friend


Tuesday, January 7, 2020 4:47 AM

i encounter the same issue, i tried  to follow the instruction you put, but the problem is, public assemblies folder is missing in my computer. what is the other solution can i try?