dotnet / vscode-csharp

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

Omnisharp OUTPUT: Can't print exception string because Exception.ToString() failed. #2718

Open Weaverzhu opened 5 years ago

Weaverzhu commented 5 years ago

Environment data

dotnet --info output:

.NET Core SDK: Version: 2.1.500 Commit: b68b931422

OS Name: Windows OS Version: 10.0.17134 OS Platform: Windows RID: win10-x64 Base Path: C:\Program Files\dotnet\sdk\2.1.500\

Host (useful for support): Version: 2.1.6 Commit: 3f4f8eebd8

.NET Core SDKs installed: 2.1.500 [C:\Program Files\dotnet\sdk]

.NET Core runtimes installed: Microsoft.AspNetCore.All 2.1.6 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All] Microsoft.AspNetCore.App 2.1.6 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.NETCore.App 2.1.6 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]

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

VS Code version: 1.29.1(user setup) C# Extension version:ms-vscode.csharp-1.17.1

OUTPUT in OmniSharp Log

OmniSharp server started. Path: C:\Users\17396.vscode\extensions\ms-vscode.csharp-1.17.1.omnisharp\1.32.8\OmniSharp.exe PID: 10072

Error: Can't print exception string because Exception.ToString() failed. [ERROR] Error: OmniSharp server load timed out. Use the 'omnisharp.projectLoadTimeout' setting to override the default delay (one minute).

Path in environment variables

C:\Windows\System32 C:\Program Files\dotnet C:\Windows\Microsoft.NET\Framework64\v4.0.30319

others are unrelated

Description

I have reinstall extension and .net core sdk for many times but not works. It also says .net cli tools can't be located, but I can actually use debugger and run my console app. dotnet commands also works in cmd. default

rchande commented 5 years ago

@Weaverzhu can you run the set command from the command prompt inside VS Code? Also, you might need to increase your project load timeout ("omnisharp.projectLoadTimeout" option).

Weaverzhu commented 5 years ago

output after running the ‘set’ command

ALLUSERSPROFILE=C:\ProgramData APPDATA=C:\Users\17396\AppData\Roaming CCHZPATH=F:\CTEX\CTeX\cct\fonts CCPKPATH=F:\CTEX\CTeX\fonts\pk\modeless\cct\dpi$d CLASSPATH=C:\Program Files\Java\jdk1.8.0_171\lib;C:\Program Files\Java\jdk1.8.0_171\lib\tools.jar;C:\Compilers\poi-3.17\poi-3.17.jar;C:\Compilers\poi-3.17\poi-ooxml-3.17.jar;C:\Compilers\poi-3.17\poi-ooxml-schemas-3.17.jar;C:\Compilers\poi-3.17\ooxml-lib\xmlbeans-2.6.0.jar;xmlbeans-2.6.0\curvesapi-1.04.jar;C:\Compilers\Java\jfreechart-1.0.1\lib\jcommon-1.0.0.jar;C:\Compilers\Java\jfreechart-1.0.1\lib\jfreechart-1.0.1.jar; CommonProgramFiles=C:\Program Files\Common Files CommonProgramFiles(x86)=C:\Program Files (x86)\Common Files CommonProgramW6432=C:\Program Files\Common Files COMPUTERNAME=DESKTOP-O3JC923 ComSpec=C:\Windows\system32\cmd.exe DriverData=C:\Windows\System32\Drivers\DriverData HOMEDRIVE=C: HOMEPATH=\Users\17396 INTEL_DEV_REDIST=C:\Program Files (x86)\Common Files\Intel\Shared Libraries\ JAVA_HOME=C:\Program Files\Java\jdk1.8.0_171 LOCALAPPDATA=C:\Users\17396\AppData\Local LOGONSERVER=\DESKTOP-O3JC923 Maven_HOME=C:\Apache-Maven\apache-maven-3.5.3 MIC_LD_LIBRARY_PATH=C:\Program Files (x86)\Common Files\Intel\Shared Libraries\compiler\lib\mic MSMPI_BIN=C:\Program Files\Microsoft MPI\Bin\ NUMBER_OF_PROCESSORS=8 OneDrive=C:\Users\17396\OneDrive OS=Windows_NT Path=C:\Program Files (x86)\PC Connectivity Solution\;F:\CTEX\GSview\gsview;F:\CTEX\WinEdt;C:\Compilers\MinGW\bin;C:\Compilers\Python;C:\Program Files\Java\jdk1.8.0_171\bin;C:\Databases\sqlite3;C:\Windows\System32;C:\Compilers\Python\Scripts;C:\Apache-Maven\apache-maven-3.5.3\bin;C:\Program Files\nodejs\;C:\Program Files\Git\cmd;C:\Windows\Microsoft.NET\Framework64\v4.0.30319;C:\Program Files\dotnet;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Compilers\Python\Lib\site-packages\django\bin;C:\Users\17396\AppData\Roaming\Python\Python36\Scripts;C:\Program Files\NVIDIA Corporation\NVIDIA NvDLISR;F:\Ruby24-x64\bin;C:\Users\17396\AppData\Local\Microsoft\WindowsApps;C:\Program Files\Microsoft VS Code\bin;C:\Users\17396\AppData\Local\atom\bin;C:\Users\17396\AppData\Local\Pandoc\;C:\texlive\2018\bin\win32;C:\Users\17396\AppData\Local\GitHubDesktop\bin;C:\Users\17396\AppData\Local\Programs\Microsoft VS Code\bin;C:\Users\17396\AppData\Roaming\npm;C:\Users\17396.dotnet\tools; PATHEXT=.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC;.RB;.RBW PROCESSOR_ARCHITECTURE=AMD64 PROCESSOR_IDENTIFIER=Intel64 Family 6 Model 158 Stepping 9, GenuineIntel PROCESSOR_LEVEL=6 PROCESSOR_REVISION=9e09 ProgramData=C:\ProgramData ProgramFiles=C:\Program Files ProgramFiles(x86)=C:\Program Files (x86) ProgramW6432=C:\Program Files PROMPT=$P$G PSModulePath=C:\Program Files\WindowsPowerShell\Modules;C:\Windows\system32\WindowsPowerShell\v1.0\Modules PUBLIC=C:\Users\Public SESSIONNAME=Console SystemDrive=C: SystemRoot=C:\Windows TEMP=F:\tmp TMP=F:\tmp USERDOMAIN=DESKTOP-O3JC923 USERDOMAIN_ROAMINGPROFILE=DESKTOP-O3JC923 USERNAME=17396 USERPROFILE=C:\Users\17396 VSCODE_CWD=C:\Users\17396\AppData\Local\Programs\Microsoft VS Code windir=C:\Windows TERM_PROGRAM=vscode TERM_PROGRAM_VERSION=1.29.1 LANG=en_US.UTF-8

I once installed a MikTex system called ctex and it cleared all my path in invironment varibles. I tried to restored by adding paths but maybe something was ignored. Maybe it has somthing to do with that?

it didnt work with 120s time out limit, still can't start omnisharp server

rchande commented 5 years ago

@Weaverzhu Can compare the output of where dotnet in a VS Code and non-VS Code compare command prompt? Somehow it's on your path outside VS Code but not in Code.

Weaverzhu commented 5 years ago

default cmd default powershell left is in vscode it seems that cmd output the path, but powershell output nothing... and by the way dotnet command works both in vscode and non-vscode cmd

gregg-miskelly commented 5 years ago

If you print out your path in VS Code, and in the command prompt (ex: echo %PATH%), what differences do you see?

gregg-miskelly commented 5 years ago

Also, have you installed the .NET SDK since the last time you rebooted? Occasionally we have seen cases where environment variable changes don't get propagated after the .NET SDK installs. So you might want to try rebooting if you haven't already.

Weaverzhu commented 5 years ago

vscode cmd prompt after type in "echo %path%"

C:\Program Files (x86)\PC Connectivity Solution\;F:\CTEX\GSview\gsview;F:\CTEX\WinEdt;C:\Compilers\MinGW\bin;C:\Compilers\Python;C:\Program Files\Java\jdk1.8.0_171\bin;C:\Databases\sqlite3;C:\Windows\System32;C:\Compilers\Python\Scripts;C:\Apache-Maven\apache-maven-3.5.3\bin;C:\Program Files\nodejs\;C:\Program Files\Git\cmd;C:\Windows\Microsoft.NET\Framework64\v4.0.30319;C:\Program Files\dotnet;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Compilers\Python\Lib\site-packages\django\bin;C:\Users\17396\AppData\Roaming\Python\Python36\Scripts;C:\Program Files\NVIDIA Corporation\NVIDIA NvDLISR;C:\Users\17396.vscode\extensions\ms-vscode.csharp-1.17.1.omnisharp\1.32.8;F:\Ruby24-x64\bin;C:\Users\17396\AppData\Local\Microsoft\WindowsApps;C:\Program Files\Microsoft VS Code\bin;C:\Users\17396\AppData\Local\atom\bin;C:\Users\17396\AppData\Local\Pandoc\;C:\texlive\2018\bin\win32;C:\Users\17396\AppData\Local\GitHubDesktop\bin;C:\Users\17396\AppData\Local\Programs\Microsoft VS Code\bin;C:\Users\17396\AppData\Roaming\npm;C:\Users\17396.dotnet\tools;

non-vscode

C:\Program Files (x86)\PC Connectivity Solution\;F:\CTEX\GSview\gsview;F:\CTEX\WinEdt;C:\Compilers\MinGW\bin;C:\Compiler s\Python;C:\Program Files\Java\jdk1.8.0_171\bin;C:\Databases\sqlite3;C:\Windows\System32;C:\Compilers\Python\Scripts;C:\ Apache-Maven\apache-maven-3.5.3\bin;C:\Program Files\nodejs\;C:\Program Files\Git\cmd;C:\Windows\Microsoft.NET\Framework 64\v4.0.30319;C:\Program Files\dotnet;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Compilers\Python\Lib\sit e-packages\django\bin;C:\Users\17396\AppData\Roaming\Python\Python36\Scripts;C:\Program Files\NVIDIA Corporation\NVIDIA NvDLISR;C:\Users\17396.vscode\extensions\ms-vscode.csharp-1.17.1.omnisharp\1.32.8;F:\Ruby24-x64\bin;C:\Users\17396\App Data\Local\Microsoft\WindowsApps;C:\Program Files\Microsoft VS Code\bin;C:\Users\17396\AppData\Local\atom\bin;C:\Users\1 7396\AppData\Local\Pandoc\;C:\texlive\2018\bin\win32;C:\Users\17396\AppData\Local\GitHubDesktop\bin;C:\Users\17396\AppDa ta\Local\Programs\Microsoft VS Code\bin;C:\Users\17396\AppData\Roaming\npm;C:\Users\17396.dotnet\tools;

it seems that dotnet path has been written in path in both cmd prompt

Weaverzhu commented 5 years ago

Just now I installed the latest .net core sdk v2.2 and reboot at once, still no use...

gregg-miskelly commented 5 years ago

Thanks @Weaverzhu. To make sure we are talking about the same issue, your initial issue description talked about two different problems -- a timeout in OmniSharp, and an error about debugging not being able to find the .NET Core CLI (see image). Are you still experiencing the second problem?

default

Weaverzhu commented 5 years ago

yes, the problems are still the same

rchande commented 5 years ago

@Weaverzhu Can you include your full omnisharp log? Thanks!

Weaverzhu commented 5 years ago

Starting OmniSharp server at 12/18/2018, 8:40:05 PM Target: c:\CODING\c#

OmniSharp server started. Path: C:\Users\17396.vscode\extensions\ms-vscode.csharp-1.17.1.omnisharp\1.32.8\OmniSharp.exe PID: 22112

Error: Can't print exception string because Exception.ToString() failed. default

rchande commented 5 years ago

@Weaverzhu That's interesting. The omnisharp server started and PID log comes from the TypeScript part of the C# extension before it starts the OmniSharp process. Something's going wrong very early in the startup of that process, such that it can't do any logging...

zhongzepeng commented 5 years ago

I also have this situation, when switching git branch, restart vscode will solve