dotnet / vscode-csharp

Official C# support for Visual Studio Code
MIT License
2.86k stars 672 forks source link

There is an error "OmniSharp.MSBuild.ProjectLoader Could not read state file "obj/Debug/net6.0/BlazorClient.Shared.csprojAssemblyReference.cache"." on the Output when open project with VSCode. #4416

Open EmilyFeng97 opened 3 years ago

EmilyFeng97 commented 3 years ago

Azure DevOps work item: https://devdiv.visualstudio.com/DevDiv/_workitems/edit/1285991

Testcases Affected [6.0] VerifyAngularwithNoAuth [6.0] VerifyReactwithNoAuth [6.0] VerifyReactRedux [6.0] VerifyBlazorClient

Platform

Repro Steps

  1. Open up a normal Terminal Emulator
  2. Create a BlazorClient project and name it "BlazorClient": dotnet new blazorwasm -ho -o BlazorClient
  3. Navigate to the folder you created Angular and open VS Code using Terminal Emulator
    cd ~
    cd ./BlazorClient/Server/
    code .

    Actual Result

    Image image image

Error Log

    Could not read state file "obj/Debug/net6.0/BlazorClient.Shared.csprojAssemblyReference.cache". The input stream is not a valid binary format. The starting contents (in bytes) are: 4D-42-52-53-43-01-01-99-00-00-00-01-69-2F-68-6F-6D ...
    Successfully loaded project file '/home/aapt/BlazorClient/Shared/BlazorClient.Shared.csproj'.

/home/aapt/BlazorClient/Shared/BlazorClient.Shared.csproj /home/aapt/.vscode/extensions/ms-dotnettools.csharp-1.23.10/.omnisharp/1.37.6/omnisharp/.msbuild/Current/Bin/Microsoft.Common.CurrentVersion.targets(2123,5): Error: Could not read state file "obj/Debug/net6.0/BlazorClient.Shared.csprojAssemblyReference.cache". The input stream is not a valid binary format. The starting contents (in bytes) are: 4D-42-52-53-43-01-01-99-00-00-00-01-69-2F-68-6F-6D ...

    Adding project '/home/aapt/BlazorClient/Shared/BlazorClient.Shared.csproj'
    Update project: BlazorClient.Server

Can't find custom attr constructor image: /home/aapt/BlazorClient/Client/bin/Debug/net6.0/BlazorClient.Client.dll mtoken: 0x0a000001 due to: Cannot resolve dependency to assembly because it has not been preloaded. When using the ReflectionOnly APIs, dependent assemblies must be pre-loaded or loaded on demand through the ReflectionOnlyAssemblyResolve event.

EmilyFeng97 commented 3 years ago

Sometimes I also encounter the following error: image Error Log

    Could not read state file "obj/Debug/net6.0/BlazoADDb2cstand.csprojAssemblyReference.cache". Binary stream '109' does not contain a valid BinaryHeader. Possible causes are invalid stream or object version change between serialization and deserialization.
    Queue project update for '/home/aapt/BlazoADDb2cstand/BlazoADDb2cstand.csproj'
    Successfully loaded project file '/home/aapt/BlazoADDb2cstand/BlazoADDb2cstand.csproj'.

/home/aapt/BlazoADDb2cstand/BlazoADDb2cstand.csproj /home/aapt/.vscode/extensions/ms-dotnettools.csharp-1.23.10/.omnisharp/1.37.6/omnisharp/.msbuild/Current/Bin/Microsoft.Common.CurrentVersion.targets(2123,5): Error: Could not read state file "obj/Debug/net6.0/BlazoADDb2cstand.csprojAssemblyReference.cache". Binary stream '109' does not contain a valid BinaryHeader. Possible causes are invalid stream or object version change between serialization and deserialization.

mwaqasaziz commented 3 years ago

Mine error is also related

VSCODE version 1.54.3 DOTNET SDK - 6.0.100-preview.2.21155.3

Successfully loaded project file '/PData.A/VsCodeProjects/HisBizBackendSolution/HisBiz.Shared/SharedLibrary/SharedLibrary.csproj'. /PData.A/VsCodeProjects/HisBizBackendSolution/HisBiz.Shared/SharedLibrary/SharedLibrary.csproj /home/waqas/.vscode/extensions/ms-dotnettools.csharp-1.23.9/.omnisharp/1.37.6/omnisharp/.msbuild/Current/Bin/Microsoft.Common.CurrentVersion.targets(2123,5): Error: Could not read state file "obj/Debug/net6.0/SharedLibrary.csprojAssemblyReference.cache". The input stream is not a valid binary format. The starting contents (in bytes) are: 4D-42-52-53-43-01-01-99-00-00-00-01-69-2F-75-73-72 ...

I only encountered this error when i installed dotnet 6.0.100-preview.2.21155.3 it was working fine with dotnet 6.0 preview 1

Yuyue960724 commented 3 years ago

This issue not repro on MAC/Linux with latest .NET 6.0 Preview 3 build.

semsuddin commented 3 years ago

This issue not repro on MAC/Linux with latest .NET 6.0 Preview 3 build.

Where did you get the Preview 3 version? I am facing the same issue with .NET 6 Preview 2.

Yuyue960724 commented 3 years ago

This issue not repro on MAC/Linux with latest .NET 6.0 Preview 3 build.

Where did you get the Preview 3 version? I am facing the same issue with .NET 6 Preview 2.

.NET 6.0 Preview 3 is an internal version, Maybe you don’t have permission to get it.