[dotnet-sdk-9.0.100-preview.6.24325.8] NotatnikMechanika get System.PlatformNotSupportedException: BinaryFormatter serialization and deserialization have been removed.
.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.24317.13: 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: System.PlatformNotSupportedException: BinaryFormatter serialization and deserialization have been removed. See https://aka.ms/binaryformatter for more information.
Application Name: NotatnikMechanika (WinForms netcoreapp3.0) 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/2110651 Github Link: https://github.com/VersatileSoft/NotatnikMechanika
Repro Steps:
1.Change the runtime.config file to let the app run against with dotnet-sdk-9.0.100-preview.6.24325.8 and Enable BinaryFormatter.
"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
}
- Launching Notatnik Mechanika.exe.
- Click Dalej button.
- Input "test01" in password textbox.
- Input "test01" in Repeat password textbox.
- Click Dalej button.
- Input “Appcompat” into Nazwa firmy textbox.
- Click Dalej button .
- Click Ok button.
Expected Result: Registered successfully. (Restart the app, the interface will change.)
Actual Result: Registered failed. It will be show PlatformNotSupportedException in Event viewer.
Exception details (Exception comes from Event Viewer):
System.PlatformNotSupportedException: 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 NotatnikMechanika.WinForms.DataMenager.ZapiszDane() in C:\Users\v-yibiaozhu\Desktop\New folder (2)\NotatnikMechanika\Clients\NotatnikMechanika.WinForms\DataMenager.cs:line 63
at NotatnikMechanika.WinForms.Program.OnApplicationExit(Object sender, EventArgs e) in C:\Users\v-yibiaozhu\Desktop\New folder (2)\NotatnikMechanika\Clients\NotatnikMechanika.WinForms\Program.cs:line 54
at System.Windows.Forms.Application.ThreadContext.DisposeInternal(Boolean disposing)
at System.Windows.Forms.Application.ThreadContext.DisposeInternal(Boolean disposing)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(msoloop reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(msoloop reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(msoloop reason, ApplicationContext context)
at NotatnikMechanika.WinForms.Program.Main() in C:\Users\v-yibiaozhu\Desktop\New folder (2)\NotatnikMechanika\Clients\NotatnikMechanika.WinForms\Program.cs:line 44
Known Workarounds
No.
Tried the following steps:
- Turn on the AppContext Switch like
<EnableUnsafeBinaryFormatterSerialization>true</EnableUnsafeBinaryFormatterSerialization> - Install the System.Runtime.Serialization.Formatters nuget package (Failed. Because it is not compatible with this .NET Core 3.0 App. The supported .NET version of System.Runtime.Serialization.Formatters nuget package is .NET 8)
@dotnet-actwx-bot @dotnet/compat
App is using binary formatter in NotatnikMechanika.WinForms.DataMenager.ZapiszDane().
NotatnikMechanika.WinForms no longer exists in the linked github repo and was removed in commit https://github.com/VersatileSoft/NotatnikMechanika/commit/7751157c3a269366658c5ce9d8c86f618588371c
For the app to work, it needs to add <EnableUnsafeBinaryFormatterSerialization>True</EnableUnsafeBinaryFormatterSerialization>.
Update for the workaround: It works well with the public Nuget package for the application. Closing this issue.