After creating a class using the right-click folder => New C# => Class, the class name is underlined in red squiggles with the following error:
The namespace 'Application.Core' already contains a definition for 'MappingProfiles' [Application, Application]csharp(CS0101) class Application.Core.MappingProfiles
Steps to Reproduce
In the file explorer of VS Code, right click a folder, hover over New C#, click on Class. See the class name in the generated file underlined with a red squiggle. If you close Code and reopen, this underline is gone.
Expected Behavior
No underlined red squggle
Actual Behavior
Underlined class name with red squiggle
Logs
OmniSharp log
Post the output from Output-->OmniSharp log here
Starting OmniSharp server at 10/3/2023, 11:12:24 PM
Target: c:\Users\hopme\OneDrive\Documents\Code\Courses\Udemy\React-NetCore\Reactivities\Reactivities.sln
OmniSharp server started with .NET 7.0.400
.
Path: c:\Users\hopme.vscode\extensions\ms-dotnettools.csharp-1.26.0-win32-x64.omnisharp\1.39.7-net6.0\OmniSharp.dll
PID: 2268
Starting OmniSharp on Windows 10.0.22621.0 (x64)
Checking the 'DOTNET_ROOT' environment variable to find a .NET SDK
{
"Request_seq": 179,
"Command": "/filesChanged",
"Running": true,
"Success": false,
"Message": "\"System.IO.IOException: The process cannot access the file 'c:\\Users\\hopme\\OneDrive\\Documents\\Code\\Courses\\Udemy\\React-NetCore\\Reactivities\\Application\\Activities\\TestClass.cs' because it is being used by another process.\r\n at Microsoft.Win32.SafeHandles.SafeFileHandle.CreateFile(String fullPath, FileMode mode, FileAccess access, FileShare share, FileOptions options)\r\n at Microsoft.Win32.SafeHandles.SafeFileHandle.Open(String fullPath, FileMode mode, FileAccess access, FileShare share, FileOptions options, Int64 preallocationSize, Nullable1 unixCreateMode)\\r\\n at System.IO.Strategies.OSFileStreamStrategy..ctor(String path, FileMode mode, FileAccess access, FileShare share, FileOptions options, Int64 preallocationSize, Nullable1 unixCreateMode)\r\n at System.IO.StreamReader.ValidateArgsAndOpenPath(String path, Encoding encoding, Int32 bufferSize)\r\n at System.IO.File.ReadAllText(String path, Encoding encoding)\r\n at OmniSharp.Roslyn.BufferManager.UpdateBufferAsync(Request request, Boolean isCreate) in D:\\a\\1\\s\\src\\OmniSharp.Roslyn\\BufferManager.cs:line 49\"",
"Body": null,
"Seq": 6895,
"Type": "response"
}
Received response for /v2/getcodeactions but could not find request.
Issue Description
After creating a class using the right-click folder => New C# => Class, the class name is underlined in red squiggles with the following error:
The namespace 'Application.Core' already contains a definition for 'MappingProfiles' [Application, Application]csharp(CS0101) class Application.Core.MappingProfiles
Steps to Reproduce
In the file explorer of VS Code, right click a folder, hover over New C#, click on Class. See the class name in the generated file underlined with a red squiggle. If you close Code and reopen, this underline is gone.
Expected Behavior
No underlined red squggle
Actual Behavior
Underlined class name with red squiggle
Logs
OmniSharp log
Starting OmniSharp server at 10/3/2023, 11:12:24 PM Target: c:\Users\hopme\OneDrive\Documents\Code\Courses\Udemy\React-NetCore\Reactivities\Reactivities.sln
OmniSharp server started with .NET 7.0.400 . Path: c:\Users\hopme.vscode\extensions\ms-dotnettools.csharp-1.26.0-win32-x64.omnisharp\1.39.7-net6.0\OmniSharp.dll PID: 2268
Received response for /quickinfo but could not find request.
{ "Type": "request", "Seq": 179, "Command": "/filesChanged", "Arguments": [ { "FileName": "c:\Users\hopme\OneDrive\Documents\Code\Courses\Udemy\React-NetCore\Reactivities\Application\Activities\TestClass.cs", "changeType": "Create" } ] }
{ "Request_seq": 179, "Command": "/filesChanged", "Running": true, "Success": false, "Message": "\"System.IO.IOException: The process cannot access the file 'c:\\Users\\hopme\\OneDrive\\Documents\\Code\\Courses\\Udemy\\React-NetCore\\Reactivities\\Application\\Activities\\TestClass.cs' because it is being used by another process.\r\n at Microsoft.Win32.SafeHandles.SafeFileHandle.CreateFile(String fullPath, FileMode mode, FileAccess access, FileShare share, FileOptions options)\r\n at Microsoft.Win32.SafeHandles.SafeFileHandle.Open(String fullPath, FileMode mode, FileAccess access, FileShare share, FileOptions options, Int64 preallocationSize, Nullable
1 unixCreateMode)\\r\\n at System.IO.Strategies.OSFileStreamStrategy..ctor(String path, FileMode mode, FileAccess access, FileShare share, FileOptions options, Int64 preallocationSize, Nullable
1 unixCreateMode)\r\n at System.IO.StreamReader.ValidateArgsAndOpenPath(String path, Encoding encoding, Int32 bufferSize)\r\n at System.IO.File.ReadAllText(String path, Encoding encoding)\r\n at OmniSharp.Roslyn.BufferManager.UpdateBufferAsync(Request request, Boolean isCreate) in D:\\a\\1\\s\\src\\OmniSharp.Roslyn\\BufferManager.cs:line 49\"", "Body": null, "Seq": 6895, "Type": "response" } Received response for /v2/getcodeactions but could not find request.C# log
There was no C# output
Environment information
VSCode version: 1.82.3 C# Extension: 1.26.0
Dotnet Information
.NET SDK: Version: 7.0.400 Commit: 73bf45718d Runtime Environment: OS Name: Windows OS Version: 10.0.22621 OS Platform: Windows RID: win10-x64 Base Path: C:\Program Files\dotnet\sdk\7.0.400\ Host: Version: 7.0.10 Architecture: x64 Commit: a6dbb800a4 .NET SDKs installed: 3.1.426 [C:\Program Files\dotnet\sdk] 5.0.100 [C:\Program Files\dotnet\sdk] 5.0.104 [C:\Program Files\dotnet\sdk] 5.0.214 [C:\Program Files\dotnet\sdk] 5.0.303 [C:\Program Files\dotnet\sdk] 5.0.408 [C:\Program Files\dotnet\sdk] 5.0.416 [C:\Program Files\dotnet\sdk] 6.0.122 [C:\Program Files\dotnet\sdk] 6.0.317 [C:\Program Files\dotnet\sdk] 7.0.400 [C:\Program Files\dotnet\sdk] .NET runtimes installed: Microsoft.AspNetCore.App 3.1.21 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 3.1.30 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 3.1.32 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 5.0.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 5.0.4 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 5.0.9 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 5.0.10 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 5.0.12 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 5.0.17 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 6.0.10 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 6.0.21 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 6.0.22 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 7.0.10 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.NETCore.App 3.1.21 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 3.1.30 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 3.1.32 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 5.0.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 5.0.4 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 5.0.6 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 5.0.9 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 5.0.12 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 5.0.17 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 6.0.4 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 6.0.10 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 6.0.15 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 6.0.21 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 6.0.22 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 7.0.10 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.WindowsDesktop.App 3.1.21 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 3.1.30 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 3.1.32 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 5.0.0 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 5.0.4 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 5.0.9 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 5.0.12 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 5.0.17 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 6.0.4 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 6.0.10 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 6.0.15 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 6.0.21 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 6.0.22 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 7.0.10 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Other architectures found: arm64 [C:\Program Files\dotnet] registered at [HKLM\SOFTWARE\dotnet\Setup\InstalledVersions\arm64\InstallLocation] x86 [C:\Program Files (x86)\dotnet] registered at [HKLM\SOFTWARE\dotnet\Setup\InstalledVersions\x86\InstallLocation] Environment variables: Not set global.json file: Not found Learn more: https://aka.ms/dotnet/info Download .NET: https://aka.ms/dotnet/downloadVisual Studio Code Extensions
|Extension|Author|Version| |---|---|---| |Angular2|johnpapa|16.0.1| |arduino-snippets|ronaldosena|1.0.2| |ASPNETCore-VSCode-Extensions|SyncfusionInc|23.1.36| |azure-account|ms-vscode|0.11.5| |azure-deploy|ms-vscode-deploy-azure|1.2.4| |better-cpp-syntax|jeff-hykin|1.17.2| |Blazor-VSCode-Extensions|SyncfusionInc|23.1.36| |cmake|twxs|0.0.17| |cmake-tools|ms-vscode|1.15.31| |cpptools|ms-vscode|1.17.5| |cpptools-extension-pack|ms-vscode|1.3.0| |cpptools-themes|ms-vscode|2.0.0| |csharp|ms-dotnettools|1.26.0| |csharpextensions|kreativ-software|1.7.3| |debugger-for-edge|msjsdiag|1.0.15| |dotnet|formulahendry|0.0.4| |doxdocgen|cschlosser|1.4.0| |es6-css-minify|olback|3.3.3| |file-tree-generator|Shinotatwu-DS|1.1.1| |gitlens|eamodio|14.3.0| |json-tools|eriklynd|1.0.2| |jsoncrack-vscode|AykutSarac|2.0.2| |markdown-all-in-one|yzhang|3.5.1| |material-icon-theme|PKief|4.30.1| |ng-template|Angular|16.1.8| |nugetpackagemanagergui|aliasadidev|2.0.6| |path-intellisense|christian-kohler|2.8.4| |poor-mans-t-sql-formatter-vscode|TaoKlerks|1.6.10| |postman-for-vscode|Postman|0.10.0| |powershell|ms-vscode|2023.6.0| |rainbow-csv|mechatroner|3.7.1| |remote-containers|ms-vscode-remote|0.309.0| |remote-ssh|ms-vscode-remote|0.106.4| |remote-ssh-edit|ms-vscode-remote|0.86.0| |remote-wsl|ms-vscode-remote|0.81.7| |tabulous|bwildeman|1.2.0| |vs-code-xml-format|fabianlauer|0.1.5| |vscode-arduino|vsciot-vscode|0.6.0| |vscode-css-formatter|aeschli|1.0.2| |vscode-dotnet-runtime|ms-dotnettools|1.8.0| |vscode-edge-devtools|ms-edgedevtools|2.1.3| |vscode-eslint|dbaeumer|2.4.2| |vscode-gitignore-generator|piotrpalarz|1.0.3| |vscode-markdownlint|DavidAnson|0.52.0| |vscode-nuget-gallery|patcx|0.0.24| |vscode-peacock|johnpapa|4.2.2| |vscode-print|pdconsec|0.11.17| |vscode-serial-monitor|ms-vscode|0.10.0| |vscode-sql-formatter|adpyke|1.4.4| |vscode-sqlite|alexcvzz|0.14.1| |vscode-streamdeck|nicollasr|4.1.6| |vscode-userscript|adpyke|1.3.2| |vsliveshare|ms-vsliveshare|1.0.5883| |vsliveshare-pack|ms-vsliveshare|0.4.0| |Web-VSCode-Extensions|SyncfusionInc|23.1.36| |windows-terminal|Tyriar|0.7.0| |xml|DotJoshJohnson|2.5.1|;