I was getting a very similar error but with error code -532462766.
In Visual Studio (2022), doing Build | Clean Solution fixed the problem.