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

[dotnet-sdk-9.0.100-preview.6.24325.8] Bulk-Crap-Uninstaller launch failed with error: Exception type : System.PlatformNotSupportedException Message : BinaryFormatter serialization and deserialization have been removed #11597

Closed
Junjun-zhao opened this issue Jun 27, 2024 · 4 comments
Labels
area-Serialization-BinaryFormatter-FeatureWork Feature work under the general area of BinaryFormatter related serialization

Comments

@Junjun-zhao
Copy link
Member

Junjun-zhao commented Jun 27, 2024

.NET version

Dotnet Info:

.NET SDK:
 Version:           9.0.100-preview.6.24325.8
 Commit:            89054b0c37
 Workload version:  9.0.100-manifests.29b7987d
 MSBuild version:   17.11.0-preview-24318-05+4a45d5633

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.22000
 OS Platform: Windows
 RID:         win-x64
 Base Path:   C:\Program Files\dotnet\sdk\9.0.100-preview.6.24325.8\

.NET workloads installed:
Configured to use loose manifests when installing new manifests.
There are no installed workloads to display.

Host:
  Version:      9.0.0-preview.6.24321.8
  Architecture: x64
  Commit:       static

.NET SDKs installed:
  9.0.100-preview.6.24325.8 [C:\Program Files\dotnet\sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 9.0.0-preview.6.24324.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 9.0.0-preview.6.24321.8 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.WindowsDesktop.App 9.0.0-preview.6.24322.3 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

Other architectures found:
  None

Environment variables:
  Not set

global.json file:
  Not found

Learn more:
  https://aka.ms/dotnet/info

Download .NET:
  https://aka.ms/dotnet/download

Did it work in .NET Framework?

Not tested/verified

Did it work in any of the earlier releases of .NET Core or .NET 5+?

Yes

Verify Scenarios:
1). Windows 10 21H2 AMD64 + dotnet-sdk-9.0.100-preview.6.24314.10: Pass
2). Windows 10 21H2 AMD64 + dotnet-sdk-9.0.100-preview.7.24321.3: Fail
3). Windows 10 21H2 AMD64 + dotnet-sdk-9.0.100-preview.6.24325.8: Fail

Issue description

When run the 3rd party application with the latest .NET 9 build "dotnet-sdk-9.0.100-preview.6.24325.8", it failed to launch with error: System.PlatformNotSupportedException : BinaryFormatter serialization and deserialization have been removed.

Application Name: Bulk-Crap-Uninstaller(WinForms)
OS: Windows 10 21H2
CPU: X64
.NET Build Number: dotnet-sdk-9.0.100-preview.6.24325.8
App or Source Checking at: https://devdiv.visualstudio.com/DevDiv/_workitems/edit/2110654

Steps to reproduce

App Repro steps:
1.Set System.Runtime.Serialization.EnableUnsafeBinaryFormatterSerialization switch to True and set runtime version to .NET 9.0.100-preview.6.24325.8 in BCUninstaller.runtimeconfig.json.

"frameworks": [
      {
        "name": "Microsoft.NETCore.App",
        "version": "9.0.0-preview.6.24321.8"
      },
      {
        "name": "Microsoft.WindowsDesktop.App",
        "version": "9.0.0-preview.6.24322.3"
      }
    ],
"configProperties": {
      "System.Runtime.Serialization.EnableUnsafeBinaryFormatterSerialization": true
    }

2.Launching BCUninstaller.exe
3. Click Close button to quit app

Expected Result:
Close successfully.

Actual Result:
App is crashed.
image
BulkCrapUninstaller_BugReproSteps

Exception type : System.PlatformNotSupportedException

Message : BinaryFormatter serialization and deserialization have been removed. See https://aka.ms/binaryformatter for more information.
at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Serialize(Stream serializationStream, Object graph)
   at BrightIdeasSoftware.ObjectListView.SaveState() in D:\Bulk-Crap-Uninstaller\source\ObjectListView\ObjectListView.cs:line 5872
   at BulkCrapUninstaller.Functions.Tools.SettingTools.SaveSettings() in D:\Bulk-Crap-Uninstaller\source\BulkCrapUninstaller\Functions\Tools\SettingTools.cs:line 108
   at BulkCrapUninstaller.Forms.MainWindow.MainWindow_FormClosed(Object sender, FormClosedEventArgs e) in D:\Bulk-Crap-Uninstaller\source\BulkCrapUninstaller\Forms\Windows\MainWindow.cs:line 783
   at BulkCrapUninstaller.Forms.MainWindow.OnFormClosed(FormClosedEventArgs e) in D:\Bulk-Crap-Uninstaller\source\BulkCrapUninstaller\Forms\Windows\MainWindow.cs:line 236
   at System.Windows.Forms.Form.WmClose(Message& m)
   at System.Windows.Forms.Form.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.Callback(HWND hWnd, MessageId msg, WPARAM wparam, LPARAM lparam)

Known Workarounds
Yes.

Tried the following steps:

  1. Turn on the AppContext Switch like <EnableUnsafeBinaryFormatterSerialization>true</EnableUnsafeBinaryFormatterSerialization>
  2. Download and Extract System.Runtime.Serialization.Formatters nuget package.
  3. Copy System.Runtime.Serialization.Formatters.dll from nuget package folder to application publish folder.
  4. Update .deps.json file to registry System.Runtime.Serialization.Formatters.dll for application dependencies by adding following content in deps.json file:
"targets": {
    ".NETCoreApp,Version=v6.0": {},
    ".NETCoreApp,Version=v6.0/win-x64": {
      "BCUninstaller/1.0.0": {
        "dependencies": {
       ......
          "runtimepack.Microsoft.Windows.SDK.NET.Ref": "10.0.18362.31",
          "System.Runtime.Serialization.Formatters": "9.0.0-preview.6.24327.7"
        },
 ......
      "System.Runtime.Serialization.Formatters/9.0.0-preview.6.24327.7": {
        "runtime": {
          "lib/net8.0/System.Runtime.Serialization.Formatters.dll": {
            "assemblyVersion": "9.0.0.0",
            "fileVersion": "9.0.24.32707"
          }
        }
      },
......

​ "libraries": {
......
    "System.Runtime.Serialization.Formatters/9.0.0-preview.6.24327.7": {
      "type": "package",
      "serviceable": true,
      "sha512": "sha512-5S1E7KF/RzcZoRQ27BW3f6HX6zihRVz2utacaUWw4ilos2L4435PPn4rn8c+6Ltp4isTukBnw9K+FZCQHwCVPA==",
      "path": "system.runtime.serialization.formatters/9.0.0-preview.6.24327.7",
      "hashPath": "system.runtime.serialization.formatters.9.0.0-preview.6.24327.7.nupkg.sha512"
    },

@dotnet-actwx-bot @dotnet/compat

@Junjun-zhao Junjun-zhao added the untriaged The team needs to look at this issue in the next triage label Jun 27, 2024
@elachlan
Copy link
Contributor

Related: #6267

@elachlan elachlan added the area-Serialization-BinaryFormatter-FeatureWork Feature work under the general area of BinaryFormatter related serialization label Jun 27, 2024
@elachlan
Copy link
Contributor

elachlan commented Jun 27, 2024

Application needs to add <EnableUnsafeBinaryFormatterSerialization>True</EnableUnsafeBinaryFormatterSerialization>.

Project located at: https://github.com/Klocman/Bulk-Crap-Uninstaller

@elachlan
Copy link
Contributor

@Klocman just a ping to let you know this issue was reported here for Bull-Crap-Uninstaller.

@Junjun-zhao
Copy link
Member Author

Junjun-zhao commented Jul 15, 2024

Update for the workaround: It works well with the public Nuget package for the application. And app owner is also aware of this change. Closing this issue

@dotnet-policy-service dotnet-policy-service bot removed the untriaged The team needs to look at this issue in the next triage label Jul 15, 2024
@github-actions github-actions bot locked and limited conversation to collaborators Aug 17, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-Serialization-BinaryFormatter-FeatureWork Feature work under the general area of BinaryFormatter related serialization
Projects
None yet
Development

No branches or pull requests

2 participants