Finally I realized that something was wrong with the installation of Visual Studio 2022.
I uninstalled and reinstalled and the exceptions have been gone away.