IT Nota

  • Home
  • How To
  • .NET
  • WordPress
  • Contact
You are here: Home / How To / How to Resolve ReferenceManagerPackage Error in Visual Studio 2019

How to Resolve ReferenceManagerPackage Error in Visual Studio 2019

If you encounter this error (see below) when you try to Add Reference in Visual Studio:

Visual Studio ReferenceManagerPackage Error

The 'ReferenceManagerPackage' package did not load correctly.
The problem may have been caused by a configuration change or by the installation of another extension. You can get more information by examining the file 'C:\Users\[UserID]\AppData\Roaming\Microsoft\VisualStudio\16.0_#####\ActivityLog.xml'
Restarting Visual Studio could help resolve this issue.
Continue to show this error message?

You can take a look at the ActivityLog.xml file, but most of the time it’s not necessary. Just for the sake of this example, let’s open it up:

  <entry>
    <record>2479</record>
    <time>2021/03/12 01:21:02.715</time>
    <type>Error</type>
    <source>VisualStudio</source>
    <description>CreateInstance failed for package [ReferenceManagerPackage]Source: &apos;mscorlib&apos; Description: Could not load type &apos;Microsoft.VisualStudio.Shell.Interop.IVsReferenceManager2&apos; from assembly &apos;Microsoft.VisualStudio.Shell.Interop.11.0, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a&apos;.&#x000D;&#x000A;System.TypeLoadException: Could not load type &apos;Microsoft.VisualStudio.Shell.Interop.IVsReferenceManager2&apos; from assembly &apos;Microsoft.VisualStudio.Shell.Interop.11.0, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a&apos;.&#x000D;&#x000A;   at System.Reflection.RuntimeAssembly.GetType(RuntimeAssembly assembly, String name, Boolean throwOnError, Boolean ignoreCase, ObjectHandleOnStack type)&#x000D;&#x000A;   at System.Reflection.RuntimeAssembly.GetType(String name, Boolean throwOnError, Boolean ignoreCase)&#x000D;&#x000A;   at System.Activator.CreateInstanceFromInternal(String assemblyFile, String typeName, Boolean ignoreCase, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes, Evidence securityInfo)&#x000D;&#x000A;   at System.AppDomain.CreateInstanceFrom(String assemblyFile, String typeName)</description>
    <guid>{48D4A2C2-01AD-4F13-9123-610711CACB5B}</guid>
    <hr>80004005 - E_FAIL</hr>
    <errorinfo></errorinfo>
  </entry>
</activity>

Or you can view it with IE or XML viewer:

VisualStudio ActivityLog.xml viewed with Internet Explorer

For this particular case, Visual Studio cannot load Microsoft.VisualStudio.Shell.Interop.11.0.

There are several things you can try to solve this.

1. Delete ComponentModelCache Folder

  1. Exit all instances of Visual Studio.
  2. Open File Explorer and go to %LocalAppData%\Microsoft\VisualStudio\16.0_##### folder and delete ComponentModelCache sub-folder.

    Visual Studio LocalAppData ComponentModelCache folder

  3. Restart Visual Studio with Admin privileges.
  4. Try to open your project and Add References.

If it works at this point, congratulations, but in my case, I got a slightly different error:

Error HRESULT E_FAIL has been returned from a call to a COM component.

Visual Studio Add References HRESULT E_FAIL error

2. Repair Visual Studio

This was suggested by many and it was the easiest to do, so it’s worth to try. Just launch your Visual Studio Intaller and select Repair from the More drop-down for the Visual Studio instance you want to fix.

Visual Studio Installer Repair

I did not have any luck with this either. So I had to do the second step by reinstalling Microsoft.VisualStudio.Shell.Interop.11.0.dll using Global Assembly Cache Tool.

3. Reinstall DLL with Gacutil.exe (Global Assembly Cache Tool)

  1. Open Developer Command Prompt for VS 2019 as administrator.

    Launch Developer Command Prompt for VS 2019 as administrator

    Make sure you see the word Administrator on the top of the command prompt window.

    Administrator Developer Command Prompt for VS 2019 window

  2. Go to the latest .NET Framework version folder you’re using (in this case it’s .NET Framework 4.8) to access the gacutil.exe file.

    C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.8 Tools\x64>
    
  3. Check where your DLL is located (your active Visual Studio instance). In this case, it is C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\PublicAssemblies folder.

  4. Type in the following:

    C:\Program Files (x86)\Microsoft SDKs\Windows\v10.0A\bin\NETFX 4.8 Tools\x64>gacutil.exe /i "C:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\Common7\IDE\PublicAssemblies\
    Microsoft.VisualStudio.Shell.Interop.11.0.dll"
    
  5. If it’s successful, you should see a message confirming that the assembly successfully added to the cache.

    GacUtil adds DLL successfully

Check if any of the fix (or the combination of them), launch Visual Studio again, open your project and try to Add References again.

If successful, you should see Reference Manager window opened up.

Visual Studio Reference Manager window

References

“ReferenceManagerPackage” package did not load correctly VS 2019 community
How can I fix the Microsoft Visual Studio error: “package did not load correctly”?
Error HRESULT E_FAIL has been returned from a call to a COM component on Add Reference
Add a reference raise error: Error HRESULT E_FAIL has been returned from a call to a COM component
Gacutil.exe (Global Assembly Cache tool)

March 11, 2021 Filed Under: How To Tagged With: Microsoft, Visual Studio

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Buy me a coffee Support this site
Buy Me a Coffee?

Categories

  • .NET
  • Coding
  • Cybersecurity
  • Database
  • How To
  • Internet
  • Multimedia
  • Photography
  • Programming
  • Resources
  • Review
  • Tips and Tricks
  • Use Case
  • WordPress
  • Writing

Recent Posts

  • How to Check Installed .NET Framework Version
  • How to Remove .NET Runtime and SDK on Mac
  • How to Solve Intermittent 403 Error in IIS
  • How to Show Hidden Folders and Files in Mac Finder
  • How to Solve MS Office VBA Compile Error UserAuthentication

Recent Posts

  • How to Check Installed .NET Framework Version
  • How to Remove .NET Runtime and SDK on Mac
  • How to Solve Intermittent 403 Error in IIS
  • How to Show Hidden Folders and Files in Mac Finder
  • How to Solve MS Office VBA Compile Error UserAuthentication
  • RSS

Tags

.NET Access AdSense ASP.NET Cdonts Dll Classic ASP Code Editor ETL FSharp Genesis Framework Git Google HP Asset Manager HTML HTML5 Hugo IIS Information Security Internet Internet Information Services iOS JAMStack Linux macOS Microsoft Microsoft SQL Server MVC PHP Python Simple Mail Transfer Protocol Smtp Server Social Media SQL SQL Server SSIS SSMS SSRS Sublime Text Visual Studio Visual Studio Code VPN Windows Windows 8 Windows 10 Windows Server

Copyright © 2011-2022 IT Nota. All rights reserved. Terms of Use | Privacy Policy | Disclosure