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

WinForms designer generates resx file with BinaryFormatter warning when control has PointF property #12509

Closed
chrarnoldus opened this issue Nov 19, 2024 · 1 comment

Comments

@chrarnoldus
Copy link

chrarnoldus commented Nov 19, 2024

Environment

Microsoft Visual Studio Professional 2022 (64-bit) - Current
Version 17.12.0

.NET version

SDK version 9.0.100

Did this work in a previous version of Visual Studio and/or previous .NET release?

I think this issue applies since BinaryFormatter was marked Obsolete.

Edit: I'm actually not sure if the designer ever could serialize PointF values out of the box.

Issue description

When a control with PointF property is used through the WinForms designer, the following warning is generated:

Form1.resx : warning MSB3825: Resource "userControl11.Point" of type "System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" may be deserialized via BinaryFormatter at runtime. BinaryFormatter is deprecated due to known security risks and is removed from .NET 9+. If you wish to continue using it, set property "GenerateResourceWarnOnBinaryFormatterUse" to false.
Form1.resx : warning MSB3825:            More information: https://aka.ms/binaryformatter-migration-guide

I have found related issues #9701 and #9110, but it is still not clear to me how to work around this issue. I don't think suppressing the warning as suggested is acceptable. The control could be in a third party DLL, so modifying the control is not a workable solution either.

Note that the property is grayed out in the designer, so it is unclear why it is serialized in the first place.

Steps to reproduce

Build the following repro: WinFormsApp1.zip

@chrarnoldus chrarnoldus added the untriaged The team needs to look at this issue in the next triage label Nov 19, 2024
@lonitra
Copy link
Member

lonitra commented Nov 19, 2024

Thank you for your report! The WinForms designer has historically always used BinaryFormatter in ResX serialization/deserialization scenarios at design time if the following are true: https://learn.microsoft.com/dotnet/standard/serialization/binaryformatter-migration-guide/winforms-applications#the-windows-forms-designer. msbuild is generating this warning because it sees a binary serialized object in Form1.resx as it is generating a .resources file. Since resources are considered trusted data, at runtime these resources will deserialize as expected without BinaryFormatter so the warning can be suppressed. If you are experiencing issues with being unable to deserialize resources at runtime please let us know, we'd be happy to investigate.

@merriemcgaw merriemcgaw added the 📭 waiting-author-feedback The team requires more information from the author label Nov 19, 2024
@dotnet-policy-service dotnet-policy-service bot removed untriaged The team needs to look at this issue in the next triage 📭 waiting-author-feedback The team requires more information from the author labels Nov 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants