If you have a .NET 8 WinForms project with a localizable form that contains a ListView with a Group, you get a MSB3825 warning about using BinaryFormatter, which is deprecated.
BinaryFormatter will be removed altogether from .NET 9.x so I assume that this will stop working next year.
How can I fix this? The error is in code generated by the WinForms designer, so I can't see how to do so...
To reproduce this issue:
- Create a directory named "WinForms1" and from the Visual Studio 2022 command line change to that directory.
- Run the following command:
dotnew new winforms - Open the created "WinForms1.csproj" file with Visual Studio 2022.
- Edit
Form1in the WinForms designer. - Add a
ListViewto the form. - Right-click the
ListViewand select Edit Groups... - Click Add and then click OK.
- In the form's properties set
Localizableto true. - Build the project.
Now you get the following warning:
Form1.resx : warning MSB3825:
Resource "listView1.Groups" of type "System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" is deserialized via BinaryFormatter at runtime.
BinaryFormatter is deprecated due to possible security risks and will be removed with .NET 9.
If you wish to continue using it, set property "GenerateResourceWarnOnBinaryFormatterUse" to false.