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.