2023-12-16

Troubleshooting C# Autocompletion Issues in VSCode

Table of Contents

Sudden disaster on C# intellisense troublle

The disasters that occur once or twice a year when updating vscode automatically are usually triggered by major updates to .Net. Due to the low frequency, it’s always a nerve-wracking experience.

The error that occurred this time is as follows.

Activating C# + C# Dev Kit + C# IntelliCode...
waiting for named pipe information from server...
[Error - 8:34:02 PM] Microsoft.CodeAnalysis.LanguageServer client: couldn't create connection to server.
Error: Timeout. Named pipe information not received from server.
	at q.<anonymous> (c:\Users\imosan\.vscode\extensions\ms-dotnettools.csharp-2.14.8-win32-x64\dist\extension.js:2:1290527)
	at Generator.next (<anonymous>)
	at s (c:\Users\imosan\.vscode\extensions\ms-dotnettools.csharp-2.14.8-win32-x64\dist\extension.js:2:1280557)

Unable to complete or jump, for example, when there is a disaster that occurs once or twice a year automatically updating Visual Studio Code. This issue has already been reported, and a fix will likely be released eventually.

Link to reported issue

However, as this problem occurs with each .NET update, it’s essential to be prepared for the possibility of it happening again.

While it might seem like simply installing the latest .NET and Visual Studio and regenerating .csproj and .sln files fixes the issue, there’s no mystical solution. It’s just that the extension’s bug gets inadvertently resolved with a few updates.

To address this more definitively, the following steps can be taken:

  • Disable automatic updates for Visual Studio Code.
  • Disable automatic updates for extensions.
  • Roll back the version of the C# extension to 1.26.0 (do not use version 2.x).
  • Check if Omnisharp is set to Auto Start

By following four three steps, code completion and jumping should be restored. This process doesn’t impact the functionality of the Unity debugger.

The assumed environment is as follows.

vscode 1.85.1


Version: 1.85.1 (user setup)
Commit: 0ee08df0cf4527e40edc9aa28f4b5bd38bbff2b2
Date: 2023-12-13T09:49:37.021Z
Electron: 25.9.7
ElectronBuildId: 25551756
Chromium: 114.0.5735.289
Node.js: 18.15.0
V8: 11.4.183.29-electron.0
OS: Windows_NT x64 10.0.22635

extensions:


C# 2.14.8
C# Dev Kit 1.1.16
IntelliCode for C# Dev Kit v0.1.26
Unity 0.9.3

If the above four are already installed, it’s advisable to uninstall all of them before proceeding with the following steps.

Disable automatic updates for Visual Studio Code

Open File -> Preferences -> Settings, search for update, and set Update: Mode (Applies to all profiles) to None as shown in the screenshot below.

Restart VSCode when prompted.

Disable automatic updates for extensions

Change Extensions: Auto Update: (Applies to all profiles) to None.

Roll back the version of the C# extension to 1.26.0 (do not use version 2.x)

When installing the Unity extension, the following are automatically installed simultaneously. Search and install them by searching for “Unity” in EXTENSIONS:

  • C#
  • C# Dev Kit 1.1.16
  • IntelliCode for C# Dev Kit v0.1.26
  • Unity

Extensions are always installed with the latest version, so here we lower the version only for “C#” after installation. This enables both auto-completion and jumping to definition.

As of the current date (December 16, 2023), in vscode, the latest version of the extension has a dropdown menu in “Uninstall,” so you can choose “Install Another Version…” to select a specific version.

You can choose it by right-click menu.

Finally, choose the most recent version of 1.x.x from the displayed list, which is the latest version other than 2.x.x. In other words, install 1.26.0.

Check if Omnisharp is set to Auto Start

Open File -> Preferences -> Settings, search for omnisharp, and turn Omnisharp: Auto Start on as shown in the screenshot below.

After that, simply press Reload as shown in the C# extension, or restart vscode, and the autocompletion feature should be restored.

After restarting, you might see a message saying, “The C# Dev Kit extension requires version 2.0.0 or greater of the C# (ms-dotnettools.csharp) extension. Please upgrade.” However, you can ignore this message until a bug fix is released for the “C#” extension.