12

I am using Visual Studio Code and I have already loaded C# OMNISharp plugin to my system and it works all fine in my existing project/solutions.

However, I just created a new solution and a new project in Visual Studio code and it sounds like for this particular solution, the Intellisense or any other Omnisharp features are just not working. I have tried following things:

  • Restarting Visual Studio Code
  • Disabling and enabling my OmniSharp Plug-in

Also, one thing that I noticed is that when a solution is created in Visual studio, it has a lot of code which looks like following:

Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{AEA16303-6991-4FF1-A3A9-72D892D7968C}"
EndProject

Basically, these are all project references. However, when a solution is created by Visual Studio Code then there is not any section like that. This solution runs and compiles fine, just that it looks fundamentally different than how a Visual Studio solution looks like.

However, nothing seems to be working. Is there anything that I can try to make it work? Any ideas ?

2
  • You should create your project with dotnet new (to target dotnet core) or with Visual Studio (to target the dot net framwork). The Project stuff you mention in your question is from the legacy csproj format generated by using the the latter. Commented Jan 16, 2018 at 20:54
  • Try disable or enable the C# extension Commented Mar 17, 2019 at 5:13

8 Answers 8

15
+25

It's caused by adding *.sln and *.csproj to your "files.exclude" setting.

Try this:

Code -> Preferences -> Settings -> "omnisharp.useMono": true/false

Remove from setting file.

Or, Open your project with MonoDevelop or Visual Studio 2015/2017 first, then reopen VS-Code.


Edit 1: Try setting "omnisharp.useGlobalMono": never and then restarting the omnisharp server. Credit: The_Wolf and kao peter

Sign up to request clarification or add additional context in comments.

3 Comments

Just put "Use global mono" to "never" and it worked.
@The_Wolf I know that's old, but Use Global mono to never worked for me too.
I'm new to vs code. I don't understand how I can set "omnisharp.useGlobalMono": never . Where do I do that? Or how do I do Code -> Preferences -> Settings -> "omnisharp.useMono": true/false I expect it to mean that there is a menu called Code but I don't have a dropdown menu called Code. Where do I find Code?
6

How did you created the project? For the Intellisense to work properly the project needs to have a specific structure.

Assuming you have the .net core sdk for mac and the omnisharp extension installed:

Try the following:

  1. Open your integrated terminal (View => Integrated terminal)
  2. Create some new directory to host a test project say "testproj" e.g => mkdir testproj

  3. use the dotnet cli to initialize the project => dotnet new console

See if you got intellisense.
Also i'd recommend watching the .net core on Mac introduction video.

2 Comments

Ok so I think the only differentiator here was that you need to create the containing folder with MKDIR from console. You can not start doing dotnet new in an already existing project created by OS. Not sure why is that but sounds like that is the only way to make it work.
Did not work for me. VSCode refusing to give intellisense in one class in a new project whereas it works fine in other classes in other projects in the same solution
4

In VS Code v1.43.2 adding following line to settings worked for me:

"omnisharp.useGlobalMono": "never"

The setting's value "never" had to be double-quoted otherwise it would be flagged in red. Even with the quotes, it remained highlighted in yellow. Not sure why, as all other options/values in there are blue. I presume this indicates some sort of warning, but it works.

(As an aside, I would love to understand what a "Globally installed mono" is. However my only interest here was getting IntelliSense working, so re: omnisharp I'm pleading 'newb'.)

4 Comments

This does not provide an answer to the question. Once you have sufficient reputation you will be able to comment on any post; instead, provide answers that don't require clarification from the asker. - From Review
Actually it provides an improved answer as the original did not specify the required quotes. Forgive me for actually trying to learn something along the way, my mistake.
Sorry, I missed that detail. I have restructured your answer to highlight the solution. (The comment you see above was created by the system when I reviewed your answer and marked it as "commentary".)
This seems to work for me, but I have to add the setting to every new Unity project that I create, which is very annoying. Is there any other fix or some way to make this a "global" setting?
3

This worked for me

"omnisharp.useGlobalMono": "never"

Comments

2

In my case, after installing C# extension, I had to click the setting icon on the extension and then click "Add to workspace recormendations"

Comments

2

I had this problem in 2022 and nothing mentioned above worked for me. For me the problem was caused by VS Code and C# plugin being updated (in my case c# plugin to v1.25.0+) because in this version they made this:

.NET Framework builds of OmniSharp no longer ship with Mono or the MSBuild tooling (See announcement omnisharp-roslyn#2339). To ensure that the C# > > extension remains usable out of the box for .NET SDK projects, we have > changed the default value of omnisharp.useModernNet to true.
If you still need Unity or .NET Framework support, you can set > omnisharp.useModernNet to false in your VS Code settings and restart OmniSharp.

So entier problem was in omnisharp.useModernNet being set to true by default which renders entire plugin unfunctional but doing what they said and setting omnisharp.useModernNet to false manually in .vscode > settings.json file solved this problem for me!
For more info, you can also read the entire official VS Code C# Plugin announcement under plugins Details section in VS Code or on this webpage as well!

Comments

1

Were your new solution and projects created in a "OneDrive" folder in Windows 10? In latest Windows 10 release, the C# plugin can't start up when a project resides in a OneDrive folder with "File On-Demand" feature on. Please take a look at this issue on Github

1 Comment

Actually this one was create on Mac in a local file-system.
1

I my case, the problem came from the resource folder of my project.

I had added a visual studio .sln file in the ressources to be used as a template but I somehow "variabilized" it with custom tags. OmniSharp tried to parse it and obviously failed, but no error poped up in VSCode, it was only visible in OmniSharp output.

The solution was to rename the template from .sln to .txt to prevent OmniSharp from loading it.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.