I'm using VSCode 1.19 and trying to "Go>Go to definition" in a C# file like in Visual Studio and it does nothing. In a .js file it works well and i'm guessing if there is some workaround this.
-
Is [OmniSharp](https://github.com/OmniSharp/omnisharp-vscode) installed? – boop_the_snoot Dec 27 '17 at 16:28
-
I think it is not installed since I'm getting this: https://i.stack.imgur.com/BAt9o.png. I'm also having trouble debugging which makes sense by the looks of this error. – Hiero De Paula Dec 28 '17 at 12:43
-
Check if you have proper rights to C; drive. Also if you are behind a proxy, you'll need to bypass it – boop_the_snoot Dec 28 '17 at 12:54
-
I can't do much about this since I can't manage rights or connections on my workstation, is there a way do to it manually? – Hiero De Paula Dec 28 '17 at 13:01
-
1Apart from rights you can manually bypass proxy by adding `"http.proxy": "http://username:password@ipaddress:port"` in your VSCode user settings. Replace username, password, ipaddress and port according to the authentication you have been provided with for your account. If your password contains `@` add username@password inside qoutes – boop_the_snoot Dec 28 '17 at 13:49
-
I've tried restarting OmniSharp, reopening the project, making sure I was opening the correct solution in the folder and reinstalling the extension. Nothing worked. Even on new projects it was broken. The only thing that worked was deleting ~/.vscode and ~/.config/Code and reinstalling vs code – galmeida Nov 05 '21 at 06:01
-
I had the same issue. tried all the solutions online. nothing happened. Then I noticed after changing the git active repository to master all the problems were gone. Hope this will help someone. – wajira000 Jun 21 '22 at 13:12
11 Answers
There may be multiple "projects" in the folder and VSCode has selected the "wrong" one. (in VSCode terms "project" means the sln file)
Use ctrl-shift-P and select OmniSharp: Select Project
to select the correct project (a .sln
file).
If you have the Output window open with "OmniSharp Logs" selected, you will see it reading your csproj's. Once finished your goto definition will start to work

- 2,534
- 1
- 28
- 25

- 2,762
- 20
- 23
-
1This worked for me! My selected project was another .sln in the same workspace folder. – Aaron Jordan Aug 02 '18 at 19:49
-
7You can restart the OmniSharp server to force it reload the solution & all the projects. Ctrl + Shift + P and Select "OmniSharp: Restart OmniSharp" [https://github.com/Microsoft/vscode/issues/3707](https://github.com/Microsoft/vscode/issues/3707) – Naren Feb 04 '19 at 12:30
-
2"project" in this case means the sln. If you have more than one in the root it can choose the "wrong" one to load the csproj's from. Just restarting omni doesn't help in this case as it'll just choose the wrong sln again. You have to tell it which sln to start with. – AndyPook Feb 04 '19 at 12:38
-
1Thanks so much for this. I was having this issue using submodules (which have sln files) I've restarted, reinstalled, and never even knew about this feature. – Mark McGookin Apr 02 '19 at 09:59
As written in the comments for @AndyPook's answer, another possible solution is to just restart OmniSharp.
CTRL + SHIFT + P -> OmniSharp: Restart OmniSharp

- 1,453
- 1
- 18
- 25
Fix: When multiple solutions in same folder
This answer is visual version of @AndyPook's answer.
1. Crtl+Shift+P
2. Search >OmniSharp
3. Choose option
Select Project
4. It will show all the list of solutions in your folder. select the correct e.g:
5. Verify it by looking into OmniSharp Logs

- 4,079
- 2
- 33
- 25
"Go to definition" was working for me for a long time, but recently stopped working. My solution was:
- Go to Extensions
- Find the C# extension (version 1.25.0 in my case)
- Click the cogwheel
- Select "Install Another Version..."
- Select one of the previous versions (version 1.24.4 fixed the problem for me)
- Press "Reload Required" when the selected version has been installed
EDIT: It is better to follow Kyle Challis' suggestions!

- 139
- 1
- 4
-
3Thank you! Apparently this was by design: https://github.com/OmniSharp/omnisharp-vscode/issues/5245 https://github.com/OmniSharp/omnisharp-vscode/issues/5120 – Kyle Challis Jun 14 '22 at 06:31
For anyone using the C# extension and coming here after May 24, 2022: version 1.25.0 of the extension disabled support for a few things
You can follow instructions at that link to get it working with 1.25.0, or you can rollback to version 1.24.4, per GeirS' answer

- 981
- 2
- 12
- 28
I resolved by
- check error on omnisharp log omnisharp log
OniSharp Error: Found dotnet version 5.0.201. Minimum required version is 6.0.100
- set "omnisharp.useModernNet": false on C# extension user/workspace
- open source code folder and reload vscode

- 31
- 2
-
2Just installing the corresponding .NET SDK will resolve the problem as well. – Vidyesh Jun 14 '22 at 10:01
I had the same problem, but with a TypeScript project folder. The solution was to simply reopen the folder.

- 19,223
- 13
- 68
- 84
I know that I am late to this thread, but restarting omnisharp did not fix this problem for me. What did fix the problem was running 'dotnet restore' and opening the project folder again.

- 307
- 2
- 10
I had the same problem in VSCode (multiple projects Web API and Angular MVC) and resolved by creating a new sln
file. Please do the following steps:
Step 1: Create the project sln
file. ( ex: MyApp.sln
)
Step 2: Open the sln
file and paste this code:
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.26124.0
MinimumVisualStudioVersion = 15.0.26124.0
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MyApp", "MyApp\MyApp.csproj", "{BC407A9C-4BD2-4086-9862-6E5A547D1DD8}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|Any CPU = Release|Any CPU
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{BC407A9C-4BD2-4086-9862-6E5A547D1DD8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{BC407A9C-4BD2-4086-9862-6E5A547D1DD8}.Debug|Any CPU.Build.0 = Debug|Any CPU
{BC407A9C-4BD2-4086-9862-6E5A547D1DD8}.Debug|x64.ActiveCfg = Debug|Any CPU
{BC407A9C-4BD2-4086-9862-6E5A547D1DD8}.Debug|x64.Build.0 = Debug|Any CPU
{BC407A9C-4BD2-4086-9862-6E5A547D1DD8}.Debug|x86.ActiveCfg = Debug|Any CPU
{BC407A9C-4BD2-4086-9862-6E5A547D1DD8}.Debug|x86.Build.0 = Debug|Any CPU
{BC407A9C-4BD2-4086-9862-6E5A547D1DD8}.Release|Any CPU.ActiveCfg = Release|Any CPU
{BC407A9C-4BD2-4086-9862-6E5A547D1DD8}.Release|Any CPU.Build.0 = Release|Any CPU
{BC407A9C-4BD2-4086-9862-6E5A547D1DD8}.Release|x64.ActiveCfg = Release|Any CPU
{BC407A9C-4BD2-4086-9862-6E5A547D1DD8}.Release|x64.Build.0 = Release|Any CPU
{BC407A9C-4BD2-4086-9862-6E5A547D1DD8}.Release|x86.ActiveCfg = Release|Any CPU
{BC407A9C-4BD2-4086-9862-6E5A547D1DD8}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal
Step 3: Crtl+Shift+P to switch on the project.

- 19
- 3
Try Using Shift+Fn+F12 if all required extension are installed depends on your system config

- 11
- 3
-
1"Fn" can mean different things. It can activate or deactivate the F-keys. So I guess it activates them for you. – csabinho Mar 27 '22 at 17:57
I face same probleam today, try to move my self from Visual Studiod to Code, As My porject is Microservie based , i have multiple Solution and repos with respect to each microservice , for make CI/CD simple, Now where the VS code Feature of Multipel Root Work Space helping me, So please follow below step if you are Setting up VS Code from professional developement prospect as c# developer,
- Install Node.js,
- Install NPM.
- Install .net Core
- Install git.(it can be other scm as well )
- Now Install VS Code,
- Install OMNI Sharp C# extension, this will help you in debug as well provide intllisence and provide feature like Go To Defination feature(it have one limittation at time it can run only on one solution even you have multi root workspace, I think they keep it like that way to keep the thing light weight ,to switch between multiple solution in such case you have to use switch project option.
)
- two more good extension i like is
- C# IDE(help you with few new nice template to create a Class File,Inferface option, the one i like is , when you create costructor and pull parameter show suggestion to create filed or proeperty for them just by Ctrl+.)
- Git History to Check Git History.
- Multiple Teriminal is also nice feature as i have to run to many services at development time.
- You Can Setup launch.setting for each indivisual project required for debug(if donot want to do manually , first open each solution folder indivisually one by one, vsc help will create for you )
- To create WorkSpace, no need to do harwork just Start adding your sln folder to workspace tab,
Crtl+shif+P : Workspace:open Configuration file you can setup compound launch setting as well after that, to open multiple sln in debug mode at same time, like below one: "launch": { "configurations": [
], "compounds": [ { "name": "Launch Server & Client", "configurations": [ "CMSAPI",// Each indivisual sln launch setting unique name "Core" ] } ]
}

- 191
- 1
- 12