Movatterモバイル変換


[0]ホーム

URL:


Skip to main content

This browser is no longer supported.

Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.

Download Microsoft EdgeMore info about Internet Explorer and Microsoft Edge
Table of contentsExit editor mode

Compiler Warning WFDEV004

Feedback

In this article

Version introduced: .NET 10 Preview 1

Form.OnClosing,Form.OnClosed and the corresponding events are obsolete. UseForm.OnFormClosing,Form.OnFormClosed,Form.FormClosing andForm.FormClosed instead.

These methods and events are provided for backwards compatibility and they shouldn't be used. Instead, reference the replacement methods and events.

Workaround

Replace the obsolete member with the new member:

Old memberNew member
Form.OnClosingForm.OnFormClosing
Form.OnClosedForm.OnFormClosed
Form.ClosingForm.FormClosing
Form.ClosedForm.FormClosed

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.WFDEV004.severity = none

    For more information about editor config files, seeConfiguration files for code analysis rules.

  • Add the followingPropertyGroup to your project file:

    <PropertyGroup>    <NoWarn>$(NoWarn);WFDEV004</NoWarn></PropertyGroup>
  • Suppress in code with the#pragma warning disable WFDEV004 directive.

For more information, seeHow to suppress code analysis warnings.

Collaborate with us on GitHub
The source for this content can be found on GitHub, where you can also create and review issues and pull requests. For more information, seeour contributor guide.

Feedback

Was this page helpful?

YesNoNo

Need help with this topic?

Want to try using Ask Learn to clarify or guide you through this topic?

Suggest a fix?

  • Last updated on

In this article

Was this page helpful?

YesNo
NoNeed help with this topic?

Want to try using Ask Learn to clarify or guide you through this topic?

Suggest a fix?