0

We have an internal Nuget server which has started throwing the following error when searching for packages through visual studio:

[NullReferenceException: Object reference not set to an instance of an object.]
NuGet.PackageEqualityComparer.<.cctor>b__1(IPackageName x) +62
System.Collections.Generic.HashSet`1.InternalGetHashCode(T item) +84
System.Collections.Generic.HashSet`1.AddIfNotPresent(T value) +54
NuGet.CollectionExtensions.AddRange(ICollection`1 collection, IEnumerable`1   items) +184
NuGet.Server.Infrastructure.ServerPackageStore.Load() +398
NuGet.Server.Infrastructure.ServerPackageRepository..ctor(String path, IHashProvider 
     hashProvider, ILogger logger) +298
NuGet.Server.DefaultServiceResolver..ctor() +145
NuGet.Server.DataServices.NuGetRoutes.Start() +31

Does this ring any bells with anyone? I have checked the nuget.config and web.config on the machine acting as the Nuget host and nothing has changed that I can see.

Declan McNulty
  • 3,194
  • 6
  • 35
  • 54

1 Answers1

0

I ran into this exception today. The fix ended being the following:

  • Rename the "Packages" folder (I was using the default packagesPath configuration) to something else
  • After this the server started responding (with no packages present of course)
  • Then I renamed the original folder with all the nuget pacakges to "Packages" again
  • The server was able to respond normally with all the packages again

I initially thought some package that was recently pushed to the server was causing this exception since the same setup had been working without any problem for a while.

However, when I copied the entire folder (including all packages) to my local machine and setup a new web page on IIS, it worked fine and I was able to use the web site normally (view packages etc). So, this seemed to indicate some issue with the actual server setup where this web page was being hosted and not anything related to the NuGet packages.

Based on the steps that fixed the error, the error seems to be related to some data being cached somewhere.

I hope this helps someone.

hsirah
  • 337
  • 1
  • 10