winforms icon indicating copy to clipboard operation
winforms copied to clipboard

[dotnet-sdk-9.0.100-preview.6.24325.8] mRemote launch failed with an exception : PlatformNotSupportedException: BinaryFormatter serialization and deserialization have been removed."

Open Junjun-zhao opened this issue 1 year ago • 2 comments

.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.19045
 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]

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.6.24325.8: Fail 3). Windows 10 21H2 AMD64 + dotnet-sdk-9.0.100-preview.7.24321.3: 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: "The type initializer for 'BrightIdeasSoftware.ObjectListView' threw an exception." After debugging the source code, we found this exception is caused by "PlatformNotSupportedException: BinaryFormatter serialization and deserialization have been removed.".

Application Name: mRemoteNG(WinForms) OS: Windows 10 21H2 CPU: X64 .NET Build Number: dotnet-sdk-9.0.100-preview.6.24325.8 App & Source checking at: https://devdiv.visualstudio.com/DevDiv/_workitems/edit/2100188 Github Link: https://github.com/mRemoteNG/mRemoteNG

Steps to reproduce

  1. Change the runtime.config file to let the app run against with dotnet-sdk-9.0.100-preview.6.24325.8.
 "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"
      }
    ],
  1. Turn on EnableUnsafeBinaryFormatterSerialization switch in runtime.config file:
"configProperties": {
      "System.Reflection.Metadata.MetadataUpdater.IsSupported": false,
      "System.Runtime.Serialization.EnableUnsafeBinaryFormatterSerialization": true
    }
  1. Launch mRemoteNG.exe.

Expected Result: Launch successfully.

Actual Result: Launch failed with error: image mRemotingNG_BugReproSteps

The type initializer for 'BrightIdeasSoftware.ObjectListView' threw an exception.
StackTrace:
at BrightIdeasSoftware.ObjectListView.get_IsVistaOrLater()
   at BrightIdeasSoftware.VirtualObjectListView.get_ShowGroups()
   at BrightIdeasSoftware.VirtualObjectListView.BuildList(Boolean shouldPreserveSelection)
   at BrightIdeasSoftware.VirtualObjectListView.set_VirtualListDataSource(IVirtualListDataSource value)
   at BrightIdeasSoftware.VirtualObjectListView..ctor()
   at BrightIdeasSoftware.TreeListView..ctor()
   at mRemoteNG.UI.Controls.ConnectionTree.ConnectionTree..ctor() in C:\Source\mRemoteNG\mRemoteNG\UI\Controls\ConnectionTree\ConnectionTree.cs:line 69
   at mRemoteNG.UI.Window.ConnectionTreeWindow.InitializeComponent() in C:\Source\mRemoteNG\mRemoteNG\UI\Window\ConnectionTreeWindow.Designer.cs:line 24
   at mRemoteNG.UI.Window.ConnectionTreeWindow..ctor(DockContent panel) in C:\Source\mRemoteNG\mRemoteNG\UI\Window\ConnectionTreeWindow.cs:line 45
   at mRemoteNG.UI.Window.ConnectionTreeWindow..ctor() in C:\Source\mRemoteNG\mRemoteNG\UI\Window\ConnectionTreeWindow.cs:line 36
   at mRemoteNG.App.Windows.get_TreeForm() in C:\Source\mRemoteNG\mRemoteNG\App\Windows.cs:line 23
   at mRemoteNG.UI.Forms.FrmMain.SetMenuDependencies() in C:\Source\mRemoteNG\mRemoteNG\UI\Forms\frmMain.cs:line 289
   at mRemoteNG.UI.Forms.FrmMain.FrmMain_Load(Object sender, EventArgs e) in C:\Source\mRemoteNG\mRemoteNG\UI\Forms\frmMain.cs:line 171
   at System.Windows.Forms.Form.OnLoad(EventArgs e)
   at System.Windows.Forms.Control.CreateControl(Boolean ignoreVisible)
   at System.Windows.Forms.Control.CreateControl()
   at System.Windows.Forms.Control.WmShowWindow(Message& m)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at mRemoteNG.UI.Forms.FrmMain.WndProc(Message& m) in C:\Source\mRemoteNG\mRemoteNG\UI\Forms\frmMain.cs:line 598
   at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.Callback(HWND hWnd, MessageId msg, WPARAM wparam, LPARAM lparam)

Inner Exception when debugging code:

PlatformNotSupportedException: BinaryFormatter serialization and deserialization have been removed. See https://aka.ms/binaryformatter for more information.

Known Workarounds No. Tried the following steps:

  1. Turn on the AppContext Switch like <EnableUnsafeBinaryFormatterSerialization>true</EnableUnsafeBinaryFormatterSerialization>
  2. Install the System.Runtime.Serialization.Formatters nuget package (Failed. Because it is not compatible with this .NET 6.0 App. The supported .NET version of System.Runtime.Serialization.Formatters nuget package is .NET 8)

@dotnet-actwx-bot @dotnet/compat

Junjun-zhao avatar Jun 27 '24 09:06 Junjun-zhao

Related: #6267

elachlan avatar Jun 27 '24 11:06 elachlan

Application needs to add <EnableUnsafeBinaryFormatterSerialization>True</EnableUnsafeBinaryFormatterSerialization> and/or BrightIdeasSoftware.ObjectListView will need to be updated to use a different form of serialization or add a typeconverter.

elachlan avatar Jun 27 '24 23:06 elachlan

Update for the workaround: It works well with the public Nuget package for the application. Closing this issue. We will file an new issue to notify the app owner about this change.

Junjun-zhao avatar Jul 15 '24 11:07 Junjun-zhao