Visual Studio Code Intellisense stopped to work on C# files

纵饮孤独 提交于 2020-01-04 09:36:29

问题


I realized that I can't use ctrl + . shortcut to import other C# classes. This shortcut works just fine for other file types like typescript.

I have uninstalled and installed back again. I also installed old version of VS code too. But nothing worked.

As I shown above, there is no import feature shows up when I do ctrl + .. Those are only the choices I was given. It's fine using without it but it's also annoying to import those files manually typed.


回答1:


The C# language features in VS Code are provided by a service called Omnisharp.

A couple of things you could try:

  • Restart Omnisharp (Omnisharp: Restart OmniSharp from the command pallette (ctrl + shift p on windows) )
  • check for errors in the Omnisharp log (ctrl + ' to bring up output pane then select output window then Omnisharp Log from the dropdown)
  • Enable debugger logging in Omnisharp



回答2:


Have you tried clearing out Visual Studio cache by any chance? Make sure Visual Studio is closed before attempting this. It is typically located at: C:\Users\Your User Name\AppData\Local\Microsoft\VisualStudio\

This cache could easily get corrupted and usually doesn't get cleared between re-installations.

Also, if previous doesn't work, try clearing temp directory as well - C:\Users\Your user name\AppData\Local\Temp

Few more additions to check

  • Check if Keyboard layout settings in Tools-> Options -> Environment -> Keyboard is set to Visual C# 2005

  • Check for IntelliSense settings in Tools -> Options -> Text Editor -> C# -> Formatting, for anything that may have caused the defaults to change

Hope this helps!




回答3:


I faced into a similar situation. In My case I had several .csproj files and one solution file. Make sure to add all .csproj file to .sln file.

dotnet sln add <.csproj file path>.

Make sure to restart omnisharp. In Mac -> (command + shift + p => select Omnisharp: Restart OmniSharp)



来源:https://stackoverflow.com/questions/48527394/visual-studio-code-intellisense-stopped-to-work-on-c-sharp-files

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!