I use two IDEs. Or even more, if different versions are considered. So, there is Visual Studio 2019, VS 2022 PreView and recently JetBrains Rider 2021.2.1. One of the most annoying problems that I had when I switched from VS to Rider, was the error: CA0001: An unknown error occurred while running Code Analysis.
Fortunately, my colleague from the office (thanks Marcin!) pointed that this is related to the selected MSBuild type. In order to resolve this issue one has to go to File->Settings->Build, Execution, Deployment->Toolset and Build and in the dropbox „Use MSBuild version” change MSBuild from „Auto detected (17.0)” (taken from VS2022 PV) to „16.0” (from VS2019).
This simple operation not only removes „CA0001: An unknown error occurred while running Code Analysis” but also allows working with the WinForms without any issues. If you experienced similar problems, try to change MSBuild – maybe it will help?