vscode-csharp icon indicating copy to clipboard operation
vscode-csharp copied to clipboard

Omnisharp can not find assembly netstandard

Open motor75 opened this issue 7 years ago • 25 comments

Issue Description

Upon starting up VS Code, I get an immediate error in the OmniSharp output indicating the following below. I reverted Omnisharp back to version 1.18 as per this Stack Overflow article, but I'm still getting the same error:

System.IO.FileNotFoundException: Could not load file or assembly 'netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' or one of its dependencies. The system cannot find the file specified. File name: 'netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' at OmniSharp.Stdio.Driver.Program.<>c__DisplayClass0_1.

b__1() at OmniSharp.HostHelpers.Start(Func`1 action) in D:\a\1\s\src\OmniSharp.Host\HostHelpers.cs:line 29

Steps to Reproduce

After OmniSharp update to 1.19, start VS Code and error occurs. Reverted back to 1.18 and error still occurs. This was not occurring 2 weeks ago.

Expected Behavior

No error should occur; Intellisense and inline errors should be displayed

Actual Behavior

The error above is produced; no intellisence nor inline errors are displayed.

OmniSharp log

OmniSharp server started. Path: C:\Users\moserk.vscode\extensions\ms-vscode.csharp-1.18.0.omnisharp\3.5.0-beta.2219\OmniSharp.exe PID: 7952

System.IO.FileNotFoundException: Could not load file or assembly 'netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' or one of its dependencies. The system cannot find the file specified. File name: 'netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' at OmniSharp.Stdio.Driver.Program.<>c__DisplayClass0_1.

b__1() at OmniSharp.HostHelpers.Start(Func`1 action) in D:\a\1\s\src\OmniSharp.Host\HostHelpers.cs:line 29

WRN: Assembly binding logging is turned OFF. To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1. Note: There is some performance penalty associated with assembly bind failure logging. To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].

Post the output from Output-->OmniSharp log here

C# log

Getting latest OmniSharp version information Downloading package 'Latest OmniSharp Version Information' (1 KB).................... Done!

Environment information

VSCode version: 1.33.1 C# Extension: 1.18.0

Dotnet Information .NET Core SDK (reflecting any global.json): Version: 2.2.203 Commit: e5bab63eca

Runtime Environment: OS Name: Windows OS Version: 10.0.15063 OS Platform: Windows RID: win10-x64 Base Path: C:\Program Files\dotnet\sdk\2.2.203\

Host (useful for support): Version: 2.2.4 Commit: f95848e524

.NET Core SDKs installed: 2.1.4 [C:\Program Files\dotnet\sdk] 2.1.103 [C:\Program Files\dotnet\sdk] 2.1.201 [C:\Program Files\dotnet\sdk] 2.1.202 [C:\Program Files\dotnet\sdk] 2.1.400 [C:\Program Files\dotnet\sdk] 2.1.403 [C:\Program Files\dotnet\sdk] 2.1.502 [C:\Program Files\dotnet\sdk] 2.1.505 [C:\Program Files\dotnet\sdk] 2.2.203 [C:\Program Files\dotnet\sdk]

.NET Core runtimes installed: Microsoft.AspNetCore.All 2.1.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All] Microsoft.AspNetCore.All 2.1.3 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All] Microsoft.AspNetCore.All 2.1.5 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All] Microsoft.AspNetCore.All 2.1.6 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All] Microsoft.AspNetCore.All 2.1.9 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All] Microsoft.AspNetCore.All 2.2.4 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All] Microsoft.AspNetCore.App 2.1.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 2.1.3 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 2.1.5 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 2.1.6 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 2.1.9 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 2.2.4 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.NETCore.App 2.0.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 2.0.6 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 2.0.7 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 2.0.9 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 2.1.2 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 2.1.3 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 2.1.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 2.1.6 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 2.1.9 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 2.2.4 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]

To install additional .NET Core runtimes or SDKs: https://aka.ms/dotnet-download

Visual Studio Code Extensions
Extension Author Version
csharp ms-vscode 1.18.0
dotnet-test-explorer formulahendry 0.6.6
EditorConfig EditorConfig 0.13.0
vscode-nuget-package-manager jmrog 1.1.6

motor75 avatar Apr 17 '19 18:04 motor75

The rollback to 1.18.0 worked for me, but be sure to set the preference "extensions.autoUpdate" to false or it will just reinstall 1.19.0

jwerra avatar Apr 17 '19 20:04 jwerra

do you have .NET 4.7.2 installed? It appears to be the reason for this failure.

filipw avatar Apr 17 '19 20:04 filipw

I do have auto update turned off, so Omnisharp is at version 1.18.0

motor75 avatar Apr 17 '19 20:04 motor75

It appears I have 4.7.2 installed...

C:\Windows\Microsoft.NET\Framework\v4.0.30319>.\msbuild.exe -version Microsoft (R) Build Engine version 4.7.2046.0 [Microsoft .NET Framework, version 4.0.30319.42000] Copyright (C) Microsoft Corporation. All rights reserved.

4.7.2046.0

motor75 avatar Apr 17 '19 20:04 motor75

I can't install 4.7.2 (Windows 8.1). Installation fails. So I think I may be stuck on 1.18.0.

Microsoft seem to have forgotten developers are still using older OS versions.

mnewboult avatar Apr 18 '19 09:04 mnewboult

I have an update on this issue - I have now suddenly got the following error dialog box which was not appearing before when I attempt to open my project: image

I clicked "YES" and installed the SDK for developers. Once installed, Omnisharp is now working fine.

Now, why it didn't show this error before and why it felt I needed to install the 4.7.2 framework when I apparently had it installed (based on my confirmation of such as shown in my previous comment above) is quite baffling. Although I would think this is unrelated, but my regular Visual Studio Enterprise installation requested an update yesterday to version 15.9.11. At the same time, Visual Studio Code also did an update for the April patches. It very well could have been one of these or a combination of these updates that caused my issue.

motor75 avatar Apr 18 '19 18:04 motor75

Probably because of this: https://github.com/OmniSharp/omnisharp-roslyn/pull/1469

SirIntruder avatar Apr 18 '19 19:04 SirIntruder

yes, you must have had "omnisharp.path":"latest" set in your VS Code, and it pulled down the latest build from master which is 1.32.19-beta.21 at the moment which had the linked change (https://github.com/OmniSharp/omnisharp-roslyn/pull/1469). instead of OmniSharp crashing at startup silently, it should prompt now for the missing 4.7.2 on windows.

If you want to pin the version please use "omnisharp.path":"1.32.19-beta.21", this way you are guaranteed you fetch that version only.

filipw avatar Apr 18 '19 19:04 filipw

@SirIntruder you're probably correct - I see my file was updated today at 2:48pm (50 minutes ago) when I was still on version 1.18. No clue how it got updated, but it definitely has the 4.7.2 framework requirement in the config:

  <startup>
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7.2" />
  </startup>

Once everything started working again, I then allowed VS Code to do an update to 1.19 and I'm still good to go. Very odd sequence of events the last 2 days - I'd like to know what caused it and how to prevent it in the future.

motor75 avatar Apr 18 '19 19:04 motor75

@filipw - I still have that in my settings:

"omnisharp.path": "latest"

Should it be set to something else?

motor75 avatar Apr 18 '19 19:04 motor75

I'd like to know what caused it and how to prevent it in the future.

Like I mentioned, the error was caused by the lack of .NET 4.7.2 on your Windows box (note, the version that you posted was just the msbuild version, not the .NET Framework version). Unfortunately we missed the supportedRuntime change as part of the OmniSharp release and instead of prompting the users that didn't have it to install it, it became a silent error that you experienced.

Apologies for the trouble. 😞

"omnisharp.path": "latest"

Should it be set to something else?

Have a look at my comment here, I try to explain the different possible settings https://github.com/OmniSharp/omnisharp-roslyn/issues/1416#issuecomment-484415857 Ideally you never need to set "omnisharp.path": "latest" because that by its definition will be unstable as it pulls the latest master build (not any official release).

Since you now have 4.7.2 wired in, it should be safe to remove that setting completely and just use the OmniSharp that's bundled with the 1.19.0 extension. Hope this helps.

filipw avatar Apr 18 '19 19:04 filipw

@filipw - Awesome explanation - thanks for your help and detailed information :)

motor75 avatar Apr 18 '19 19:04 motor75

Same issue, resolved disabling update and installing 1.18.0

Jacknq avatar Apr 19 '19 12:04 Jacknq

This was resolved by https://github.com/OmniSharp/omnisharp-roslyn/pull/1469 Until the next release, the workaround is to install .NET 4.7.2 or use the method described here https://github.com/OmniSharp/omnisharp-vscode/issues/3004#issuecomment-484655065 which will prompt automatically for .NET 4.7.2 installation.

filipw avatar Apr 23 '19 15:04 filipw

I'm creating a Blazor project with .NET Core 3.0 following the official documentation: Get started with Blazor and having this issue. Why do i have to install .NET Framework 4.7.2 as a workaround if .NET Core is supposed to replace the .NET Framework? I'm not a .NET Developer but that is what i understood

GabrielBB avatar May 02 '19 14:05 GabrielBB

@GabrielBB OmniSharp, the component used by the C# Extension for VS Code to provide intellisense, runs on .NET Framework 4.7.2. Your Blazor project runs in .NET Core, but this particular development tool requires .NET Framework. Note that the fact that you have to manually determine that you need install 4.7.2 is a bug that we fixed in https://github.com/OmniSharp/omnisharp-roslyn/pull/1469

rchande avatar May 02 '19 16:05 rchande

I have the same issue, but on linux

shkarface avatar Jun 03 '19 12:06 shkarface

Ditto for Linux.


OmniSharp server started with Mono 5.18.1.
    Path: /home/luyseyal/.vscode/extensions/ms-vscode.csharp-1.20.0/.omnisharp/1.32.20/omnisharp/OmniSharp.exe
    PID: 4455

System.IO.FileNotFoundException: Could not load file or assembly 'netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' or one of its dependencies.
File name: 'netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'
  at OmniSharp.CommandLineApplication+<>c__DisplayClass11_0.<OnExecute>b__0 () [0x0000b] in <ed3c9ce4e617450c93f057d2d4910269>:0 
  at McMaster.Extensions.CommandLineUtils.CommandLineApplication.Execute (System.String[] args) [0x00039] in <344a1e8cd6594b17b1e01f8df6ae8827>:0 
  at OmniSharp.CommandLineApplication.Execute (System.Collections.Generic.IEnumerable`1[T] args) [0x00042] in <ed3c9ce4e617450c93f057d2d4910269>:0 
  at OmniSharp.Stdio.Driver.Program+<>c__DisplayClass0_0.<Main>b__0 () [0x00028] in <8c53cc66f1ca4f63a09ec8173bd47c77>:0 
  at OmniSharp.HostHelpers.Start (System.Func`1[TResult] action) [0x0001c] in <ed3c9ce4e617450c93f057d2d4910269>:0 
[ERROR] Error: OmniSharp server load timed out. Use the 'omnisharp.projectLoadTimeout' setting to override the default delay (one minute).

luyseyal avatar Jul 18 '19 15:07 luyseyal

I think this is fixed if you install fsharp for Linux. Sorry, I installed a TON of stuff but I think that's the one that did it.

luyseyal avatar Jul 18 '19 15:07 luyseyal

I am getting this on Mac since upgrading to .NET Core 3.0

koliyo avatar Oct 01 '19 19:10 koliyo