Intellisense not automatically working VSCode
Asked Answered
I

34

113

I just downloaded Visual Studio Code and my Intellisense is not automatically working.

The two settings that control this seem to be set correctly:

"editor.quickSuggestions": true,
"editor.suggestOnTriggerCharacters": true,

I do get an Intellisense menu when i start typing and press "CTRL + Space", but this gives me a list of everything and not things specifically for my object.

What am i doing wrong?

Illimani answered 30/4, 2015 at 18:31 Comment(6)
Do you know what the "trigger characters" are?Grande
I'm assuming it is . for most languages.Illimani
The final solution for me was doing a downgrade of the extension, to do that follow this link: tpodolak.com/blog/2017/04/09/… trust me !Strawn
I have the same issue like you but in python. ^space ends up showing a giant list, completely unrelated to the code I'm trying to get suggestions from. How did you solve it?Scalariform
Those with this problem may need to clear out their VSCode cache folder. See here: https://mcmap.net/q/195692/-visual-studio-code-gives-me-quot-include-error-detected-quot-for-cToro
marketplace.visualstudio.com/…Dellora
C
103

Visual Studio Code's more advanced editing features (IntelliSense, refactoring tools, etc.) only work in C# files if you have a project.json file or *.sln file that VSCode is aware of. Open the folder (i.e. open the File menu and click Open Folder...) with the *.sln file or project.json and VSCode will attempt to find all project/solution files in the folder. If there are multiple projects, you may need to select one from the projects button on the right side of the status bar (bottom of the window).

From the VSCode website:

  • Selecting a project.json-file is opening a DNX-project and VSCode will load that project plus the referenced projects
  • Selecting a *.sln-file is opening a MSBuild-project. It will load the referenced *.csproj-projects and sibling or descendant project.json-files but no other project files that are referenced from the solution file.
  • Selecting a folder will make VSCode scan for *.sln and project.json files and VSCode will attempt to load them all.

enter image description here

Cultrate answered 1/5, 2015 at 0:0 Comment(11)
I have a project containing a .sln file, but IntelliSense still doesn't show up....Uranian
I am opening a folder just like the video shows, but IntelliSense is not working on either Windows or Mac. I have many .sln files, but no project.json files.Wavy
The project selection button has moved to the right side of the status bar now.Gerick
Make sure you explicitly add the project to the sln using 'dotnet sln add'. If you have projects in the dir but not sln they will not work with IntelliSense.Afroamerican
How can I create project.json file ? I do not see neither project.json not *.sln file in solution directory.Liew
@Cultrate I have the same problem but project button does not exist.Skedaddle
to create a solution file use this command dotnet new sln The result will be a solution file witht a time matching your directory nameGeary
I have the same issue as the OP but in python. ^space ends up showing a giant list, completely unrelated to the code I'm trying to get suggestions from.Scalariform
After running dotnet new sln, you can add your project files using dotnet sln if they already exist. learn.microsoft.com/en-us/dotnet/core/tools/dotnet-slnKaunas
I don't know if this is true about all the IntelliSense extensions, but the C# / OmniSharp extension will crash if somewhere in the directory tree underneath the open folder there exists a folder which the user does not have permissions to read. That may be an unusual circumstance, but it's one I just ran into, and it took me a while to figure out why I couldn't get IntelliSense suggestions on this one project while it still worked for others.Hitt
If you have a project without project.json or *.sln you can make Omnisharp work with Ctrl + P --> Omnisharp: Select project.Agulhas
H
132

If you have a workspace and for some reason have multiple folders you may need to 'help' omnisharp a bit. I initially had a big project and added a solution for it further on - ending up with TWO workspace folders (one to a startup project and one to the solution). After composing that setup I experienced only the first project to have intellisense working.

Solution to get intellisense working was to make sure omnisharp worked its way from the solution instead of the project:

  1. Ctrl + Shift + p
  2. Write "OmniSharp: Select Project" and press Enter.
  3. Choose the solution workspace entry.

Inspiration gotten from 'swaner': https://github.com/OmniSharp/omnisharp-vscode/issues/1889

Harley answered 16/10, 2019 at 9:54 Comment(1)
This also works when you create a project without Visual Studio with just dotnet new console. In this case the VSCode plugin allows you to select the *.csproj file.Agulhas
C
103

Visual Studio Code's more advanced editing features (IntelliSense, refactoring tools, etc.) only work in C# files if you have a project.json file or *.sln file that VSCode is aware of. Open the folder (i.e. open the File menu and click Open Folder...) with the *.sln file or project.json and VSCode will attempt to find all project/solution files in the folder. If there are multiple projects, you may need to select one from the projects button on the right side of the status bar (bottom of the window).

From the VSCode website:

  • Selecting a project.json-file is opening a DNX-project and VSCode will load that project plus the referenced projects
  • Selecting a *.sln-file is opening a MSBuild-project. It will load the referenced *.csproj-projects and sibling or descendant project.json-files but no other project files that are referenced from the solution file.
  • Selecting a folder will make VSCode scan for *.sln and project.json files and VSCode will attempt to load them all.

enter image description here

Cultrate answered 1/5, 2015 at 0:0 Comment(11)
I have a project containing a .sln file, but IntelliSense still doesn't show up....Uranian
I am opening a folder just like the video shows, but IntelliSense is not working on either Windows or Mac. I have many .sln files, but no project.json files.Wavy
The project selection button has moved to the right side of the status bar now.Gerick
Make sure you explicitly add the project to the sln using 'dotnet sln add'. If you have projects in the dir but not sln they will not work with IntelliSense.Afroamerican
How can I create project.json file ? I do not see neither project.json not *.sln file in solution directory.Liew
@Cultrate I have the same problem but project button does not exist.Skedaddle
to create a solution file use this command dotnet new sln The result will be a solution file witht a time matching your directory nameGeary
I have the same issue as the OP but in python. ^space ends up showing a giant list, completely unrelated to the code I'm trying to get suggestions from.Scalariform
After running dotnet new sln, you can add your project files using dotnet sln if they already exist. learn.microsoft.com/en-us/dotnet/core/tools/dotnet-slnKaunas
I don't know if this is true about all the IntelliSense extensions, but the C# / OmniSharp extension will crash if somewhere in the directory tree underneath the open folder there exists a folder which the user does not have permissions to read. That may be an unusual circumstance, but it's one I just ran into, and it took me a while to figure out why I couldn't get IntelliSense suggestions on this one project while it still worked for others.Hitt
If you have a project without project.json or *.sln you can make Omnisharp work with Ctrl + P --> Omnisharp: Select project.Agulhas
D
29

If you are start your project with c#, then some time you haven't download extension.

Process by written

  • Ctrl + Shift + p.
  • Write "OmniSharp: Select Project" and press Enter.
  • Choose the solution workspace entry.
  • Then enable the c# extension for "OmniSharp : Project".

Process by image

enter image description here

enter image description here

Danella answered 21/8, 2021 at 13:48 Comment(0)
T
15

Downgrading to 1.23.9 of the C# VS Code extension fixed the intellisense for me. So if nothing else is working for you, perhaps try installing an older version of the extension (doesn't necessarily have to be that exact one I mentioned). You can do this by selecting this option in VS Code: enter image description here

Tribadism answered 30/7, 2021 at 1:44 Comment(0)
C
8

As of the 0.5 version I have found that I need to close and re-open my working files to get some new intellisense information to start working for my own files. This usually happens after I have a file open that needs to use type information from another file I just created. Until I close and re-open them (within the editor) the intellisense doesn't always work.

Hopefully this is something that'll get fixed as the app matures.

Capital answered 17/7, 2015 at 11:38 Comment(4)
Have you ever come across a cmd to perform this manually(without shutdown)?Helldiver
No, and I don't recall the last time I needed to jump through this particular hoop honestly.Capital
Alternatively, you can restart Omnisharp (Omnisharp: Restart OmniSharp from the command palette)Matrona
Thanks @Mojtaba! the green flame icon is OmniSharp but didn't have a *.sln filename next to it until I did Command palette > OmniSharp: Select Project, because I had renamed my project's folder and it was using the oldfilename.sln, so I selected newname.sln, which fixes it so that typing Debug. shows Log as a tooltip intellisense nowRetiring
T
4

Inorder to make the intelligence working, the Visual Studio Code extension OmniSharp should be there along with Mono. When you open a project/solution folder, the OmniSharp gets the project dependencies from either project.json or from the dotnet solution file (if the project/solution created with other versions of visual studio).

So, when you look at the omnisharp's output window after immediately opening the project/ solution folder, you may see the following lines

Starting OmniSharp server at 2017-9-18 09:26:44
    Target: /Users/{username}/Source/{Your Solution Folder}/{Your Solution
file}.sln

OmniSharp server started wth Mono
    Path: /Users/{username}/.vscode/extensions/ms-vscode.csharp-1.12.1/.omnisharp/run
    PID: 5808

post that, you may see couple of lines coming up like below,

[info]: OmniSharp.MSBuild.MSBuildProjectSystem
        Update project: {Your Project1 Name}
[info]: OmniSharp.MSBuild.MSBuildProjectSystem
        Update project: {Your Project2 Name} 
....

they mean that your projects are getting recognised by OmniSharp Extension.

If you get any error message informing you about timeout, please get into the settings of the Visual Studio Code, and add a configuration override like the one below:

  "omnisharp.projectLoadTimeout": 200

I know it is too long to wait for 200 seconds. But don't worry, this won't stop you anymore working with project files. But, remember that the IntelliSense will be automatically available once all the projects in the folder are successfully loaded.

Feel free to extend the Timeout setting since it will help you getting intellisense even-though you are not getting it immediately.

Here is another link with the same solution: https://github.com/OmniSharp/omnisharp-vscode/issues/1585

Hope my information helps you! Enjoy your VSCode!

Tierratiersten answered 18/9, 2017 at 5:3 Comment(0)
K
4

This case was for an existing project that was working fine before. Opened via the vs code "recent" history.

For dotnet core. I opened my project's *.csprog file, made no changes, and saved it via the vs code editor.

As soon as I saved, all of the intellisense stuff starting working again in my other files within that project.

Karalynn answered 12/6, 2019 at 13:26 Comment(0)
B
3

Another troubleshooting strategy to try if none of the above works out is uninstalling Mono, which is unnecessary anyways if you're using .NET Core. I also experienced a sudden disappearance of Intellisense after pulling changes to one of our enterprise repos that included an upgrade from ASP.NET Core 2.0 to 2.1. Strangely, at the same time, Intellisense was working fine in another C# project repo running ASP.NET Core 2.2.

For the project in question, I was puzzled to see successful logs for each reboot of the Omnisharp server as well as perfectly clean builds and runs. The puzzlement increased as I compared these Omnisharp logs to those from the 2.2 project and found them effectively identical.

Upon uninstalling Mono, the one detail that changed is how Omnisharp started. Now it boots up from a shell script located at ~/.vscode/extensions/ms-vscode.csharp-1.19.0/.omnisharp/1.32.18/run. Previously, Mono itself was booting the server from the executable at ~/.vscode/extensions/ms-vscode.csharp-1.19.0/.omnisharp/1.32.18/omnisharp/Omnisharp.exe.

Other troubleshooting I attempted in this instance though to no avail:

  • dotnet clean / Deleting bin and obj directories
  • Updating launch.json to point at the proper /bin/Debug/netcoreapp2.1 build directory
  • Wiping my local nuget cache
  • Restarting Omnisharp
  • Uninstalling and reinstalling VS Code, as well as bumping back a version from 1.33.1 as the breakage coincided oddly with the March 2019 update
  • Uninstalling and reinstalling the C# VS Code extension, as well as bumping back a version from 1.19.0 given other users' reports of said version interfering with Intellisense for certain projects*
  • Adding a global.json file at project root to override default utilization of latest .NET Core SDK (mine was 2.2.105) and run instead using 2.1.302 in concert with the project's version
  • Wiping/rebuilding the project .sln file

Specs: VS Code 1.33.1, C# Extension 1.19.0, MacOS High Sierra 10.13.6.


*NB: As it turns out, in another .NET Core 2.1 project with the same issues in VS Code as described above, uninstalling Mono alone did not fix things. I also did wind up needing to bump back the C# extension to v. 1.18.0 to recover Intellisense. Weird.

Bailar answered 18/4, 2019 at 17:57 Comment(0)
A
3

The issue I had was OmniSharp was an older version. I set the flag to update to latest version in Settings.json file. This ensures the extension is always the latest version.

"omnisharp.path": "latest"

And restarted VS code. That fixed it for me.

Arraignment answered 12/1, 2021 at 9:25 Comment(0)
A
2

I've had some good experiences in C# with this extension so far: https://marketplace.visualstudio.com/items?itemName=jchannon.csharpextensions

This extension traverses up the folder tree to find the project.json or *.csproj and uses that as the parent folder to determine namespaces.

Altercation answered 13/6, 2017 at 22:27 Comment(1)
seems no longer supportedScreening
M
2

Simply reinstall the extension and restart the VSCode/PC.

Methodical answered 16/1, 2021 at 19:38 Comment(0)
R
2

I use Task Manager and kill the Visual Studio Code process, then restart Visual Studio Code, the intellisense shows and fixed.

Raila answered 16/5, 2021 at 3:32 Comment(0)
R
1

Try "Install Extension" from command Pallete - probably if C# intellisense is not there:

enter image description here

https://code.visualstudio.com/docs/customization/colorizer

Retroflex answered 27/4, 2016 at 13:21 Comment(0)
K
1

if intellisense in not working for react js or javascript or node js this solution will help for windows

  1. uninistall type script by typing npm uninstall -g typescript
  2. install specific version of type script that is 3.3 by typing npm install -g [email protected]
  3. add the typescript location in vscode by navigating to file > Preferences > settings > here search for edit in setting.json then add this path "typescript.tsdk": "/Users/yourusename/AppData/Roaming/npm/node_modules/typescript/lib"
  4. settings.json should look someting like this
{
"editor.suggestSelection": "first", 
   "vsintellicode.modify.editor.suggestSelection":"automaticallyOverrodeDefaultValue",
"typescript.tsdk": "/Users/yourusername/AppData/Roaming/npm/node_modules/typescript/lib"
}
Kreegar answered 3/2, 2020 at 7:7 Comment(0)
R
1

I was able to fix this by changing the Api Compatibility Level from .Net Standard 2.0 to .NT 4.x. You can find this setting on Project Settings / Player. After that, intellisense started working again. enter image description here

Regenerative answered 20/8, 2020 at 10:27 Comment(0)
P
1

This is because of C# extension issue. Reinstall the extension will work.

https://code.visualstudio.com/docs/editor/intellisense

https://marketplace.visualstudio.com/items?itemName=ms-dotnettools.csharp

Plaintiff answered 7/12, 2020 at 3:10 Comment(0)
D
1

I fixed this with a multiple project solution in .net5 / .net core 3.1 by opening each project (not the sln folder) in VSCODE. This then prompts to add the resources/ .CSX? files to the project; enabling intellisense, per project. Finally close that window and reopen the solution folder and all works as expected.

See image Add VSCode assets

Despond answered 28/8, 2021 at 20:44 Comment(0)
I
1

I fixed this by installing .NET Framework 4.7.1 Developer Pack:

https://dotnet.microsoft.com/en-us/download/dotnet-framework/net471

Impatiens answered 30/1, 2022 at 3:25 Comment(1)
Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.Carnatic
B
1

Downgrading to 1.23.9 of C# for Visual Studio Code (powered by OmniSharp). https://i.stack.imgur.com/VrdJl.png

Bovill answered 3/6, 2022 at 9:42 Comment(1)
As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.Carnatic
H
0

After trying several things I looked at the OmniSharp logs only to realize that because I had two different sln files in my workspace. It had picked up the “other” one and thus wasn’t working. I deleted it, reopened vs code, and all is well again.

Houdini answered 23/7, 2019 at 13:26 Comment(0)
T
0

For me I had been working without internet for a long time. It had previously been working but then stopped. I closed+reopened VSCode with a stable wifi connection and the Output tab in VSCode popped up, displaying the the extensions were re-installing. After that it worked!

Testamentary answered 26/7, 2019 at 16:7 Comment(0)
H
0

in my case , the extension wasn't enabled

Homeostasis answered 29/11, 2019 at 15:43 Comment(4)
Please, could you elaborate on your answer? For example, how you did to enable the extension?Elspeth
File->Preferences->Extensions A side panel will open up with the list of extensions. There is "enabled","disabled" and "recommanded". Click the "disabled" tab and click on the c# extension. and then "enable"Homeostasis
I use react-native for development as well and to make it work with flow I had to disable the default language features, and when I started with node the IntelliSense was not working because of this. Thanks a lot for pointing it out !!Nozzle
which extension you even talk of?Telemark
E
0

I just had this happen (this being no code completion suggestions appearing). What resolved it for me was changing the VSCode Editor package in Unity to a previous version and then back to the current version.

For me, this was going from 1.2.0 to 1.1.3 and then back to 1.2.0. I believe removing and reinstalling 1.2.0 would have accomplished the same.

Window > Package Manager > Visual Studio Code Editor

Electroshock answered 8/5, 2020 at 21:12 Comment(0)
M
0

I know this is probably the most obvious answer. But I had enough dealing with VS Code ridiculous bugs. You should be focusing on code, not the buggy IDE. Their documentation doesn't make it easy either to debug.

Steps for complete uninstallation:

  1. Save your personalization files such as keybindings.json,

Just put it on GitHub or something so whenever you need have trouble with VS Code you simply just need to go to GitHub and copy-paste it.

  1. Uninstall VS Code completely

When you uninstalled VS Code, it doesn't erase your extension files and some old settings. This is the cause of the re-installation ended up the same. Horrible move VS Code. For the list of the files that you must delete, you can check out this answer.

  1. Go to their website and install the new one.

I hope this helps some people who are already had enough with the VS Code ridiculous bug.

Minaminabe answered 6/6, 2020 at 10:33 Comment(0)
A
0

In my case, the issue was not with VS Code settings. The error was due to a corrupted TEMP path configured in my PC's registry user profile environment settings. I got this error from Help --> Toggle Developer Tools --> Console The error was flagged in the console when I opened a new typescript file.

Unable to write file c:\Users\XXX\AppData\Local\Temp;C:\wamp64\bin\php\php5.6.25;C:\vufind-3.1.2\install.php\09cf49d8-af5b-42e9-8194-43f5b566be0f'

Obviously this path was corrupted. After updating the environment variables in registry settings, the VS code IntelliSense started working. Checking the console is a good start to find the root cause of this issue.

Alister answered 3/7, 2020 at 6:15 Comment(0)
A
0

Earlier intellisense was working for Angular in VS-Code but for some reason (which I don't know) intellisense stopped working. I had extensions installed i.e. Angular Essentials and Angular Language Service etc. that were responsible for this intellisense and all that.

What I did?

I disabled the extensions, restarted VS Code and enabled them. It was all working fine as before.

Arvie answered 17/2, 2021 at 11:14 Comment(0)
H
0

Download and install "Tool for Visual Studio 2019" as the C# extension under hood use the build tools: https://visualstudio.microsoft.com/downloads/

Hubbell answered 19/6, 2021 at 14:33 Comment(0)
D
0

In my case, I had an extension installed (Explorer Exclude) to help me focus and hide certain files that I don't regularly work with within the Explorer.

I so happened to have disabled viewing *.sln, *.csproj and *.vsconfig files and folders, which apparently prevents VSCode from even knowing the file is there in the first place. Disabling these specific rules solved the problem instantly.

Took me ages to figure out... The more you know.

Dubiety answered 30/6, 2021 at 20:21 Comment(0)
B
0

I solved it by uninstalling all SDK's (not sure if this is needed) and installed 4.7.1 developer pack

win 10, vscode 1.63.2, unity 2020.3.25f1

Bespeak answered 27/12, 2021 at 16:44 Comment(0)
S
0

Wow, so many answers... and some of them are very old... but lots of clues to help fix things :)

As of Dec 2022, here's what worked for me, for using Unity:

  • everything does indeed hinge on the "C# for Visual Studio Code (powered by OmniSharp)" plugin
  • however, rather than downgrading to 1.23.9, what I did was, following the instructions in the main page:
    • in the settings, uncheck 'Omnisharp: Use Modern Net' enter image description here
    • follow the instructions to download and install Mono
    • restarted by VSC a couple of times
    • => Unity autocomplete started working :)
Screening answered 9/12, 2022 at 12:39 Comment(0)
E
0

To fix this, I had to go on Unity to "Preferences" then in "External tools" tab.

For the "External Script Editor", "Visual Studio Code" was already selected.

I clicked on "Reset argument", then for "Generate .csproj files for:" nothing was selected. Then I clicked on "Regenerate project files".

Then I reloaded VS Code and Intellisense was working.

Ebba answered 1/2, 2023 at 20:33 Comment(0)
R
0

So many answers and none have helped me. After uninstalling the C# extension and opening a C# script, I was advised to install the C# extension "C# for Visual Studio Code (powered by OmniSharp)". After the installation I was informed that .NET 7.0 SDK is missing. After the installation the autocomplition worked for me.

Link: https://dotnet.microsoft.com/en-us/download/dotnet/thank-you/sdk-7.0.200-windows-x64-installer?journey=vs-code

I hope this will help some of you.

Razee answered 15/2, 2023 at 11:1 Comment(0)
Z
-1

Clearing typescript cache and downgrading the typescript version to 3.3 solved the issue for me.

Follow these steps to clear cache and downgrade typescript version:

  1. Enter following command in terminal according to your OS and delete whatever is inside it.
  • Mac: ~/Library/Caches/TypeScript/
  • Windows: %LOCALAPPDATA%\Microsoft\TypeScript\ (windows users can run this in run box too)
  • Linux: ~/.cache/typescript/
  1. Install this specific @[email protected] using following command.
  1. Restart VSCode.
Zapata answered 26/1, 2020 at 19:3 Comment(0)
M
-1

If everything in VSCode is working ( No errors in output console, language server is working etc.) and built-in extensions are enabled. Still, if your IntelliSense is not working for normal .js files make sure variables are defined with a type identifier such as var d = new Date() or let d = new Date(). In my case, IntelliSense was not working for d = new Date() (No autocomplete for Date object 'd' APIs in this way) but started working fine when I specified a type before my variable names.

Mansoor answered 15/6, 2021 at 14:1 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.