I encountered the same issue. The simplest solution is to change target framework to .NET 9.0. Error magically disappears!