Visual Studio thinks NuGet packages are installed that aren’t

I have an ASP.NET Web Forms web site with a dependency on some Telerik packages. When I right-click on the web site in Visual Studio and “Manage NuGet Packages”, the packages are listed under the “Installed” tab:

Visual Studio thinks NuGet packages are installed that aren't

However:

  1. When viewing Global.asax I get the error “Could not load file or assembly” about Telerik.ReportViewer.Html5.WebForms which seems to be breaking IntelliSense and syntax highlighting
  2. The assemblies don’t exist in the web site’s Bin directory
  3. When I try to uninstall the packages, nothing happens and they’re still listed as installed

Answers:

Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

It is quite a bit strange since you have installed the package Telerik.ReportViewer.Html5.WebForms.

Please try the following steps:

1) disable any third party installed vs extensions under Extensions–>Manage Extensions

2) clean all nuget caches or delete all files under C:Usersxxx(current user).nugetpackages then rebuild your project.

3) close VS Instance, delete .vs hidden folder under the solution folder, bin and obj folder, then rebuild your project.

4) run devenv /safemode under Developer Command Prompt for VS to start a pure VS and then test your project in it.

Besides, when you finishing checking, please add bindredirect on your main web project.

add this:

<runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> 
      <dependentAssembly>
        <assemblyIdentity name="Telerik.ReportViewer.Html5.WebForms" publicKeyToken="eb42632606e9261f" />
        <bindingRedirect oldVersion="0.0.0.0-14.1.20.618" newVersion="14.1.20.618" />
      </dependentAssembly>    
    </assemblyBinding>
  </runtime>

Like this link.

5) Or you could try to create a new asp net web site project and then install that nuget package to test whether the issue happens again.

If it still exists, please repair VS or update it to the latest version.

===========================================

Update 1

clean nuget caches first, delete Bin folder, or just use nuget xxxxxx.sln to restore the packages, then rerun update-package -reinstall to test again. After that, rebuild your website project.

Please check on your web.config file and make sure that you have such node:

<compilation debug="true" targetFramework="4.7.2">
      <assemblies>
        <add assembly="Telerik.ReportViewer.Html5.WebForms, Version=14.2.20.916, Culture=neutral, PublicKeyToken=A9D7983DFCC261BE" />
      </assemblies>
</compilation>

Make sure that you have referenced such dll in web.config.

Visual Studio thinks NuGet packages are installed that aren't

Then, delete .vs hidden folder and Bin folder then rebuild your project to check whether the dll exists under Bin folder.

Update 2

=====================================================

Finally find the reason.

It turned out that the problem was caused by another package failing to install. It was one that I’d gotten away with not having installed before so I just ignored it but it looks like if NuGet fails to install a package, it won’t even try to install any subsequent packages.

Method 2

I stumbled upon this thread, just wanted to add that simply running update-package -reinstall fixed the issue for me. I was having issues, maybe because I have many projects referencing the same Nuget packages.

  1. Tools
  2. Nuget Package Manager
  3. Package Manager Console
  4. Paste:

update-package -reinstall

  1. Press Enter


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x