I had this problem on a VM with Windows Server 2019 and Visual Studio 2022. I had Read/Write permissions to C:\ProgramData\Microsoft\Crypto\RSA\MachineKeys. I removed myself from the list and added again with Read/Write permissions (I couldn't grant myself Full control), ran VS as an Administrator and that solved the problem.