question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

"Type or namespace name ... could not be found" for some symbols

See original GitHub issue

Issue Description

Opened a Unity project that previously worked and now some symbols are not recognized.

Steps to Reproduce

Open project

Expected Behavior

No errors

Actual Behavior

Several erroneous errors about missing symbols. In the logs there a System.ArgumentOutOfRangeException as a response.

Logs

OmniSharp log

Starting OmniSharp server at 11/26/2020, 9:44:34 AM Target: /home/megan/w/CVTest/CVTest.sln

OmniSharp server started with Mono 6.8.0. Path: /home/megan/.vscode/extensions/ms-dotnettools.csharp-1.23.6/.omnisharp/1.37.3/omnisharp/OmniSharp.exe PID: 2983

    Starting OmniSharp on fedora 33.0 (x64)
    DotNetPath set to dotnet
    Located 1 MSBuild instance(s)
        1: StandAlone 16.8.0 - "/home/megan/.vscode/extensions/ms-dotnettools.csharp-1.23.6/.omnisharp/1.37.3/omnisharp/.msbuild/Current/Bin"
    MSBUILD_EXE_PATH environment variable set to '/home/megan/.vscode/extensions/ms-dotnettools.csharp-1.23.6/.omnisharp/1.37.3/omnisharp/.msbuild/Current/Bin/MSBuild.exe'
    Registered MSBuild instance: StandAlone 16.8.0 - "/home/megan/.vscode/extensions/ms-dotnettools.csharp-1.23.6/.omnisharp/1.37.3/omnisharp/.msbuild/Current/Bin"
        CscToolExe = csc.exe
        MSBuildToolsPath = /home/megan/.vscode/extensions/ms-dotnettools.csharp-1.23.6/.omnisharp/1.37.3/omnisharp/.msbuild/Current/Bin
        CscToolPath = /home/megan/.vscode/extensions/ms-dotnettools.csharp-1.23.6/.omnisharp/1.37.3/omnisharp/.msbuild/Current/Bin/Roslyn
        BypassFrameworkInstallChecks = true
        MSBuildExtensionsPath = /home/megan/.vscode/extensions/ms-dotnettools.csharp-1.23.6/.omnisharp/1.37.3/omnisharp/.msbuild
    Detecting Cake files in '/home/megan/w/CVTest'.
    Could not find any Cake files
    Detecting projects in '/home/megan/w/CVTest/CVTest.sln'.
    Queue project update for '/home/megan/w/CVTest/UnityEngine.UI.csproj'
    Queue project update for '/home/megan/w/CVTest/Assembly-CSharp.csproj'
    Queue project update for '/home/megan/w/CVTest/Unity.2D.Sprite.Editor.csproj'
    Queue project update for '/home/megan/w/CVTest/UnityEditor.UI.csproj'
    Queue project update for '/home/megan/w/CVTest/Unity.2D.Tilemap.Editor.csproj'
    Detecting CSX files in '/home/megan/w/CVTest'.
    Could not find any CSX files
    Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.CSharpFormattingWorkspaceOptionsProvider, Order: 0
    Loading project: /home/megan/w/CVTest/UnityEngine.UI.csproj
    Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.Completion.CompletionOptionsProvider, Order: 0
    Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.RenameWorkspaceOptionsProvider, Order: 100
    Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.ImplementTypeWorkspaceOptionsProvider, Order: 110
    Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.BlockStructureWorkspaceOptionsProvider, Order: 140
    Configuration finished.
    Omnisharp server running using Stdio at location '/home/megan/w/CVTest' on host 2831.
    Successfully loaded project file '/home/megan/w/CVTest/UnityEngine.UI.csproj'.
    Adding project '/home/megan/w/CVTest/UnityEngine.UI.csproj'
    Loading project: /home/megan/w/CVTest/Assembly-CSharp.csproj
    Successfully loaded project file '/home/megan/w/CVTest/Assembly-CSharp.csproj'.
    Adding project '/home/megan/w/CVTest/Assembly-CSharp.csproj'
    Loading project: /home/megan/w/CVTest/Unity.2D.Sprite.Editor.csproj
    Successfully loaded project file '/home/megan/w/CVTest/Unity.2D.Sprite.Editor.csproj'.
    Adding project '/home/megan/w/CVTest/Unity.2D.Sprite.Editor.csproj'
    Loading project: /home/megan/w/CVTest/UnityEditor.UI.csproj
    Successfully loaded project file '/home/megan/w/CVTest/UnityEditor.UI.csproj'.
    Adding project '/home/megan/w/CVTest/UnityEditor.UI.csproj'
    Loading project: /home/megan/w/CVTest/Unity.2D.Tilemap.Editor.csproj
    Successfully loaded project file '/home/megan/w/CVTest/Unity.2D.Tilemap.Editor.csproj'.
    Adding project '/home/megan/w/CVTest/Unity.2D.Tilemap.Editor.csproj'
    Update project: UnityEngine.UI
    Update project: Assembly-CSharp
    Update project: Unity.2D.Sprite.Editor
    Update project: UnityEditor.UI
    Update project: Unity.2D.Tilemap.Editor
    ************  Response ************ 

{ “Request_seq”: 8, “Command”: “/v2/highlight”, “Running”: true, “Success”: false, “Message”: “"System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values.\nParameter name: line\n at Microsoft.CodeAnalysis.Text.LinePosition…ctor (System.Int32 line, System.Int32 character) [0x00004] in <74e762f007514b0991a005183ec8dcb2>:0 \n at OmniSharp.Roslyn.CSharp.Services.SemanticHighlight.SemanticHighlightService.Handle (OmniSharp.Models.SemanticHighlight.SemanticHighlightRequest request) [0x00146] in <8ca5e445b15640a0986680e5a0180b25>:0 \n at OmniSharp.Endpoint.EndpointHandler2[TRequest,TResponse].GetFirstNotEmptyResponseFromHandlers (OmniSharp.Endpoint.Exports.ExportHandler2[TRequest,TResponse][] handlers, TRequest request) [0x00099] in <9e06207949b04d41ac60c7c691c8ecbb>:0 \n at OmniSharp.Endpoint.EndpointHandler2[TRequest,TResponse].HandleRequestForLanguage (System.String language, TRequest request, OmniSharp.Protocol.RequestPacket packet) [0x00163] in <9e06207949b04d41ac60c7c691c8ecbb>:0 \\n at OmniSharp.Endpoint.EndpointHandler2[TRequest,TResponse].Process (OmniSharp.Protocol.RequestPacket packet, OmniSharp.Endpoint.LanguageModel model, Newtonsoft.Json.Linq.JToken requestObject) [0x0024b] in <9e06207949b04d41ac60c7c691c8ecbb>:0 \n at OmniSharp.Stdio.Host.HandleRequest (System.String json, Microsoft.Extensions.Logging.ILogger logger) [0x000e7] in <add5f40a6e784fcca3e930b59965388b>:0 "”, “Body”: null, “Seq”: 66, “Type”: “response” } fail: OmniSharp.Stdio.Host ************ Response ************ { “Request_seq”: 14, “Command”: “/v2/highlight”, “Running”: true, “Success”: false, “Message”: “"System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values.\nParameter name: line\n at Microsoft.CodeAnalysis.Text.LinePosition…ctor (System.Int32 line, System.Int32 character) [0x00004] in <74e762f007514b0991a005183ec8dcb2>:0 \n at OmniSharp.Roslyn.CSharp.Services.SemanticHighlight.SemanticHighlightService.Handle (OmniSharp.Models.SemanticHighlight.SemanticHighlightRequest request) [0x00146] in <8ca5e445b15640a0986680e5a0180b25>:0 \n at OmniSharp.Endpoint.EndpointHandler2[TRequest,TResponse].GetFirstNotEmptyResponseFromHandlers (OmniSharp.Endpoint.Exports.ExportHandler2[TRequest,TResponse][] handlers, TRequest request) [0x00099] in <9e06207949b04d41ac60c7c691c8ecbb>:0 \n at OmniSharp.Endpoint.EndpointHandler2[TRequest,TResponse].HandleRequestForLanguage (System.String language, TRequest request, OmniSharp.Protocol.RequestPacket packet) [0x00163] in <9e06207949b04d41ac60c7c691c8ecbb>:0 \\n at OmniSharp.Endpoint.EndpointHandler2[TRequest,TResponse].Process (OmniSharp.Protocol.RequestPacket packet, OmniSharp.Endpoint.LanguageModel model, Newtonsoft.Json.Linq.JToken requestObject) [0x0024b] in <9e06207949b04d41ac60c7c691c8ecbb>:0 \n at OmniSharp.Stdio.Host.HandleRequest (System.String json, Microsoft.Extensions.Logging.ILogger logger) [0x000e7] in <add5f40a6e784fcca3e930b59965388b>:0 "”, “Body”: null, “Seq”: 83, “Type”: “response” }

C# log

empty

Environment information

VSCode version: 1.51.1 C# Extension: 1.23.6

Mono Information OmniSharp using global mono :6.8.0
Dotnet Information .NET Core SDK (reflecting any global.json): Version: 3.1.109 Commit: 32ced2d411

Runtime Environment: OS Name: fedora OS Version: 33 OS Platform: Linux RID: fedora.33-x64 Base Path: /usr/lib64/dotnet/sdk/3.1.109/

Host (useful for support): Version: 3.1.9 Commit: 774fc3d6a9

.NET Core SDKs installed: 3.1.109 [/usr/lib64/dotnet/sdk]

.NET Core runtimes installed: Microsoft.AspNetCore.App 3.1.9 [/usr/lib64/dotnet/shared/Microsoft.AspNetCore.App] Microsoft.NETCore.App 3.1.9 [/usr/lib64/dotnet/shared/Microsoft.NETCore.App]

To install additional .NET Core runtimes or SDKs: https://aka.ms/dotnet-download

Visual Studio Code Extensions
Extension Author Version
ayu teabyii 0.20.1
csharp ms-dotnettools 1.23.6
haskell haskell 1.2.0
language-haskell justusadam 3.3.0
material-icon-theme PKief 4.4.0
material-palenight-theme whizkydee 2.0.1
material-theme zhuangtongfa 3.9.11
monokai-operator-theme markfknight 4.0.0
night-owl sdras 2.0.0
nord-operator-theme Chad 1.0.0
one-monokai azemoh 0.5.0
one-monokai-italics iamkd 0.4.0
operatormonodarktheme Valiantsin 1.0.1
snazzy-operator-plus bsides 1.2.1
theme-dracula dracula-theme 2.22.3
tomorrow-and-tomorrow-night-operator-mono-theme chiragpat 0.0.6
tomorrow-and-tomorrow-night-operator-mono-theme-tweaked stonebuddha 0.1.1
twilight-operator stevemcgrath 0.0.1
unity-debug Unity 3.0.2
vim vscodevim 1.17.1
vsc-community-material-theme Equinusocio 1.4.2
vsc-material-theme-icons equinusocio 1.2.0
vscode-great-icons emmanuelbeziat 2.1.61
vscode-simple-icons LaurentTreguier 1.13.5
vscode-theme-onedark akamud 2.2.2
winteriscoming johnpapa 1.4.3

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
mrcommented, Nov 26, 2020

Oh after also regenerating files it looks like it figured everything out! Thanks!

1reaction
filipwcommented, Nov 26, 2020

For Mono-based development (e.g. Unity) that requires full .NET framework, you need to set "omnisharp.useGlobalMono": "always" in VS Code settings.

This is mentioned in the known issues in release notes - https://github.com/OmniSharp/omnisharp-vscode/blob/8f7b3d21b5cdb04d6cf725302503d91099d95164/CHANGELOG.md#known-issues-in-1236

Read more comments on GitHub >

github_iconTop Results From Across the Web

The type or namespace name could not be found [duplicate]
See this question. Turns out this was a client profiling issue. PrjForm was set to ".Net Framework 4 Client Profile" I changed it...
Read more >
C# the type or namespace name could not be found (are you ...
Solution 1​​ The problem is that it can't find the class - it's not in the same namespace as your current code. That...
Read more >
Compiler Error CS0246 | Microsoft Learn
Did you misspell the name of the type or namespace? Without the correct name, the compiler cannot find the definition for the type...
Read more >
Type or namespace could not be found
Hi, I'm getting a type or namespace could not be found in VS 2019. I don't get any issues when I open the...
Read more >
The type or namespace name 'CreateBuilder' does not exist in ...
The problem is your application name is WebApplication, so the IDE thinks it's referring to the namespace instead of the build in WebApplication ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found