microsoft / vscode-dotnettools

This is a feedback repository to capture issues logged for the C# Dev Kit and related extensions from Visual Studio Code
Other
234 stars 13 forks source link

[BUG] .NET server STDERR: System.IO.FileNotFoundException #1496

Open dgf17541 opened 1 month ago

dgf17541 commented 1 month ago

Describe the Issue

I am trying to use unzipped .net binaries with vscode(portable mode). I have used a batch file to set the environment variables and add the dotnet.exe folder to the PATH before opening vscode. However, the extension is not working properly after pressing "Create .NET Project".

Steps To Reproduce

  1. install extensions "C# Dev Kit".
  2. after loaded, press the "Create .NET Project" button.
  3. nothing happen (no warning/error message box)

Expected Behavior

poping up what project to be created and starting new .net project

Environment Information

OS: Window 11 VS Code Version: 1.93.1 (portable mode) Extension Version: C# Dev Kit (v1.10.18) (also tried pre-released v1.11.11)

Batch that I use to open vscode:

@echo off
set "currentPath=C:\Users\User1\Desktop\_files\VSCode"
set "vscodefolder=%currentPath%\VSCode-win32-x64-1.93.1"

set "DOTNET_ROOT=%currentPath%\dotnet-sdk-8.0.401-win-x64"
set "DOTNET_INSTALL_DIR=%DOTNET_ROOT%"
set "DOTNET_MSBUILD_SDK_RESOLVER_CLI_DIR=%DOTNET_ROOT%"
set "DOTNET_CLI_HOME=%currentPath%\dotnet_related\user_profile"

set "PATH=%DOTNET_ROOT%;%DOTNET_CLI_HOME%\.dotnet\tools;%vscodefolder%\bin;%PATH%"

start "" "%vscodefolder%\Code.exe"

"dotnet --info" command result in terminal in vscode:

.NET SDK:
 Version:           8.0.401
 Commit:            811edcc344
 Workload version:  8.0.400-manifests.b6724b7a
 MSBuild version:   17.11.4+37eb419ad

執行階段環境:
 OS Name:     Windows
 OS Version:  10.0.22631
 OS Platform: Windows
 RID:         win-x64
 Base Path:   C:\Users\User1\Desktop\_files\VSCode\dotnet-sdk-8.0.401-win-x64\sdk\8.0.401\

安裝的 .NET 工作負載:
設為在安裝新資訊清單時使用 loose manifests。
沒有已安裝的工作負載可顯示。

Host:
  Version:      8.0.8
  Architecture: x64
  Commit:       08338fcaa5

.NET SDKs installed:
  8.0.401 [C:\Users\User1\Desktop\_files\VSCode\dotnet-sdk-8.0.401-win-x64\sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 8.0.8 [C:\Users\User1\Desktop\_files\VSCode\dotnet-sdk-8.0.401-win-x64\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 8.0.8 [C:\Users\User1\Desktop\_files\VSCode\dotnet-sdk-8.0.401-win-x64\shared\Microsoft.NETCore.App]
  Microsoft.WindowsDesktop.App 8.0.8 [C:\Users\User1\Desktop\_files\VSCode\dotnet-sdk-8.0.401-win-x64\shared\Microsoft.WindowsDesktop.App]

Other architectures found:
  x86   [C:\Program Files (x86)\dotnet]
    registered at [HKLM\SOFTWARE\dotnet\Setup\InstalledVersions\x86\InstallLocation]     

Environment variables:
  DOTNET_ROOT       [C:\Users\User1\Desktop\_files\VSCode\dotnet-sdk-8.0.401-win-x64]

global.json file:
  Not found

C# OUTPUT:

Using dotnet configured on PATH
Dotnet path: C:\Users\User1\Desktop\_files\VSCode\dotnet-sdk-8.0.401-win-x64\dotnet.exe
Activating C# + C# Dev Kit...
waiting for named pipe information from server...
[stdout] {"pipeName":"\\\\.\\pipe\\51b75c70"}
received named pipe information from server
attempting to connect client to server...
client has connected to server
[Info  - 6:40:22 PM] [Program] Language server initialized

C# Dev Kit OUTPUT:

Starting Spawn .NET server...
Using preinstalled .NET runtime at "C:\Users\User1\Desktop\_files\VSCode\dotnet-sdk-8.0.401-win-x64\dotnet.exe" to load Dev Kit processes.
Found installed dotnet location "C:\Users\User1\Desktop\_files\VSCode\dotnet-sdk-8.0.401-win-x64\dotnet.exe" to load projects.
.NET server STDERR: Unhandled exception. 
.NET server STDERR: System.IO.FileNotFoundException: �t�Χ䤣����w���ɮסC (0x80070002)
   at System.Runtime.InteropServices.Marshal.ThrowExceptionForHR(Int32 errorCode)
   at Microsoft.ServiceHub.Utility.Shared.Common.StartProcessWindows(ProcessStartInfo startInfo, EventHandler onExited, EventHandler onDisposed)
   at Microsoft.ServiceHub.Client.HubControllerClient.StartAsync(ServiceHubConfig config, String clientName, CancellationToken cancellationToken)
   at Microsoft.ServiceHub.Client.HubClient.LaunchOrFindControllerAsync()
   at Microsoft.ServiceHub.Client.HubClient.GetLocationServiceAsync()
   at Microsoft.ServiceHub.Utility.Shared.ServiceHubRetry.ExecuteAsync[TReturnType](Func`1 actionToExecute, TraceSource logger, ServiceHubRetryConfiguration`1 serviceHubRetryConfiguration, CancellationToken cancellationToken)
   at Microsoft.ServiceHub.Utility.Shared.ServiceHubRetry.ExecuteAsync[TReturnType](Func`1 actionToExecute, TraceSource logger, ServiceHubRetryConfiguration`1 serviceHubRetryConfiguration, CancellationToken cancellationToken)
   at Microsoft.ServiceHub.Client.HubClient.GetThisAsRemoteServiceBrokerAsync()
   at Microsoft.VisualStudio.Server.ServiceBroker.Program.RunAsync(Stream rpcStream, String bridgePipeName, ExportProvider exportProvider, Boolean includeServiceHub, String serviceHubConfigPath, Func`2 traceSourceFactory, TraceSource traceSource, TelemetrySession telemetrySession, TelemetryEvent perfTelemetryEvent, CancellationToken cancellationToken)
   at Microsoft.VisualStudio.Server.ServiceBroker.Program.RunAsync(Stream rpcStream, String bridgePipeName, ExportProvider exportProvider, Boolean includeServiceHub, String serviceHubConfigPath, Func`2 traceSourceFactory, TraceSource traceSource, TelemetrySession telemetrySession, TelemetryEvent perfTelemetryEvent, CancellationToken cancellationToken)
   at Microsoft.VisualStudio.Server.ServiceBroker.Program.<>c.<<BuildCommandLine>b__7_1>d.MoveNext()
--- End of stack trace from previous location ---
   at System.CommandLine.Invocation.AnonymousCommandHandler.InvokeAsync(InvocationContext context)
   at System.CommandLine.Invocation.InvocationPipeline.<>c__DisplayClass4_0.<<BuildInvocationChain>b__0>d.MoveNext()
--- End of stack trace from previous location ---
   at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass18_0.<<UseParseErrorReporting>b__0>d.MoveNext()
--- End of stack trace from previous location ---
   at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass13_0.<<UseHelp>b__0>d.MoveNext()
--- End of stack trace from previous location ---
   at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass22_0.<<UseVersionOption>b__0>d.MoveNext()
--- End of stack trace from previous location ---
   at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass20_0.<<UseTypoCorrections>b__0>d.MoveNext()
--- End of stack trace from previous location ---
   at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c.<<UseSuggestDirective>b__19_0>d.MoveNext()
--- End of stack trace from previous location ---
   at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c__DisplayClass17_0.<<UseParseDirective>b__0>d.MoveNext()
--- End of stack trace from previous location ---
   at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c.<<RegisterWithDotnetSuggest>b__6_0>d.MoveNext()
--- End of stack trace from previous location ---
   at System.CommandLine.Builder.CommandLineBuilderExtensions.<>c.<<CancelOnProcessTermination>b__1_0>d.MoveNext()
--- End of stack trace from previous location ---
   at System.CommandLine.Invocation.InvocationPipeline.InvokeAsync(IConsole console)
   at System.CommandLine.Parsing.ParseResultExtensions.InvokeAsync(ParseResult parseResult, IConsole console)
   at System.CommandLine.Parsing.ParserExtensions.InvokeAsync(Parser parser, String[] args, IConsole console)
   at Microsoft.VisualStudio.Server.ServiceBroker.Program.Main(String[] args)
   at Microsoft.VisualStudio.Server.ServiceBroker.Program.<Main>(String[] args)

Error occurred in launchDotNetServer: Error: Stream terminated before required bytes were read.
Failed at 'Spawn .NET server' (5224ms) with error: Error: Stream terminated before required bytes were read.
.NET server exited with 3762504530

C# LSP Trace Logs:

Extension vscode.bat does not contribute csharpExtensionLoadPaths
Extension vscode.clojure does not contribute csharpExtensionLoadPaths
Extension vscode.coffeescript does not contribute csharpExtensionLoadPaths
Extension vscode.configuration-editing does not contribute csharpExtensionLoadPaths
Extension vscode.cpp does not contribute csharpExtensionLoadPaths
Extension vscode.csharp does not contribute csharpExtensionLoadPaths
Extension vscode.css does not contribute csharpExtensionLoadPaths
Extension vscode.css-language-features does not contribute csharpExtensionLoadPaths
Extension vscode.dart does not contribute csharpExtensionLoadPaths
Extension vscode.debug-auto-launch does not contribute csharpExtensionLoadPaths
Extension vscode.debug-server-ready does not contribute csharpExtensionLoadPaths
Extension vscode.diff does not contribute csharpExtensionLoadPaths
Extension vscode.docker does not contribute csharpExtensionLoadPaths
Extension vscode.emmet does not contribute csharpExtensionLoadPaths
Extension vscode.extension-editing does not contribute csharpExtensionLoadPaths
Extension vscode.fsharp does not contribute csharpExtensionLoadPaths
Extension vscode.git does not contribute csharpExtensionLoadPaths
Extension vscode.git-base does not contribute csharpExtensionLoadPaths
Extension vscode.github does not contribute csharpExtensionLoadPaths
Extension vscode.github-authentication does not contribute csharpExtensionLoadPaths
Extension vscode.go does not contribute csharpExtensionLoadPaths
Extension vscode.groovy does not contribute csharpExtensionLoadPaths
Extension vscode.grunt does not contribute csharpExtensionLoadPaths
Extension vscode.gulp does not contribute csharpExtensionLoadPaths
Extension vscode.handlebars does not contribute csharpExtensionLoadPaths
Extension vscode.hlsl does not contribute csharpExtensionLoadPaths
Extension vscode.html does not contribute csharpExtensionLoadPaths
Extension vscode.html-language-features does not contribute csharpExtensionLoadPaths
Extension vscode.ini does not contribute csharpExtensionLoadPaths
Extension vscode.ipynb does not contribute csharpExtensionLoadPaths
Extension vscode.jake does not contribute csharpExtensionLoadPaths
Extension vscode.java does not contribute csharpExtensionLoadPaths
Extension vscode.javascript does not contribute csharpExtensionLoadPaths
Extension vscode.json does not contribute csharpExtensionLoadPaths
Extension vscode.json-language-features does not contribute csharpExtensionLoadPaths
Extension vscode.julia does not contribute csharpExtensionLoadPaths
Extension vscode.latex does not contribute csharpExtensionLoadPaths
Extension vscode.less does not contribute csharpExtensionLoadPaths
Extension vscode.log does not contribute csharpExtensionLoadPaths
Extension vscode.lua does not contribute csharpExtensionLoadPaths
Extension vscode.make does not contribute csharpExtensionLoadPaths
Extension vscode.markdown does not contribute csharpExtensionLoadPaths
Extension vscode.markdown-language-features does not contribute csharpExtensionLoadPaths
Extension vscode.markdown-math does not contribute csharpExtensionLoadPaths
Extension vscode.media-preview does not contribute csharpExtensionLoadPaths
Extension vscode.merge-conflict does not contribute csharpExtensionLoadPaths
Extension vscode.microsoft-authentication does not contribute csharpExtensionLoadPaths
Extension ms-vscode.js-debug does not contribute csharpExtensionLoadPaths
Extension ms-vscode.js-debug-companion does not contribute csharpExtensionLoadPaths
Extension ms-vscode.vscode-js-profile-table does not contribute csharpExtensionLoadPaths
Extension vscode.builtin-notebook-renderers does not contribute csharpExtensionLoadPaths
Extension vscode.npm does not contribute csharpExtensionLoadPaths
Extension vscode.objective-c does not contribute csharpExtensionLoadPaths
Extension vscode.perl does not contribute csharpExtensionLoadPaths
Extension vscode.php does not contribute csharpExtensionLoadPaths
Extension vscode.php-language-features does not contribute csharpExtensionLoadPaths
Extension vscode.powershell does not contribute csharpExtensionLoadPaths
Extension vscode.pug does not contribute csharpExtensionLoadPaths
Extension vscode.python does not contribute csharpExtensionLoadPaths
Extension vscode.r does not contribute csharpExtensionLoadPaths
Extension vscode.razor does not contribute csharpExtensionLoadPaths
Extension vscode.references-view does not contribute csharpExtensionLoadPaths
Extension vscode.restructuredtext does not contribute csharpExtensionLoadPaths
Extension vscode.ruby does not contribute csharpExtensionLoadPaths
Extension vscode.rust does not contribute csharpExtensionLoadPaths
Extension vscode.scss does not contribute csharpExtensionLoadPaths
Extension vscode.search-result does not contribute csharpExtensionLoadPaths
Extension vscode.shaderlab does not contribute csharpExtensionLoadPaths
Extension vscode.shellscript does not contribute csharpExtensionLoadPaths
Extension vscode.simple-browser does not contribute csharpExtensionLoadPaths
Extension vscode.sql does not contribute csharpExtensionLoadPaths
Extension vscode.swift does not contribute csharpExtensionLoadPaths
Extension vscode.theme-abyss does not contribute csharpExtensionLoadPaths
Extension vscode.theme-defaults does not contribute csharpExtensionLoadPaths
Extension vscode.theme-kimbie-dark does not contribute csharpExtensionLoadPaths
Extension vscode.theme-monokai does not contribute csharpExtensionLoadPaths
Extension vscode.theme-monokai-dimmed does not contribute csharpExtensionLoadPaths
Extension vscode.theme-quietlight does not contribute csharpExtensionLoadPaths
Extension vscode.theme-red does not contribute csharpExtensionLoadPaths
Extension vscode.vscode-theme-seti does not contribute csharpExtensionLoadPaths
Extension vscode.theme-solarized-dark does not contribute csharpExtensionLoadPaths
Extension vscode.theme-solarized-light does not contribute csharpExtensionLoadPaths
Extension vscode.theme-tomorrow-night-blue does not contribute csharpExtensionLoadPaths
Extension vscode.tunnel-forwarding does not contribute csharpExtensionLoadPaths
Extension vscode.typescript does not contribute csharpExtensionLoadPaths
Extension vscode.typescript-language-features does not contribute csharpExtensionLoadPaths
Extension vscode.vb does not contribute csharpExtensionLoadPaths
Extension vscode.xml does not contribute csharpExtensionLoadPaths
Extension vscode.yaml does not contribute csharpExtensionLoadPaths
Extension ms-dotnettools.csdevkit does not contribute csharpExtensionLoadPaths
Extension ms-dotnettools.csharp does not contribute csharpExtensionLoadPaths
Extension ms-dotnettools.vscode-dotnet-runtime does not contribute csharpExtensionLoadPaths
smitpatel commented 1 month ago

@AArnott - This does look like that server process is starting to launch.

AArnott commented 1 month ago

@ryantoth3 for servicehub failing

AArnott commented 1 month ago

It sounds like a missing file that should have been installed. Can you remove the C# Dev Kit extension and reinstall?

dgf17541 commented 1 month ago

@AArnott @smitpatel Thank you for replying. I have tried reinstalling the extension but it does not help.

How can I know what the missing file is? (e.g. name, preferred location, etc.) Maybe I can help to find its actual location if it does exist.

AArnott commented 1 month ago

@dgf17541 On my Windows x64 machine, the path it tries to launch is at "%USERPROFILE%\.vscode\extensions\ms-dotnettools.csdevkit-1.12.2-win32-x64\components\vs-green-server\platforms\win32-x64\node_modules\@microsoft\servicehub-controller-net60.win32-x64\Microsoft.ServiceHub.Controller.exe"

dgf17541 commented 1 month ago

@AArnott Thank you. As I am using portable mode of vscode. My path will be C:\Users\User1\Desktop\_files\VSCode\VSCode-win32-x64-1.93.1\data\extensions\ms-dotnettools.csdevkit-1.11.14-win32-x64\components\vs-green-server\platforms\win32-x64\node_modules\@microsoft\servicehub-controller-net60.win32-x64.

And it does exist? Image

AArnott commented 1 month ago

Interesting. I wondered if portable mode has anything to do with it, as I've never tried that before. But it worked out of the box.

@dgf17541 Can you try it in the documented way?

  1. download and expand the zip.
  2. create the data directory
  3. launch code.exe and install the C# Dev Kit extension
  4. click "Create .NET Project"

See if the server process starts successfully.

dgf17541 commented 1 month ago

Since I cannot test properly without dotnet installed, this time I have installed the dotnet (installer) and use vscode in portable mode "in the documented way". This time the error disappeared. But in fact, I am not allowed to install anything in the computer(I have uninstalled dotnet immediately after the test).

I wonder the error is caused by my batch script. But what the batch did is only adding dotnet to PATH and keeping the folders created by dotnet in place. It has done nothing about vscode. @AArnott Could you help me to correct my batch therefore I can use vscode with dotnet binaries(without installation)?

wygysimo11 commented 1 month ago

@dgf17541 do you solved it? I just find VsCode can portable. I dont have right to install program. How can I use Vscode with dotnet without install?

dgf17541 commented 1 month ago

@wygysimo11 No. You can try to modify my batch script to get it to work (not yet getting any success though) For the dotnet binaries, you can download zip file from the "Binaries" session at https://dotnet.microsoft.com/en-us/download/dotnet/8.0 then extract it to the location you want.

dgf17541 commented 1 month ago

After couple of testing, I found the error only occur when using the batch script with vscode in portable mode. The error do not occur when I am using the batch script with vscode installed.

Here is the testing results for your reference: dotnet vscode error occur
binaries with batch installed No
binaries with batch portable Yes
installed portable No
installed installed No

Are there anyone could help to look into the issue? Thank you.