I had the same issue following an update to Visual Studio. I saw that the .NET Runtime Optimization Service was running the background. After it had completed and I cleaned and rebuilt my solution, the errors had gone. I think you may just have to wait for the Runtime Optimization to complete and then it should work.