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.

Incorrectly reporting errors in unity project

See original GitHub issue

Environment data

dotnet --info output:

.NET Command Line Tools (1.0.4)

Product Information: Version: 1.0.4 Commit SHA-1 hash: af1e6684fd

Runtime Environment: OS Name: Mac OS X OS Version: 10.13 OS Platform: Darwin RID: osx.10.11-x64 Base Path: /usr/local/share/dotnet/sdk/1.0.4

VS Code version:

1.27.2

C# Extension version:

1.16.1

Steps to reproduce

I don’t have a simple repro. In my project, if I open the “Shooter.cs” file then it’s fine. If I open the “Rifle.cs” file it’s still fine. If I then click back on the open Shooter.cs file I get about 400 spurious errors.

Expected behavior

Only real errors should be reported.

Actual behavior

Almost every line of the file is reported as an error. This is the error on the rifle class itself:

The type 'Rifle' in '/Users/simonwatson/Documents/Projects/swatson_OSX_SVT2/Assets/Scripts/Rifle.cs' conflicts with the imported type 'Rifle' in 'Assembly-CSharp-firstpass, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'. Using the type defined in '/Users/simonwatson/Documents/Projects/swatson_OSX_SVT2/Assets/Scripts/Rifle.cs'. [Assembly-CSharp]
The type 'Rifle' in '/Users/simonwatson/Documents/Projects/swatson_OSX_SVT2/Assets/Scripts/Rifle.cs' conflicts with the imported type 'Rifle' in 'Assembly-CSharp, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null'. Using the type defined in '/Users/simonwatson/Documents/Projects/swatson_OSX_SVT2/Assets/Scripts/Rifle.cs'. [Assembly-CSharp-Editor]

This is from a reference to the rifle in the Shooter class:

The type or namespace name 'Rifle' could not be found (are you missing a using directive or an assembly reference?) [Assembly-CSharp, Assembly-CSharp-firstpass, Assembly-CSharp-Editor]

(This is most of the errors)

This is a reference in Shooter to an external enum:

Cannot implicitly convert type 'Shooter.LaserType [Assembly-CSharp, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null]' to 'Shooter.LaserType [Assembly-CSharp-Editor, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null]'. An explicit conversion exists (are you missing a cast?) [Assembly-CSharp-Editor]

This is the output from omnisharp when loading up:

Starting OmniSharp server at 9/17/2018, 4:57:48 PM
    Target: /Users/simonwatson/Documents/Projects/swatson_OSX_SVT2/swatson_OSX_SVT2.sln

OmniSharp server started with Mono 5.14.0.
    Path: /Users/simonwatson/.vscode/extensions/ms-vscode.csharp-1.16.1/.omnisharp/1.32.5/omnisharp/OmniSharp.exe
    PID: 12532

[info]: OmniSharp.Stdio.Host
        Starting OmniSharp on MacOS 10.13.6 (x64)
[info]: OmniSharp.Services.DotNetCliService
        DotNetPath set to dotnet
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
        Located 2 MSBuild instance(s)
            1: Mono 15.0 - "/usr/local/Cellar/mono/5.14.0.177/lib/mono/msbuild/15.0/bin"
            2: StandAlone 15.0 - "/Users/simonwatson/.vscode/extensions/ms-vscode.csharp-1.16.1/.omnisharp/1.32.5/omnisharp/msbuild/15.0/Bin"
[info]: OmniSharp.MSBuild.Discovery.MSBuildLocator
        Registered MSBuild instance: Mono 15.0 - "/usr/local/Cellar/mono/5.14.0.177/lib/mono/msbuild/15.0/bin"
            CscToolPath = /Users/simonwatson/.vscode/extensions/ms-vscode.csharp-1.16.1/.omnisharp/1.32.5/omnisharp/msbuild/15.0/Bin/Roslyn
            CscToolExe = csc.exe
[info]: OmniSharp.Cake.CakeProjectSystem
        Detecting Cake files in '/Users/simonwatson/Documents/Projects/swatson_OSX_SVT2'.
[info]: OmniSharp.Cake.CakeProjectSystem
        Could not find any Cake files
[info]: OmniSharp.WorkspaceInitializer
        Project system 'OmniSharp.DotNet.DotNetProjectSystem' is disabled in the configuration.
[info]: OmniSharp.MSBuild.ProjectSystem
        Detecting projects in '/Users/simonwatson/Documents/Projects/swatson_OSX_SVT2/swatson_OSX_SVT2.sln'.
[info]: OmniSharp.MSBuild.ProjectManager
        Queue project update for '/Users/simonwatson/Documents/Projects/swatson_OSX_SVT2/Assembly-CSharp.csproj'
[info]: OmniSharp.MSBuild.ProjectManager
        Queue project update for '/Users/simonwatson/Documents/Projects/swatson_OSX_SVT2/Assembly-CSharp-firstpass.csproj'
[info]: OmniSharp.MSBuild.ProjectManager
        Queue project update for '/Users/simonwatson/Documents/Projects/swatson_OSX_SVT2/Assembly-CSharp-Editor.csproj'
[info]: OmniSharp.Script.ScriptProjectSystem
        Detecting CSX files in '/Users/simonwatson/Documents/Projects/swatson_OSX_SVT2'.
[info]: OmniSharp.MSBuild.ProjectManager
        Loading project: /Users/simonwatson/Documents/Projects/swatson_OSX_SVT2/Assembly-CSharp.csproj
[info]: OmniSharp.MSBuild.ProjectManager
        Successfully loaded project file '/Users/simonwatson/Documents/Projects/swatson_OSX_SVT2/Assembly-CSharp.csproj'.
[info]: OmniSharp.MSBuild.ProjectManager
        Adding project '/Users/simonwatson/Documents/Projects/swatson_OSX_SVT2/Assembly-CSharp.csproj'
[info]: OmniSharp.MSBuild.ProjectManager
        Loading project: /Users/simonwatson/Documents/Projects/swatson_OSX_SVT2/Assembly-CSharp-firstpass.csproj
[info]: OmniSharp.Script.ScriptProjectSystem
        Could not find any CSX files
[info]: OmniSharp.WorkspaceInitializer
        Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.CSharpWorkspaceOptionsProvider
[info]: OmniSharp.WorkspaceInitializer
        Configuration finished.
[info]: OmniSharp.Stdio.Host
        Omnisharp server running using Stdio at location '/Users/simonwatson/Documents/Projects/swatson_OSX_SVT2' on host 12486.
[info]: OmniSharp.MSBuild.ProjectManager
        Successfully loaded project file '/Users/simonwatson/Documents/Projects/swatson_OSX_SVT2/Assembly-CSharp-firstpass.csproj'.
[info]: OmniSharp.MSBuild.ProjectManager
        Adding project '/Users/simonwatson/Documents/Projects/swatson_OSX_SVT2/Assembly-CSharp-firstpass.csproj'
[info]: OmniSharp.MSBuild.ProjectManager
        Loading project: /Users/simonwatson/Documents/Projects/swatson_OSX_SVT2/Assembly-CSharp-Editor.csproj
[info]: OmniSharp.MSBuild.ProjectManager
        Successfully loaded project file '/Users/simonwatson/Documents/Projects/swatson_OSX_SVT2/Assembly-CSharp-Editor.csproj'.
[info]: OmniSharp.MSBuild.ProjectManager
        Adding project '/Users/simonwatson/Documents/Projects/swatson_OSX_SVT2/Assembly-CSharp-Editor.csproj'
[info]: OmniSharp.MSBuild.ProjectManager
        Update project: Assembly-CSharp
[warn]: OmniSharp.MSBuild.ProjectManager
        Unable to resolve assembly '/Users/simonwatson/Documents/Projects/swatson_OSX_SVT2/Temp/bin/Debug/Assembly-CSharp-firstpass.dll'
[info]: OmniSharp.MSBuild.ProjectManager
        Update project: Assembly-CSharp-firstpass
[info]: OmniSharp.MSBuild.ProjectManager
        Update project: Assembly-CSharp-Editor
[warn]: OmniSharp.MSBuild.ProjectManager
        Unable to resolve assembly '/Users/simonwatson/Documents/Projects/swatson_OSX_SVT2/Temp/bin/Debug/Assembly-CSharp-firstpass.dll'
[warn]: OmniSharp.MSBuild.ProjectManager
        Unable to resolve assembly '/Users/simonwatson/Documents/Projects/swatson_OSX_SVT2/Temp/bin/Debug/Assembly-CSharp.dll'

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:9
  • Comments:25 (1 by maintainers)

github_iconTop GitHub Comments

4reactions
mihnescucommented, Jul 31, 2019

Quick Update: Unity 2019.2 officially added support for VS Code via package manager. To ensure projects are generated correctly, remove all csproj files that are related to the unity project and reopen the the project from Unity in order to properly generated the proj files. You might also want to remove any old .vscode directory just to be sure that a clean vs-code compatible is generated from unity.

Will come with updates after I test this for a few days

4reactions
akshita31commented, Sep 17, 2018

@Aciho I think I might know what is the problem here. Do you have symbolic links in your project? Can you try setting omnisharp.path: “1.32.2” in your settings and then Ctrl+Shift+P --> Restart OmniSharp and see if the error still reproduces ?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Bug Reporting - Unity QA
If your bug report is to do with Documentation, either an error, typo, or omission, you can report it by scrolling to the...
Read more >
Common Errors - Unity - Manual
Two common errors you might encounter are: Create match failed: Failed to access NetworkDB appId=0. This occurs if you have not linked the...
Read more >
Debugging Unity Crashes & Errors - The Easy Way - YouTube
Try Backtrace FREE - https://backtrace.io/create/?utm_campaign=Free%20Trial%20Signup&utm_source=Jason%20WeimannLearn how to catch and fix ...
Read more >
C# (for Unity) stopped reporting errors to Error List
First of, as a workaround to unlock you, you can go to the Visual Studio options (Tools -> Options), and in the Tools...
Read more >
Fix program errors and improve code - Visual Studio (Windows)
This article describes some basic ways Visual Studio can help you find and fix problems in your code, including build errors, code analysis, ......
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