--- lang: ja-jp breaks: true --- # C# `net8.0` WinForm の .resx ファイルで「BinaryFormatter は、セキュリティ上のリスクが発生する可能性があるため非推奨であり、.NET 9 を使用して削除されます。」と警告が出る。 2023-11-23 ## 警告内容 > .resx : warning MSB3825: "XXXXXXXX.ImageStream" 型のリソース "System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" は、実行時に BinaryFormatter を介して逆シリアル化されます。BinaryFormatter は、セキュリティ上のリスクが発生する可能性があるため非推奨であり、.NET 9 を使用して削除されます。引き続き使用する場合は、プロパティ "GenerateResourceWarnOnBinaryFormatterUse" を false に設定してください。 > .resx : warning MSB3825: 詳細情報: https://aka.ms/msbuild/net8-binaryformatter ## 調査 > BinaryFormatter がほとんどのプロジェクトの種類で無効になりました > https://learn.microsoft.com/ja-jp/dotnet/core/compatibility/serialization/8.0/binaryformatter-disabled > .NET 8 以降では、影響を受けるメソッドは、Windows フォームと WPF を除くすべてのプロジェクトの種類で、実行時に NotSupportedException をスローします。 API は、Windows フォームや WPF を含むすべてのプロジェクトの種類では、古いままになっています (エラーとして残っています)。 > > https://learn.microsoft.com/ja-jp/dotnet/core/compatibility/serialization/7.0/binaryformatter-apis-produce-errors#recommended-action ```xml= <PropertyGroup> ... <EnableUnsafeBinaryFormatterSerialization>true</EnableUnsafeBinaryFormatterSerialization> </PropertyGroup> ``` ###### tags: `C#` `net8.0` `BinaryFormatter` `WinForm`
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up