Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VS: solution user options fail to deserialize after NuGet update #8166

Closed
dtivel opened this issue May 28, 2019 · 1 comment · Fixed by NuGet/NuGet.Client#2863
Closed

VS: solution user options fail to deserialize after NuGet update #8166

dtivel opened this issue May 28, 2019 · 1 comment · Fixed by NuGet/NuGet.Client#2863
Assignees
Milestone

Comments

@dtivel
Copy link
Contributor

dtivel commented May 28, 2019

Repro steps:

  1. Install Visual Studio 2019. (This should also work with older versions (2017, 2015, …).)
  2. Launch Visual Studio.
  3. Create a C# class library project (.NET Framework).
  4. In the Solution Explorer tool window, right-click on the project and select "Manage NuGet Packages..."
  5. Exit Visual Studio.
  6. Install a newer NuGet VSIX.
    (Optional) Open a developer command prompt and run: devenv /clearCache
  7. Launch Visual Studio.
  8. Open the project created in step 3.
  9. In the Solution Explorer tool window, right-click on the project and select "Manage NuGet Packages..."

Result:
A System.Runtime.Serialization.SerializationException exception is thrown here.

System.Runtime.Serialization.SerializationException: Unable to find assembly 'NuGet.Tools, Version=5.2.0.1108, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.
   at System.Runtime.Serialization.Formatters.Binary.BinaryAssemblyInfo.GetAssembly()
   at System.Runtime.Serialization.Formatters.Binary.ObjectReader.GetType(BinaryAssemblyInfo assemblyInfo, String name)
   at System.Runtime.Serialization.Formatters.Binary.ObjectMap..ctor(String objectName, String[] memberNames, BinaryTypeEnum[] binaryTypeEnumA, Object[] typeInformationA, Int32[] memberAssemIds, ObjectReader objectReader, Int32 objectId, BinaryAssemblyInfo assemblyInfo, SizedArray assemIdToAssemblyTable)
   at System.Runtime.Serialization.Formatters.Binary.__BinaryParser.ReadObjectWithMapTyped(BinaryObjectWithMapTyped record)
   at System.Runtime.Serialization.Formatters.Binary.__BinaryParser.ReadObjectWithMapTyped(BinaryHeaderEnum binaryHeaderEnum)
   at System.Runtime.Serialization.Formatters.Binary.__BinaryParser.Run()
   at System.Runtime.Serialization.Formatters.Binary.ObjectReader.Deserialize(HeaderHandler handler, __BinaryParser serParser, Boolean fCheck, Boolean isCrossAppDomain, IMethodCallMessage methodCallMessage)
   at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize(Stream serializationStream, HeaderHandler handler, Boolean fCheck, Boolean isCrossAppDomain, IMethodCallMessage methodCallMessage)
   at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize(Stream serializationStream)
   at NuGetVSExtension.SolutionUserOptions.ReadUserOptions(IStream pOptionsStream, String _)

NuGet serializes its solution user options using binary serialization and this creates a dependency on the exact assembly (per strong name) used to serialize those settings.

@dtivel
Copy link
Contributor Author

dtivel commented May 28, 2019

For example, here is a snapshot of the types required to successfully deserialize NuGet solution user options on a particular NuGet build.

  • NuGetVSExtension.NuGetSettings, NuGet.Tools, Version=5.2.0.524, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
  • System.Collections.Generic.Dictionary``2[[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[NuGet.PackageManagement.UI.UserSettings, * NuGet.PackageManagement.UI, Version=5.2.0.524, Culture=neutral, PublicKeyToken=31bf3856ad364e35]], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
  • System.OrdinalComparer, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
  • System.Collections.Generic.KeyValuePair``2[[System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089],[NuGet.PackageManagement.UI.UserSettings, NuGet.PackageManagement.UI, Version=5.2.0.524, Culture=neutral, PublicKeyToken=31bf3856ad364e35]], mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
  • NuGet.PackageManagement.UI.UserSettings, NuGet.PackageManagement.UI, Version=5.2.0.524, Culture=neutral, PublicKeyToken=31bf3856ad364e35
  • NuGet.PackageManagement.UI.ItemFilter, NuGet.PackageManagement.UI, Version=5.2.0.524, Culture=neutral, PublicKeyToken=31bf3856ad364e35
  • NuGet.Resolver.DependencyBehavior, NuGet.Resolver, Version=5.2.0.2, Culture=neutral, PublicKeyToken=31bf3856ad364e35
  • NuGet.ProjectManagement.FileConflictAction, NuGet.PackageManagement, Version=5.2.0.2, Culture=neutral, PublicKeyToken=31bf3856ad364e35
  • System.ComponentModel.ListSortDirection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089

If these exact NuGet assemblies aren't available, deserialization will fail.

@dtivel dtivel self-assigned this May 28, 2019
dtivel added a commit to NuGet/NuGet.Client that referenced this issue Jun 3, 2019
@dtivel dtivel added this to the 5.2 milestone Jun 7, 2019
matherm-aboehm pushed a commit to matherm-aboehm/NuGet.Client that referenced this issue Aug 31, 2023
Fix internal bug 677891.  Also, fix NuGet/Home#8166.

(cherry picked from commit 925c4bc)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant