Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Version introduced: .NET 10 Preview 1
Clipboard.GetData(string)is obsolete. UseClipboard.TryGetData<T>methods instead.
-or-
DataObject.GetDatamethods are obsolete. Use the correspondingDataObject.TryGetData<T>instead.
-or-
ClipboardProxy.GetData(As String)method is obsolete. UseClipboardProxy.TryGetData(Of T)(As String, As T)instead.
Using Clipboard.GetData(String), DataObject.GetData, or ClipboardProxy.GetData(String), generates warning WFDEV005 at compile time. These methods rely on BinaryFormatter, which is deprecated for security reasons. For more information, see Windows Forms migration guide for BinaryFormatter.
Workaround
Replace references to these methods with ones that don't use BinaryFormatter.
| Original method | Replacement method |
|---|---|
| Clipboard.GetData(String) | Clipboard.TryGetData |
| DataObject.GetData | DataObject.TryGetData |
| ClipboardProxy.GetData(String) | ClipboardProxy.TryGetData |
Suppress a warning
Suppress the warning with either of the following methods:
Set the severity of the rule in the .editorConfig file.
[*.{cs,vb}] dotnet_diagnostic.WFDEV005.severity = noneFor more information about editor config files, see Configuration files for code analysis rules.
Add the following
PropertyGroupto your project file:<PropertyGroup> <NoWarn>$(NoWarn);WFDEV005</NoWarn> </PropertyGroup>Suppress in code with the
#pragma warning disable WFDEV005directive.
For more information, see How to suppress code analysis warnings.
.NET Desktop feedback