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

The WinformsControlTest app under the Winforms repo will stop running when opening TreeView/ListView form #9322

Closed
MelonWang1 opened this issue Jun 21, 2023 · 4 comments
Assignees
Labels
area-Serialization-BinaryFormatter-FeatureWork Feature work under the general area of BinaryFormatter related serialization
Milestone

Comments

@MelonWang1
Copy link
Contributor

.NET version

.NET 8.0.100-preview.6.23320.4

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, it cannot repro in .NET 8.0.100-preview.5.23261.16.

Issue description

In E2E testing, the WinformsControlTest app under the Winforms repo will stop running when opening TreeView/ListView form. After investigation, we found an exception: BinaryFormatter serialization and deserialization are disabled within this application was catched.
Stop running:

debug.mp4

Exception:
image

Call stack:

System.Windows.Forms.dll!System.Windows.Forms.NativeWindow.Callback(Windows.Win32.Foundation.HWND hWnd, Interop.User32.WM msg, Windows.Win32.Foundation.WPARAM wparam, Windows.Win32.Foundation.LPARAM lparam) Line 381 C#
[External Code]
System.Windows.Forms.dll!System.Windows.Forms.Application.ComponentManager.Interop.Mso.IMsoComponentManager.FPushMessageLoop(nuint dwComponentID, Interop.Mso.msoloop uReason, void* pvLoopData) Line 293 C#
System.Windows.Forms.dll!System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Interop.Mso.msoloop reason, System.Windows.Forms.ApplicationContext context) Line 1090 C#
System.Windows.Forms.dll!System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Interop.Mso.msoloop reason, System.Windows.Forms.ApplicationContext context) Line 956 C#
System.Windows.Forms.dll!System.Windows.Forms.Application.Run(System.Windows.Forms.Form mainForm) Line 1160 C#
WinformsControlsTest.dll!Program.

$(string[] args) Line 23 C#

Steps to reproduce

  1. Git clone https://github.com/dotnet/winforms
  2. Open CMD from clone folder and run "start-vs.cmd" command open project
  3. Select WinformsControlTest app, right click it to set as startup project
  4. Build and run, click "TreeView,ImageList"/"ListView" button
@MelonWang1 MelonWang1 added untriaged The team needs to look at this issue in the next triage 💥 regression-preview Regression from a preview release labels Jun 21, 2023
@Tanya-Solyanik
Copy link
Member

Tanya-Solyanik commented Jun 21, 2023

See dotnet/sdk#31591 for details.
This sample is not a "winforms application" because it does not have - <UseWindowsForms>true</UseWindowsForms> and instead refereces winforms binaries directly.
It can be fixed on application startup -

            AppContext.SetSwitch(
                "System.Runtime.Serialization.EnableUnsafeBinaryFormatterSerialization",
                isEnabled: true);

or in the project file -

    <EnableUnsafeBinaryFormatterSerialization>true</EnableUnsafeBinaryFormatterSerialization>

Tanya-Solyanik added a commit to Tanya-Solyanik/winforms that referenced this issue Jun 21, 2023
@merriemcgaw merriemcgaw removed the untriaged The team needs to look at this issue in the next triage label Jun 21, 2023
@merriemcgaw
Copy link
Member

Part of the follow up to #6267

@merriemcgaw merriemcgaw added area-Serialization-BinaryFormatter-FeatureWork Feature work under the general area of BinaryFormatter related serialization and removed 💥 regression-preview Regression from a preview release labels Jun 21, 2023
@MelonWang1
Copy link
Contributor Author

Verified this issue on the latest winforms repo from main branch and the release/8.0 branch, it was fixed. The TreeView/ListView form run successfully when opening it.
Main:

main.mp4

Release/8.0:

release-8.0.mp4

@MelonWang1 MelonWang1 added this to the 9.0 Preview2 milestone Feb 7, 2024
@John-Qiao
Copy link
Member

Verified this issue on the winforms repo from release/9.0-preview2 branch, it was fixed. The result is same as above.

@github-actions github-actions bot locked and limited conversation to collaborators Apr 3, 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

5 participants