In my previously normal project, it suddenly started giving this error. There is no problem with the directory you mentioned. Even if I delete the .NET CORE SDK and reinstall it, the error persists.
1>SGEN : error : An attempt was made to load an assembly with an incorrect format: C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\5.0.0\ref\net5.0\Microsoft.CSharp.dll.