WFDEV001: WParam, LParam, and Message.Result are obsolete
To reduce the risk of cast and overflow exceptions associated with IntPtr on different platforms, the Windows Forms SDK disallows direct use of Message.WParam, Message.LParam, and Message.Result. Projects that use the DEBUG
build of the Windows Forms SDK and that reference WParam, LParam, or Result will fail to compile due to warning WFDEV001
.
Workarounds
Update your code to use the new internal properties, either WParamInternal
, LParamInternal
, or ResultInternal
depending on the situation.
Suppress a warning
If you must use the obsolete APIs, you can suppress the warning in code or in your project file.
To suppress only a single violation, add preprocessor directives to your source file to disable and then re-enable the warning.
// Disable the warning.
#pragma warning disable WFDEV001
// Code that uses obsolete API.
// ...
// Re-enable the warning.
#pragma warning restore WFDEV001
To suppress all the WFDEV001
warnings in your project, add a <NoWarn>
property to your project file.
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
...
<NoWarn>$(NoWarn);WFDEV001</NoWarn>
</PropertyGroup>
</Project>
For more information, see Suppress warnings.
.NET Desktop feedback
Feedback
https://aka.ms/ContentUserFeedback.
Coming soon: Throughout 2024 we will be phasing out GitHub Issues as the feedback mechanism for content and replacing it with a new feedback system. For more information see:Submit and view feedback for