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.

Error when creating new files

See original GitHub issue

Issue Description

Hello!

I’m having some trouble using VSCode and the C# extension. Everytime I create a new file, the Intellisense doens’t work, not showing any errors (red underline) on the file. The OmniSharp Log output shows the following message:

    Could not find document for file /Users/rafaelmaia/source/personal/dotnet/Commander/Data/Mock.cs

I reinstalled VSCode and deleted all my extensions folder rm -rf ~/.vscode*, just installed the C# extension and the error persists.

I’m using VSCode version 1.50.1 on a macOS Cataline 10.15.7, dotnet sdk 3.1.403

Steps to Reproduce

Clean Install of VSCode Install C# extension Create a dotnet webapi project dotnet new webapi -n Test Create a new file Write something ex: aaaaaa

Expected Behavior

The expect behavior would be the line written with a red underscore, indicating an error.

Actual Behavior

Nothing happens, and you can check errors popping on the OmniSharp Log

[info]: OmniSharp.Roslyn.CSharp.Services.Completion.CompletionService
        Could not find document for file /Users/rafaelmaia/source/personal/dotnet/Teste/Controllers/teste.cs

Logs

OmniSharp log

Here's the full OmniSharp Log, the error lines at the end start appearing as I create a new file and start to type on it.

Starting OmniSharp server at 11/5/2020, 4:28:59 AM Target: /Users/rafaelmaia/source/personal/dotnet/Commander

OmniSharp server started. Path: /Users/rafaelmaia/.vscode/extensions/ms-dotnettools.csharp-1.23.5/.omnisharp/1.37.3/run PID: 94751

    Starting OmniSharp on MacOS 10.15.7 (x64)
    DotNetPath set to dotnet
    Located 1 MSBuild instance(s)
        1: StandAlone 16.8.0 - "/Users/rafaelmaia/.vscode/extensions/ms-dotnettools.csharp-1.23.5/.omnisharp/1.37.3/omnisharp/.msbuild/Current/Bin"
    MSBUILD_EXE_PATH environment variable set to '/Users/rafaelmaia/.vscode/extensions/ms-dotnettools.csharp-1.23.5/.omnisharp/1.37.3/omnisharp/.msbuild/Current/Bin/MSBuild.exe'
    Registered MSBuild instance: StandAlone 16.8.0 - "/Users/rafaelmaia/.vscode/extensions/ms-dotnettools.csharp-1.23.5/.omnisharp/1.37.3/omnisharp/.msbuild/Current/Bin"
        CscToolExe = csc.exe
        MSBuildToolsPath = /Users/rafaelmaia/.vscode/extensions/ms-dotnettools.csharp-1.23.5/.omnisharp/1.37.3/omnisharp/.msbuild/Current/Bin
        CscToolPath = /Users/rafaelmaia/.vscode/extensions/ms-dotnettools.csharp-1.23.5/.omnisharp/1.37.3/omnisharp/.msbuild/Current/Bin/Roslyn
        BypassFrameworkInstallChecks = true
        MSBuildExtensionsPath = /Users/rafaelmaia/.vscode/extensions/ms-dotnettools.csharp-1.23.5/.omnisharp/1.37.3/omnisharp/.msbuild
    Detecting Cake files in '/Users/rafaelmaia/source/personal/dotnet/Commander'.
    Could not find any Cake files
    No solution files found in '/Users/rafaelmaia/source/personal/dotnet/Commander'
    Queue project update for '/Users/rafaelmaia/source/personal/dotnet/Commander/Commander.csproj'
    Detecting CSX files in '/Users/rafaelmaia/source/personal/dotnet/Commander'.
    Could not find any CSX files
    Invoking Workspace Options Provider: OmniSharp.Roslyn.CSharp.Services.CSharpFormattingWorkspaceOptionsProvider, Order: 0
    Loading project: /Users/rafaelmaia/source/personal/dotnet/Commander/Commander.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 '/Users/rafaelmaia/source/personal/dotnet/Commander' on host 94627.
    Successfully loaded project file '/Users/rafaelmaia/source/personal/dotnet/Commander/Commander.csproj'.
    Adding project '/Users/rafaelmaia/source/personal/dotnet/Commander/Commander.csproj'
    Update project: Commander
    Could not find document for file /Users/rafaelmaia/source/personal/dotnet/Commander/Data/teste1.cs
    Could not find document for file /Users/rafaelmaia/source/personal/dotnet/Commander/Data/teste1.cs
    Could not find document for file /Users/rafaelmaia/source/personal/dotnet/Commander/Data/teste1.cs
    Could not find document for file /Users/rafaelmaia/source/personal/dotnet/Commander/Data/teste1.cs
    Could not find document for file /Users/rafaelmaia/source/personal/dotnet/Commander/Data/teste1.cs
    Could not find document for file /Users/rafaelmaia/source/personal/dotnet/Commander/Data/teste1.cs
    Could not find document for file /Users/rafaelmaia/source/personal/dotnet/Commander/Data/teste1.cs

C# log

Nothing on C# Log.

Environment information

VSCode version: 1.50.1 C# Extension: 1.23.5

Mono Information OmniSharp using built-in mono
Dotnet Information .NET Core SDK (reflecting any global.json): Version: 3.1.403 Commit: 9e895200cd

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

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

.NET Core SDKs installed: 2.0.3 [/usr/local/share/dotnet/sdk] 2.1.3 [/usr/local/share/dotnet/sdk] 3.1.403 [/usr/local/share/dotnet/sdk]

.NET Core runtimes installed: Microsoft.AspNetCore.App 3.1.9 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App] Microsoft.NETCore.App 2.0.3 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App] Microsoft.NETCore.App 2.0.4 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App] Microsoft.NETCore.App 2.1.23 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App] Microsoft.NETCore.App 3.1.9 [/usr/local/share/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
csharp ms-dotnettools 1.23.5

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:10
  • Comments:31 (10 by maintainers)

github_iconTop GitHub Comments

2reactions
333fredcommented, Jan 10, 2021

For those of you who are still seeing this and aren’t adding non csharp files (like tcroc is) please file a new issue with specific repro steps. I use the extension every day and have yet to reproduce the issue with csharp files, so more info is needed.

2reactions
alpha-tango-kilocommented, Dec 12, 2020
1. make a new folder, cd into it

2. `dotnet new console`

3. go edit Program class, add property : `public Model MyProperty { get; set; }`

4. use `Show Fixes (ctrl+;)` to create Model `Generate type 'Model' -> Generate class 'Model' in a new file`

now Model.cs is created but Program doesn’t see the class, and you can’t see the ‘x references’ hints in the new file.

This minimal example works for me having set omnisharp.path to latest, however within a Unity project adding a new C# script isn’t recognised and I get the “Could not find document for file” warning, no autocompletions or reference counter

I’m using VSCodium 1.52.0, C# extension 1.23.7. I’m not massively familiar with C# development so please let me know what other debug info you need if you do

Read more comments on GitHub >

github_iconTop Results From Across the Web

Can't create new files or folders. Keep getting error window pop
When I try to make a new text document for instance it pops up an error window and says "Unable to create the...
Read more >
Error when creating a new text file with python? - Stack Overflow
If the file does not exists, open(name,'r+') will fail. You can use open(name, 'w') , which creates the file if the file does...
Read more >
Windows 10: An Error Occurred While Creating the Directory
What to Do If an Error Occurred While Creating the Directory ; Go to Settings, click on Accounts, and select Family & other...
Read more >
Fix: Unable to Create New Files on Adobe Photoshop - Saintlad
Fix: Unable to Create New Files on Adobe Photoshop · 1. Restart Your Computer. · 2. Open or Create Files in Adobe Illustrator....
Read more >
DataStage reporting "Error on CREATE.FILE command ... - IBM
Certain operations on DataStage projects report an error creating job files such as:Error on CREATE.FILE command (Creating file ...
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 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