Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NullReferenceException when OmniSharp server starts #1188

Closed
DustinCampbell opened this issue May 16, 2018 · 1 comment · Fixed by #1189
Closed

NullReferenceException when OmniSharp server starts #1188

DustinCampbell opened this issue May 16, 2018 · 1 comment · Fixed by #1189

Comments

@DustinCampbell
Copy link
Contributor

From @sidecus on May 16, 2018 4:42

Environment data

dotnet --info output:

.NET Command Line Tools (2.0.0)
Runtime Environment:
 OS Name:     Windows
 OS Version:  6.3.9600
 OS Platform: Windows
 RID:         win81-x64

VS Code version: 1.23.1
C# Extension version: 1.15.2

Steps to reproduce

OmniSharp started and then throws exception:

System.NullReferenceException: Object reference not set to an instance of an object.
   at OmniSharp.MSBuild.Discovery.Providers.DevConsoleInstanceProvider.GetInstances()
   at OmniSharp.MSBuild.Discovery.MSBuildLocator.GetInstances()
   at OmniSharp.CompositionHostBuilder.RegisterMSBuildInstance(IMSBuildLocator msbuildLocator, ILogger logger)
   at OmniSharp.CompositionHostBuilder.Build()
   at OmniSharp.Stdio.Host..ctor(TextReader input, ISharedTextWriter writer, IOmniSharpEnvironment environment, IConfiguration configuration, IServiceProvider serviceProvider, CompositionHostBuilder compositionHostBuilder, ILoggerFactory loggerFactory, CancellationTokenSource cancellationTokenSource)
   at OmniSharp.Stdio.Driver.Program.<>c__DisplayClass0_1.<Main>b__1()
   at Microsoft.Extensions.CommandLineUtils.CommandLineApplication.Execute(String[] args)
   at OmniSharp.HostHelpers.Start(Func`1 action)
[ERROR] Error: OmniSharp server load timed out. Use the 'omnisharp.projectLoadTimeout' setting to override the default delay (one minute).

Copied from original issue: dotnet/vscode-csharp#2310

@DustinCampbell
Copy link
Contributor Author

Thanks for reporting this failure! It looks to me like this can happen if the "VSINSTALLDIR" environment variable is set but "VSCMD_VER" is not. This could happen with older instances of Visual Studio when launching from a Developer Command Prompt or if you've set "VSINSTALLDIR" yourself.

I have fix for null-ref in PR. Once this PR is merged and CI is complete, you can use it in C# for VS Code by setting the following option in VS Code:

{
    "omnisharp.path": "latest"
}

Alternatively, you should be able workaround the issue by setting the "VSCMD_VER" environment variable to "".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant