omnisharp-roslyn icon indicating copy to clipboard operation
omnisharp-roslyn copied to clipboard

VS Code's code completion causes many errors by OmniSharp

Open mkorsukov opened this issue 1 year ago • 19 comments

Setup:

  • Ubuntu 20.04.6
  • .NET SDK 8.0.202 (the only version on machine)
  • VS Code 1.87.2
  • C# extension 2.22.5 (OmniSharp 1.39.11-net6)
  • No C# DevKit

VS Code's settings.json

{
  "csharp.showOmnisharpLogOnError": true,
  "dotnet.completion.showCompletionItemsFromUnimportedNamespaces": true,
  "dotnet.defaultSolution": "disable",
  "dotnet.server.useOmnisharp": true,
  "omnisharp.useModernNet": true,
  "omnisharp.enableEditorConfigSupport": true,
  "omnisharp.sdkIncludePrereleases": false,
  "omnisharp.loggingLevel": "warning"
}

OnmiSharp Startup message

Starting OmniSharp server at 3/22/2024, 10:36:56 AM
  Target: /media/ramdisk/Platform/Src

OmniSharp server started with .NET 8.0.202
.
  Path: /home/max/.vscode/extensions/ms-dotnettools.csharp-2.22.5-linux-x64/.omnisharp/1.39.11-net6.0/OmniSharp.dll
  PID: 8240

Code example

using System;
using System.Collections.Generic;
using System.Threading.Tasks;

namespace X.App.Office.Commands;

public sealed class GetTextDialogCommand
{ }

Steps to reproduce

When I click on namespace word itself I get a warning log message, which is not a big deal (could be [info] however).

[warn]: OmniSharp.Roslyn.CSharp.Services.Navigation.FindUsagesService
        No symbol found. File: /media/ramdisk/Platform/Src/Apps/Office/Commands/Text/GetTextDialogCommand.cs, Line: 7, Column: 2.

When I click on the namespace's name within X.App.Office.Commands words I get an error log message. Sometimes it results in inability to use code completion in the project at all.

[warn]: OmniSharp.Stdio.Host
        ************ Request ************
{
  "Type": "request",
  "Seq": 618,
  "Command": "/v2/getcodeactions",
  "Arguments": {
    "FileName": "/media/ramdisk/Platform/Src/Apps/Office/Commands/Text/GetTextDialogCommand.cs",
    "Line": 7,
    "Column": 18
  }
}
[fail]: OmniSharp.Stdio.Host
        ************  Response (17.0102ms) ************ 
{
  "Request_seq": 618,
  "Command": "/v2/getcodeactions",
  "Running": true,
  "Success": false,
  "Message": "\"System.Reflection.ReflectionTypeLoadException: Unable to load one or more of the requested types.\\nAccess is denied: 'Microsoft.AspNetCore.Razor.PooledObjects.PooledObject`1[System.Collections.Immutable.ImmutableArray`1+Builder[Microsoft.AspNetCore.Razor.Language.SourceMapping]]'.\\nAccess is denied: 'Microsoft.AspNetCore.Razor.PooledObjects.PooledObject`1[System.Collections.Immutable.ImmutableArray`1+Builder[Microsoft.AspNetCore.Razor.Language.SourceMapping]]'.\\n   at System.Reflection.RuntimeModule.GetTypes(RuntimeModule module)\\n   at System.Reflection.RuntimeAssembly.get_DefinedTypes()\\n   at OmniSharp.Roslyn.CSharp.Services.Refactoring.V2.CachingCodeFixProviderForProjects.<>c.<LoadFrom>b__6_0(AnalyzerFileReference analyzerFileReference) in /home/vsts/work/1/s/src/OmniSharp.Roslyn.CSharp/Services/Refactoring/V2/CachingCodeFixProviderForProjects.cs:line 64\\n   at System.Linq.Enumerable.SelectManySingleSelectorIterator`2.MoveNext()\\n   at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()\\n   at System.Linq.Enumerable.WhereEnumerableIterator`1.MoveNext()\\n   at System.Collections.Generic.LargeArrayBuilder`1.AddRange(IEnumerable`1 items)\\n   at System.Collections.Generic.SparseArrayBuilder`1.ReserveOrAdd(IEnumerable`1 items)\\n   at System.Linq.Enumerable.Concat2Iterator`1.ToArray()\\n   at System.Collections.Immutable.ImmutableArray.CreateRange[T](IEnumerable`1 items)\\n   at OmniSharp.Roslyn.CSharp.Services.Refactoring.V2.CachingCodeFixProviderForProjects.LoadFrom(Project project) in /home/vsts/work/1/s/src/OmniSharp.Roslyn.CSharp/Services/Refactoring/V2/CachingCodeFixProviderForProjects.cs:line 95\\n   at OmniSharp.Roslyn.CSharp.Services.Refactoring.V2.CachingCodeFixProviderForProjects.GetAllCodeFixesForProject(ProjectId projectId) in /home/vsts/work/1/s/src/OmniSharp.Roslyn.CSharp/Services/Refactoring/V2/CachingCodeFixProviderForProjects.cs:line 57\\n   at OmniSharp.Roslyn.CSharp.Services.Refactoring.V2.BaseCodeActionService`2.GetSortedCodeFixProviders(Document document) in /home/vsts/work/1/s/src/OmniSharp.Roslyn.CSharp/Services/Refactoring/V2/BaseCodeActionService.cs:line 170\\n   at OmniSharp.Roslyn.CSharp.Services.Refactoring.V2.BaseCodeActionService`2.AppendFixesAsync(Document document, TextSpan span, IEnumerable`1 diagnostics, List`1 codeActions) in /home/vsts/work/1/s/src/OmniSharp.Roslyn.CSharp/Services/Refactoring/V2/BaseCodeActionService.cs:line 142\\n   at OmniSharp.Roslyn.CSharp.Services.Refactoring.V2.BaseCodeActionService`2.CollectCodeFixesActions(Document document, TextSpan span, List`1 codeActions) in /home/vsts/work/1/s/src/OmniSharp.Roslyn.CSharp/Services/Refactoring/V2/BaseCodeActionService.cs:line 134\\n   at OmniSharp.Roslyn.CSharp.Services.Refactoring.V2.BaseCodeActionService`2.GetAvailableCodeActions(ICodeActionRequest request) in /home/vsts/work/1/s/src/OmniSharp.Roslyn.CSharp/Services/Refactoring/V2/BaseCodeActionService.cs:line 86\\n   at OmniSharp.Roslyn.CSharp.Services.Refactoring.V2.GetCodeActionsService.Handle(GetCodeActionsRequest request) in /home/vsts/work/1/s/src/OmniSharp.Roslyn.CSharp/Services/Refactoring/V2/GetCodeActionsService.cs:line 34\\n   at OmniSharp.Endpoint.EndpointHandler`2.GetFirstNotEmptyResponseFromHandlers(ExportHandler`2[] handlers, TRequest request) in /home/vsts/work/1/s/src/OmniSharp.Host/Endpoint/EndpointHandler.cs:line 200\\n   at OmniSharp.Endpoint.EndpointHandler`2.HandleRequestForLanguage(String language, TRequest request, RequestPacket packet) in /home/vsts/work/1/s/src/OmniSharp.Host/Endpoint/EndpointHandler.cs:line 229\\n   at OmniSharp.Endpoint.EndpointHandler`2.Process(RequestPacket packet, LanguageModel model, JToken requestObject) in /home/vsts/work/1/s/src/OmniSharp.Host/Endpoint/EndpointHandler.cs:line 130\\n   at OmniSharp.Stdio.Host.HandleRequest(String json, ILogger logger) in /home/vsts/work/1/s/src/OmniSharp.Stdio/Host.cs:line 218\\nSystem.TypeLoadException: Access is denied: 'Microsoft.AspNetCore.Razor.PooledObjects.PooledObject`1[System.Collections.Immutable.ImmutableArray`1+Builder[Microsoft.AspNetCore.Razor.Language.SourceMapping]]'.\\nSystem.TypeLoadException: Access is denied: 'Microsoft.AspNetCore.Razor.PooledObjects.PooledObject`1[System.Collections.Immutable.ImmutableArray`1+Builder[Microsoft.AspNetCore.Razor.Language.SourceMapping]]'.\"",
  "Body": null,
  "Seq": 2076,
  "Type": "response"
}

Formatted error message

System.Reflection.ReflectionTypeLoadException: Unable to load one or more of the requested types.
Access is denied: 'Microsoft.AspNetCore.Razor.PooledObjects.PooledObject`1[System.Collections.Immutable.ImmutableArray`1+Builder[Microsoft.AspNetCore.Razor.Language.SourceMapping]]'.
   at System.Reflection.RuntimeModule.GetTypes(RuntimeModule module)
   at System.Reflection.RuntimeAssembly.get_DefinedTypes()
   at OmniSharp.Roslyn.CSharp.Services.Refactoring.V2.CachingCodeFixProviderForProjects.<>c.<LoadFrom>b__6_0(AnalyzerFileReference analyzerFileReference) in /home/vsts/work/1/s/src/OmniSharp.Roslyn.CSharp/Services/Refactoring/V2/CachingCodeFixProviderForProjects.cs:line 64
   at System.Linq.Enumerable.SelectManySingleSelectorIterator`2.MoveNext()
   at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()
   at System.Linq.Enumerable.WhereEnumerableIterator`1.MoveNext()
   at System.Collections.Generic.LargeArrayBuilder`1.AddRange(IEnumerable`1 items)
   at System.Collections.Generic.SparseArrayBuilder`1.ReserveOrAdd(IEnumerable`1 items)
   at System.Linq.Enumerable.Concat2Iterator`1.ToArray()
   at System.Collections.Immutable.ImmutableArray.CreateRange[T](IEnumerable`1 items)
   at OmniSharp.Roslyn.CSharp.Services.Refactoring.V2.CachingCodeFixProviderForProjects.LoadFrom(Project project) in /home/vsts/work/1/s/src/OmniSharp.Roslyn.CSharp/Services/Refactoring/V2/CachingCodeFixProviderForProjects.cs:line 95
   at OmniSharp.Roslyn.CSharp.Services.Refactoring.V2.CachingCodeFixProviderForProjects.GetAllCodeFixesForProject(ProjectId projectId) in /home/vsts/work/1/s/src/OmniSharp.Roslyn.CSharp/Services/Refactoring/V2/CachingCodeFixProviderForProjects.cs:line 57
   at OmniSharp.Roslyn.CSharp.Services.Refactoring.V2.BaseCodeActionService`2.GetSortedCodeFixProviders(Document document) in /home/vsts/work/1/s/src/OmniSharp.Roslyn.CSharp/Services/Refactoring/V2/BaseCodeActionService.cs:line 170
   at OmniSharp.Roslyn.CSharp.Services.Refactoring.V2.BaseCodeActionService`2.AppendFixesAsync(Document document, TextSpan span, IEnumerable`1 diagnostics, List`1 codeActions) in /home/vsts/work/1/s/src/OmniSharp.Roslyn.CSharp/Services/Refactoring/V2/BaseCodeActionService.cs:line 142
   at OmniSharp.Roslyn.CSharp.Services.Refactoring.V2.BaseCodeActionService`2.CollectCodeFixesActions(Document document, TextSpan span, List`1 codeActions) in /home/vsts/work/1/s/src/OmniSharp.Roslyn.CSharp/Services/Refactoring/V2/BaseCodeActionService.cs:line 134
   at OmniSharp.Roslyn.CSharp.Services.Refactoring.V2.BaseCodeActionService`2.GetAvailableCodeActions(ICodeActionRequest request) in /home/vsts/work/1/s/src/OmniSharp.Roslyn.CSharp/Services/Refactoring/V2/BaseCodeActionService.cs:line 86
   at OmniSharp.Roslyn.CSharp.Services.Refactoring.V2.GetCodeActionsService.Handle(GetCodeActionsRequest request) in /home/vsts/work/1/s/src/OmniSharp.Roslyn.CSharp/Services/Refactoring/V2/GetCodeActionsService.cs:line 34
   at OmniSharp.Endpoint.EndpointHandler`2.GetFirstNotEmptyResponseFromHandlers(ExportHandler`2[] handlers, TRequest request) in /home/vsts/work/1/s/src/OmniSharp.Host/Endpoint/EndpointHandler.cs:line 200
   at OmniSharp.Endpoint.EndpointHandler`2.HandleRequestForLanguage(String language, TRequest request, RequestPacket packet) in /home/vsts/work/1/s/src/OmniSharp.Host/Endpoint/EndpointHandler.cs:line 229
   at OmniSharp.Endpoint.EndpointHandler`2.Process(RequestPacket packet, LanguageModel model, JToken requestObject) in /home/vsts/work/1/s/src/OmniSharp.Host/Endpoint/EndpointHandler.cs:line 130
   at OmniSharp.Stdio.Host.HandleRequest(String json, ILogger logger) in /home/vsts/work/1/s/src/OmniSharp.Stdio/Host.cs:line 218
System.TypeLoadException: Access is denied: 'Microsoft.AspNetCore.Razor.PooledObjects.PooledObject`1[System.Collections.Immutable.ImmutableArray`1+Builder[Microsoft.AspNetCore.Razor.Language.SourceMapping]]'.

Questions

  • Is my setup broken or missing something?
  • Do I need .NET 6 SDK installed as well?

mkorsukov avatar Mar 22 '24 16:03 mkorsukov

Having the same issue. Also described here: https://github.com/dotnet/vscode-csharp/issues/6914 I would love to see a fix or workaround.

1h-me avatar Mar 23 '24 18:03 1h-me

Having the same issue

garrettlondon1 avatar Mar 23 '24 23:03 garrettlondon1

I made a couple experiments on clean virtual machines.

Experiment 1

  • Linux Mint Cinnamon 21.2
  • .NET 8.0.103
  • VS Codium 1.87.2
  • C# extension (by muhammad-sammy) 2.22.3
  • O# 1.39.11-net6.0

I made two projects with dotnet new command: console and MVC. Opened in VS Codium and all code actions and debugging work fine without any issues (clean logs as well).

VS Codium settings:

image

Look, there is no dotnet.server.useOmnisharp option in settings above. And everything works good.

UPDATE: After C# extension update to 2.22.5, OmniSharp stops working normally 😞

Experiment 2

  • Linux Mint Cinnamon 21.2
  • .NET 8.0.103
  • VS Code 1.87.2
  • C# extension (by Microsoft) 2.22.5
  • O# 1.39.11-net6.0

After opening a folder with MVC project in VS Code, the OmniSharp extension didn't start at all like it wasn't installed. VS Code settings had no dotnet.server.useOmnisharp option. I set it with true, then OmniSharp started and worked without any issues (clean logs as well).

VS Code settings:

image

mkorsukov avatar Mar 24 '24 02:03 mkorsukov

Same issue after updating C# extension to 2.23.15.

OmniSharp server started with .NET 8.0.202
  Path: /home/max/.vscode/extensions/ms-dotnettools.csharp-2.23.15-linux-x64/.omnisharp/1.39.11-net6.0/OmniSharp.dll
  PID: 43852

mkorsukov avatar Apr 02 '24 23:04 mkorsukov

Dear OmniSharp team, were you able to reproduce the issue? Editing, autocomplete and refactoring features are very important for successfull programming. Maybe there is a workaround available?

mkorsukov avatar Apr 15 '24 19:04 mkorsukov

same issue

my errors looked the same at first but then i changed a bunch of settings to no avail and now they look like

[Warn  - 28:53:54 AM] OmniSharp.Roslyn.CSharp.Services.Navigation.FindUsagesService: No symbol found. File: censored.cs, Line: 12, Column: 19. |
[Warn  - 28:53:54 AM] OmniSharp.Roslyn.CSharp.Services.Navigation.FindUsagesService: No symbol found. File: censored.cs, Line: 12, Column: 19. |
[Error - 28:53:54 AM] OmniSharp.Extensions.JsonRpc.DefaultRequestInvoker: Failed to handle request textDocument/codeAction 109 - System.Reflection.ReflectionTypeLoadException: Unable to load one or more of the requested types.
Access is denied: 'Microsoft.AspNetCore.Razor.PooledObjects.PooledObject`1[System.Collections.Immutable.ImmutableArray`1+Builder[Microsoft.AspNetCore.Razor.Language.SourceMapping]]'.
Access is denied: 'Microsoft.AspNetCore.Razor.PooledObjects.PooledObject`1[System.Collections.Immutable.ImmutableArray`1+Builder[Microsoft.AspNetCore.Razor.Language.SourceMapping]]'.
   at System.Reflection.RuntimeModule.GetTypes(RuntimeModule module)
   at System.Reflection.RuntimeAssembly.get_DefinedTypes()
   at System.Linq.Enumerable.SelectManySingleSelectorIterator`2.MoveNext()
   at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()
   at System.Linq.Enumerable.WhereEnumerableIterator`1.MoveNext()
   at System.Collections.Generic.LargeArrayBuilder`1.AddRange(IEnumerable`1 items)
   at System.Collections.Generic.SparseArrayBuilder`1.ReserveOrAdd(IEnumerable`1 items)
   at System.Linq.Enumerable.Concat2Iterator`1.ToArray()
   at System.Collections.Immutable.ImmutableArray.CreateRange[T](IEnumerable`1 items)
   at OmniSharp.Roslyn.CSharp.Services.Refactoring.V2.CachingCodeFixProviderForProjects.LoadFrom(Project project) in /home/vsts/work/1/s/src/OmniSharp.Roslyn.CSharp/Services/Refactoring/V2/CachingCodeFixProviderForProjects.cs:line 95
   at OmniSharp.Roslyn.CSharp.Services.Refactoring.V2.CachingCodeFixProviderForProjects.GetAllCodeFixesForProject(ProjectId projectId) in /home/vsts/work/1/s/src/OmniSharp.Roslyn.CSharp/Services/Refactoring/V2/CachingCodeFixProviderForProjects.cs:line 57
   at OmniSharp.Roslyn.CSharp.Services.Refactoring.V2.BaseCodeActionService`2.GetSortedCodeFixProviders(Document document) in /home/vsts/work/1/s/src/OmniSharp.Roslyn.CSharp/Services/Refactoring/V2/BaseCodeActionService.cs:line 170
   at OmniSharp.Roslyn.CSharp.Services.Refactoring.V2.BaseCodeActionService`2.AppendFixesAsync(Document document, TextSpan span, IEnumerable`1 diagnostics, List`1 codeActions) in /home/vsts/work/1/s/src/OmniSharp.Roslyn.CSharp/Services/Refactoring/V2/BaseCodeActionService.cs:line 142
   at OmniSharp.Roslyn.CSharp.Services.Refactoring.V2.BaseCodeActionService`2.CollectCodeFixesActions(Document document, TextSpan span, List`1 codeActions) in /home/vsts/work/1/s/src/OmniSharp.Roslyn.CSharp/Services/Refactoring/V2/BaseCodeActionService.cs:line 134
   at OmniSharp.Roslyn.CSharp.Services.Refactoring.V2.BaseCodeActionService`2.GetAvailableCodeActions(ICodeActionRequest request) in /home/vsts/work/1/s/src/OmniSharp.Roslyn.CSharp/Services/Refactoring/V2/BaseCodeActionService.cs:line 86
   at OmniSharp.Roslyn.CSharp.Services.Refactoring.V2.GetCodeActionsService.Handle(GetCodeActionsRequest request) in /home/vsts/work/1/s/src/OmniSharp.Roslyn.CSharp/Services/Refactoring/V2/GetCodeActionsService.cs:line 34
   at OmniSharp.LanguageServerProtocol.Handlers.OmniSharpCodeActionHandler.Handle(CodeActionParams request, CancellationToken cancellationToken) in /home/vsts/work/1/s/src/OmniSharp.LanguageServerProtocol/Handlers/OmniSharpCodeActionHandler.cs:line 70
   at OmniSharp.Extensions.LanguageServer.Server.Pipelines.SemanticTokensDeltaPipeline`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at OmniSharp.Extensions.LanguageServer.Server.Pipelines.ResolveCommandPipeline`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at MediatR.Pipeline.RequestPreProcessorBehavior`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at MediatR.Pipeline.RequestPostProcessorBehavior`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at MediatR.Pipeline.RequestExceptionProcessorBehavior`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at MediatR.Pipeline.RequestExceptionProcessorBehavior`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at MediatR.Pipeline.RequestExceptionActionProcessorBehavior`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at MediatR.Pipeline.RequestExceptionActionProcessorBehavior`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at OmniSharp.Extensions.JsonRpc.RequestRouterBase`1.<RouteRequest>g__InnerRoute|7_0(IServiceScopeFactory serviceScopeFactory, Request request, TDescriptor descriptor, Object params, CancellationToken token, ILogger logger)
   at OmniSharp.Extensions.JsonRpc.RequestRouterBase`1.RouteRequest(IRequestDescriptor`1 descriptors, Request request, CancellationToken token)
   at OmniSharp.Extensions.JsonRpc.DefaultRequestInvoker.<>c__DisplayClass10_0.<<RouteRequest>b__5>d.MoveNext()
System.TypeLoadException: Access is denied: 'Microsoft.AspNetCore.Razor.PooledObjects.PooledObject`1[System.Collections.Immutable.ImmutableArray`1+Builder[Microsoft.AspNetCore.Razor.Language.SourceMapping]]'.
System.TypeLoadException: Access is denied: 'Microsoft.AspNetCore.Razor.PooledObjects.PooledObject`1[System.Collections.Immutable.ImmutableArray`1+Builder[Microsoft.AspNetCore.Razor.Language.SourceMapping]]'. | Method='textDocument/codeAction' RequestId='109'
[Error - 28:53:54 AM] Request textDocument/codeAction failed.
  Message: Internal Error - System.Reflection.ReflectionTypeLoadException: Unable to load one or more of the requested types.
Access is denied: 'Microsoft.AspNetCore.Razor.PooledObjects.PooledObject`1[System.Collections.Immutable.ImmutableArray`1+Builder[Microsoft.AspNetCore.Razor.Language.SourceMapping]]'.
Access is denied: 'Microsoft.AspNetCore.Razor.PooledObjects.PooledObject`1[System.Collections.Immutable.ImmutableArray`1+Builder[Microsoft.AspNetCore.Razor.Language.SourceMapping]]'.
   at System.Reflection.RuntimeModule.GetTypes(RuntimeModule module)
   at System.Reflection.RuntimeAssembly.get_DefinedTypes()
   at System.Linq.Enumerable.SelectManySingleSelectorIterator`2.MoveNext()
   at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()
   at System.Linq.Enumerable.WhereEnumerableIterator`1.MoveNext()
   at System.Collections.Generic.LargeArrayBuilder`1.AddRange(IEnumerable`1 items)
   at System.Collections.Generic.SparseArrayBuilder`1.ReserveOrAdd(IEnumerable`1 items)
   at System.Linq.Enumerable.Concat2Iterator`1.ToArray()
   at System.Collections.Immutable.ImmutableArray.CreateRange[T](IEnumerable`1 items)
   at OmniSharp.Roslyn.CSharp.Services.Refactoring.V2.CachingCodeFixProviderForProjects.LoadFrom(Project project) in /home/vsts/work/1/s/src/OmniSharp.Roslyn.CSharp/Services/Refactoring/V2/CachingCodeFixProviderForProjects.cs:line 95
   at OmniSharp.Roslyn.CSharp.Services.Refactoring.V2.CachingCodeFixProviderForProjects.GetAllCodeFixesForProject(ProjectId projectId) in /home/vsts/work/1/s/src/OmniSharp.Roslyn.CSharp/Services/Refactoring/V2/CachingCodeFixProviderForProjects.cs:line 57
   at OmniSharp.Roslyn.CSharp.Services.Refactoring.V2.BaseCodeActionService`2.GetSortedCodeFixProviders(Document document) in /home/vsts/work/1/s/src/OmniSharp.Roslyn.CSharp/Services/Refactoring/V2/BaseCodeActionService.cs:line 170
   at OmniSharp.Roslyn.CSharp.Services.Refactoring.V2.BaseCodeActionService`2.AppendFixesAsync(Document document, TextSpan span, IEnumerable`1 diagnostics, List`1 codeActions) in /home/vsts/work/1/s/src/OmniSharp.Roslyn.CSharp/Services/Refactoring/V2/BaseCodeActionService.cs:line 142
   at OmniSharp.Roslyn.CSharp.Services.Refactoring.V2.BaseCodeActionService`2.CollectCodeFixesActions(Document document, TextSpan span, List`1 codeActions) in /home/vsts/work/1/s/src/OmniSharp.Roslyn.CSharp/Services/Refactoring/V2/BaseCodeActionService.cs:line 134
   at OmniSharp.Roslyn.CSharp.Services.Refactoring.V2.BaseCodeActionService`2.GetAvailableCodeActions(ICodeActionRequest request) in /home/vsts/work/1/s/src/OmniSharp.Roslyn.CSharp/Services/Refactoring/V2/BaseCodeActionService.cs:line 86
   at OmniSharp.Roslyn.CSharp.Services.Refactoring.V2.GetCodeActionsService.Handle(GetCodeActionsRequest request) in /home/vsts/work/1/s/src/OmniSharp.Roslyn.CSharp/Services/Refactoring/V2/GetCodeActionsService.cs:line 34
   at OmniSharp.LanguageServerProtocol.Handlers.OmniSharpCodeActionHandler.Handle(CodeActionParams request, CancellationToken cancellationToken) in /home/vsts/work/1/s/src/OmniSharp.LanguageServerProtocol/Handlers/OmniSharpCodeActionHandler.cs:line 70
   at OmniSharp.Extensions.LanguageServer.Server.Pipelines.SemanticTokensDeltaPipeline`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at OmniSharp.Extensions.LanguageServer.Server.Pipelines.ResolveCommandPipeline`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at MediatR.Pipeline.RequestPreProcessorBehavior`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at MediatR.Pipeline.RequestPostProcessorBehavior`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at MediatR.Pipeline.RequestExceptionProcessorBehavior`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at MediatR.Pipeline.RequestExceptionProcessorBehavior`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at MediatR.Pipeline.RequestExceptionActionProcessorBehavior`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at MediatR.Pipeline.RequestExceptionActionProcessorBehavior`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at OmniSharp.Extensions.JsonRpc.RequestRouterBase`1.<RouteRequest>g__InnerRoute|7_0(IServiceScopeFactory serviceScopeFactory, Request request, TDescriptor descriptor, Object params, CancellationToken token, ILogger logger)
   at OmniSharp.Extensions.JsonRpc.RequestRouterBase`1.RouteRequest(IRequestDescriptor`1 descriptors, Request request, CancellationToken token)
   at OmniSharp.Extensions.JsonRpc.DefaultRequestInvoker.<>c__DisplayClass10_0.<<RouteRequest>b__5>d.MoveNext()
System.TypeLoadException: Access is denied: 'Microsoft.AspNetCore.Razor.PooledObjects.PooledObject`1[System.Collections.Immutable.ImmutableArray`1+Builder[Microsoft.AspNetCore.Razor.Language.SourceMapping]]'.
System.TypeLoadException: Access is denied: 'Microsoft.AspNetCore.Razor.PooledObjects.PooledObject`1[System.Collections.Immutable.ImmutableArray`1+Builder[Microsoft.AspNetCore.Razor.Language.SourceMapping]]'.
  Code: -32603
[Error - 28:53:55 AM] OmniSharp.Extensions.JsonRpc.DefaultRequestInvoker: Failed to handle request textDocument/codeAction 110 - System.Reflection.ReflectionTypeLoadException: Unable to load one or more of the requested types.
Access is denied: 'Microsoft.AspNetCore.Razor.PooledObjects.PooledObject`1[System.Collections.Immutable.ImmutableArray`1+Builder[Microsoft.AspNetCore.Razor.Language.SourceMapping]]'.
Access is denied: 'Microsoft.AspNetCore.Razor.PooledObjects.PooledObject`1[System.Collections.Immutable.ImmutableArray`1+Builder[Microsoft.AspNetCore.Razor.Language.SourceMapping]]'.
   at System.Reflection.RuntimeModule.GetTypes(RuntimeModule module)
   at System.Reflection.RuntimeAssembly.get_DefinedTypes()
   at System.Linq.Enumerable.SelectManySingleSelectorIterator`2.MoveNext()
   at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()
   at System.Linq.Enumerable.WhereEnumerableIterator`1.MoveNext()
   at System.Collections.Generic.LargeArrayBuilder`1.AddRange(IEnumerable`1 items)
   at System.Collections.Generic.SparseArrayBuilder`1.ReserveOrAdd(IEnumerable`1 items)
   at System.Linq.Enumerable.Concat2Iterator`1.ToArray()
   at System.Collections.Immutable.ImmutableArray.CreateRange[T](IEnumerable`1 items)
   at OmniSharp.Roslyn.CSharp.Services.Refactoring.V2.CachingCodeFixProviderForProjects.LoadFrom(Project project) in /home/vsts/work/1/s/src/OmniSharp.Roslyn.CSharp/Services/Refactoring/V2/CachingCodeFixProviderForProjects.cs:line 95
   at OmniSharp.Roslyn.CSharp.Services.Refactoring.V2.CachingCodeFixProviderForProjects.GetAllCodeFixesForProject(ProjectId projectId) in /home/vsts/work/1/s/src/OmniSharp.Roslyn.CSharp/Services/Refactoring/V2/CachingCodeFixProviderForProjects.cs:line 57
   at OmniSharp.Roslyn.CSharp.Services.Refactoring.V2.BaseCodeActionService`2.GetSortedCodeFixProviders(Document document) in /home/vsts/work/1/s/src/OmniSharp.Roslyn.CSharp/Services/Refactoring/V2/BaseCodeActionService.cs:line 170
   at OmniSharp.Roslyn.CSharp.Services.Refactoring.V2.BaseCodeActionService`2.AppendFixesAsync(Document document, TextSpan span, IEnumerable`1 diagnostics, List`1 codeActions) in /home/vsts/work/1/s/src/OmniSharp.Roslyn.CSharp/Services/Refactoring/V2/BaseCodeActionService.cs:line 142
   at OmniSharp.Roslyn.CSharp.Services.Refactoring.V2.BaseCodeActionService`2.CollectCodeFixesActions(Document document, TextSpan span, List`1 codeActions) in /home/vsts/work/1/s/src/OmniSharp.Roslyn.CSharp/Services/Refactoring/V2/BaseCodeActionService.cs:line 134
   at OmniSharp.Roslyn.CSharp.Services.Refactoring.V2.BaseCodeActionService`2.GetAvailableCodeActions(ICodeActionRequest request) in /home/vsts/work/1/s/src/OmniSharp.Roslyn.CSharp/Services/Refactoring/V2/BaseCodeActionService.cs:line 86
   at OmniSharp.Roslyn.CSharp.Services.Refactoring.V2.GetCodeActionsService.Handle(GetCodeActionsRequest request) in /home/vsts/work/1/s/src/OmniSharp.Roslyn.CSharp/Services/Refactoring/V2/GetCodeActionsService.cs:line 34
   at OmniSharp.LanguageServerProtocol.Handlers.OmniSharpCodeActionHandler.Handle(CodeActionParams request, CancellationToken cancellationToken) in /home/vsts/work/1/s/src/OmniSharp.LanguageServerProtocol/Handlers/OmniSharpCodeActionHandler.cs:line 70
   at OmniSharp.Extensions.LanguageServer.Server.Pipelines.SemanticTokensDeltaPipeline`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at OmniSharp.Extensions.LanguageServer.Server.Pipelines.ResolveCommandPipeline`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at MediatR.Pipeline.RequestPreProcessorBehavior`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at MediatR.Pipeline.RequestPostProcessorBehavior`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at MediatR.Pipeline.RequestExceptionProcessorBehavior`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at MediatR.Pipeline.RequestExceptionProcessorBehavior`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at MediatR.Pipeline.RequestExceptionActionProcessorBehavior`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at MediatR.Pipeline.RequestExceptionActionProcessorBehavior`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at OmniSharp.Extensions.JsonRpc.RequestRouterBase`1.<RouteRequest>g__InnerRoute|7_0(IServiceScopeFactory serviceScopeFactory, Request request, TDescriptor descriptor, Object params, CancellationToken token, ILogger logger)
   at OmniSharp.Extensions.JsonRpc.RequestRouterBase`1.RouteRequest(IRequestDescriptor`1 descriptors, Request request, CancellationToken token)
   at OmniSharp.Extensions.JsonRpc.DefaultRequestInvoker.<>c__DisplayClass10_0.<<RouteRequest>b__5>d.MoveNext()
System.TypeLoadException: Access is denied: 'Microsoft.AspNetCore.Razor.PooledObjects.PooledObject`1[System.Collections.Immutable.ImmutableArray`1+Builder[Microsoft.AspNetCore.Razor.Language.SourceMapping]]'.
System.TypeLoadException: Access is denied: 'Microsoft.AspNetCore.Razor.PooledObjects.PooledObject`1[System.Collections.Immutable.ImmutableArray`1+Builder[Microsoft.AspNetCore.Razor.Language.SourceMapping]]'. | Method='textDocument/codeAction' RequestId='110'
[Error - 28:53:55 AM] Request textDocument/codeAction failed.
  Message: Internal Error - System.Reflection.ReflectionTypeLoadException: Unable to load one or more of the requested types.
Access is denied: 'Microsoft.AspNetCore.Razor.PooledObjects.PooledObject`1[System.Collections.Immutable.ImmutableArray`1+Builder[Microsoft.AspNetCore.Razor.Language.SourceMapping]]'.
Access is denied: 'Microsoft.AspNetCore.Razor.PooledObjects.PooledObject`1[System.Collections.Immutable.ImmutableArray`1+Builder[Microsoft.AspNetCore.Razor.Language.SourceMapping]]'.
   at System.Reflection.RuntimeModule.GetTypes(RuntimeModule module)
   at System.Reflection.RuntimeAssembly.get_DefinedTypes()
   at System.Linq.Enumerable.SelectManySingleSelectorIterator`2.MoveNext()
   at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()
   at System.Linq.Enumerable.WhereEnumerableIterator`1.MoveNext()
   at System.Collections.Generic.LargeArrayBuilder`1.AddRange(IEnumerable`1 items)
   at System.Collections.Generic.SparseArrayBuilder`1.ReserveOrAdd(IEnumerable`1 items)
   at System.Linq.Enumerable.Concat2Iterator`1.ToArray()
   at System.Collections.Immutable.ImmutableArray.CreateRange[T](IEnumerable`1 items)
   at OmniSharp.Roslyn.CSharp.Services.Refactoring.V2.CachingCodeFixProviderForProjects.LoadFrom(Project project) in /home/vsts/work/1/s/src/OmniSharp.Roslyn.CSharp/Services/Refactoring/V2/CachingCodeFixProviderForProjects.cs:line 95
   at OmniSharp.Roslyn.CSharp.Services.Refactoring.V2.CachingCodeFixProviderForProjects.GetAllCodeFixesForProject(ProjectId projectId) in /home/vsts/work/1/s/src/OmniSharp.Roslyn.CSharp/Services/Refactoring/V2/CachingCodeFixProviderForProjects.cs:line 57
   at OmniSharp.Roslyn.CSharp.Services.Refactoring.V2.BaseCodeActionService`2.GetSortedCodeFixProviders(Document document) in /home/vsts/work/1/s/src/OmniSharp.Roslyn.CSharp/Services/Refactoring/V2/BaseCodeActionService.cs:line 170
   at OmniSharp.Roslyn.CSharp.Services.Refactoring.V2.BaseCodeActionService`2.AppendFixesAsync(Document document, TextSpan span, IEnumerable`1 diagnostics, List`1 codeActions) in /home/vsts/work/1/s/src/OmniSharp.Roslyn.CSharp/Services/Refactoring/V2/BaseCodeActionService.cs:line 142
   at OmniSharp.Roslyn.CSharp.Services.Refactoring.V2.BaseCodeActionService`2.CollectCodeFixesActions(Document document, TextSpan span, List`1 codeActions) in /home/vsts/work/1/s/src/OmniSharp.Roslyn.CSharp/Services/Refactoring/V2/BaseCodeActionService.cs:line 134
   at OmniSharp.Roslyn.CSharp.Services.Refactoring.V2.BaseCodeActionService`2.GetAvailableCodeActions(ICodeActionRequest request) in /home/vsts/work/1/s/src/OmniSharp.Roslyn.CSharp/Services/Refactoring/V2/BaseCodeActionService.cs:line 86
   at OmniSharp.Roslyn.CSharp.Services.Refactoring.V2.GetCodeActionsService.Handle(GetCodeActionsRequest request) in /home/vsts/work/1/s/src/OmniSharp.Roslyn.CSharp/Services/Refactoring/V2/GetCodeActionsService.cs:line 34
   at OmniSharp.LanguageServerProtocol.Handlers.OmniSharpCodeActionHandler.Handle(CodeActionParams request, CancellationToken cancellationToken) in /home/vsts/work/1/s/src/OmniSharp.LanguageServerProtocol/Handlers/OmniSharpCodeActionHandler.cs:line 70
   at OmniSharp.Extensions.LanguageServer.Server.Pipelines.SemanticTokensDeltaPipeline`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at OmniSharp.Extensions.LanguageServer.Server.Pipelines.ResolveCommandPipeline`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at MediatR.Pipeline.RequestPreProcessorBehavior`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at MediatR.Pipeline.RequestPostProcessorBehavior`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at MediatR.Pipeline.RequestExceptionProcessorBehavior`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at MediatR.Pipeline.RequestExceptionProcessorBehavior`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at MediatR.Pipeline.RequestExceptionActionProcessorBehavior`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at MediatR.Pipeline.RequestExceptionActionProcessorBehavior`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at OmniSharp.Extensions.JsonRpc.RequestRouterBase`1.<RouteRequest>g__InnerRoute|7_0(IServiceScopeFactory serviceScopeFactory, Request request, TDescriptor descriptor, Object params, CancellationToken token, ILogger logger)
   at OmniSharp.Extensions.JsonRpc.RequestRouterBase`1.RouteRequest(IRequestDescriptor`1 descriptors, Request request, CancellationToken token)
   at OmniSharp.Extensions.JsonRpc.DefaultRequestInvoker.<>c__DisplayClass10_0.<<RouteRequest>b__5>d.MoveNext()
System.TypeLoadException: Access is denied: 'Microsoft.AspNetCore.Razor.PooledObjects.PooledObject`1[System.Collections.Immutable.ImmutableArray`1+Builder[Microsoft.AspNetCore.Razor.Language.SourceMapping]]'.
System.TypeLoadException: Access is denied: 'Microsoft.AspNetCore.Razor.PooledObjects.PooledObject`1[System.Collections.Immutable.ImmutableArray`1+Builder[Microsoft.AspNetCore.Razor.Language.SourceMapping]]'.
  Code: -32603

i'm not using Razor explicitly but i can't figure out how to make omnisharp ignore it...

am-katzest avatar Apr 29 '24 00:04 am-katzest

Issue still exists after upgrade to 2.28.11.

mkorsukov avatar May 08 '24 13:05 mkorsukov

+1. Lots of Access is denied: 'Microsoft.AspNetCore.Razor.PooledObjects.PooledObject errors on 2.29.11.

TrieBr avatar May 10 '24 17:05 TrieBr

Looks like OmniSharp is trying to load internal PooledObject<T> type from the Microsoft.AspNetCore.Razor.Utilities.Shared assembly using reflection. Maybe there is an incorrect referencing of assembly or its version?

Here are findings of that assembly(es):

~/.vscode/extensions/ms-dotnettools.csharp-2.28.11-linux-x64

  • ./.razor/Microsoft.AspNetCore.Razor.Utilities.Shared.dll 7.0.0-preview.24178.4
  • ./.razoromnisharp/Microsoft.AspNetCore.Razor.Utilities.Shared.dll 7.0.0-preview.23363.1
  • ./.razoromnisharp/OmniSharpPlugin/Microsoft.AspNetCore.Razor.Utilities.Shared.dll 7.0.0-preview.23363.1
  • ./.roslyn/Microsoft.AspNetCore.Razor.Utilities.Shared.dll unknown

mkorsukov avatar May 10 '24 18:05 mkorsukov

In my .Net 6 project in VS Code, I was able to circumvent the loss of functionality (and all of the errors in the console) by overriding the .Net SDK version being used. This was in the workspace settings as follows:

"omnisharp.sdkVersion": "6.0.421"

Although I have .Net 8 SDK installed, it appears that the failures occur when you try to use a .Net 8 SDK (on my machine, that would be 8.0.204). Once I forced VS Code to use 6.0.421, so far it seems everything is back to the way it worked before I ever installed .Net 8 SDK on my PC.

Of course, for my .Net 8 based projects, this is not an ideal workaround...

Londovir avatar May 13 '24 18:05 Londovir

"omnisharp.sdkVersion": "6.0.421"

How do you determine the proper version number? I have .NET 7 projects (although I have .NET 8 installed) that I am having problems with.

terryaney avatar May 14 '24 00:05 terryaney

One way is you can look at the Omnisharp console window in VS Code. When Omnisharp launches, it will enumerate all of the detected SDK versions, and you can spot it from there.

Additionally, I was able to drop to a command prompt and run the command "dotnet --list-sdks", which provided the same information.

Londovir avatar May 14 '24 00:05 Londovir

Unless you need Razor one solution is to set "razor.plugin.path": "blablabla",. That way it won't try to load Razor assemblies

seesharper avatar May 15 '24 21:05 seesharper

Issue still exists after extension upgrade to 2.30.28.

mkorsukov avatar May 21 '24 19:05 mkorsukov

If you set dotnet.server.path to the value latest in VS Code settings, this should install the latest development build of O#. In that build we have moved to a newer Roslyn and removed the Razor external access library (was required for a time, but may now be causing the opposite problem). Do you see this same issue?

JoeRobich avatar May 24 '24 22:05 JoeRobich

Thank you @JoeRobich for an idea, but still same issue(s) after trying that workaround.

Some logs from update.

C#

Getting latest OmniSharp version information
Downloading package 'Latest OmniSharp Version Information' (1 KB).................... Done!
Installing OmniSharp Version = 1.39.12-beta.9...
Platform: linux, x86_64, name=ubuntu, version=20.04

Downloading package 'OmniSharp for Linux (.NET 6 / x64), Version = 1.39.12-beta.9' (47601 KB).................... Done!
Installing package 'OmniSharp for Linux (.NET 6 / x64), Version = 1.39.12-beta.9'

Finished

OmniSharp

OmniSharp server started with .NET 8.0.300
    Path: /home/max/.vscode/extensions/ms-dotnettools.csharp-2.30.28-linux-x64/.omnisharp/1.39.12-beta.9-net6.0/OmniSharp.dll

mkorsukov avatar May 25 '24 22:05 mkorsukov

Updated to latest 2.31.19. Situation is similar as listed above. However, an issue relates to new dependencies.

Startup logs:

OmniSharp server started with .NET 8.0.300
.
    Path: /home/max/.vscode/extensions/ms-dotnettools.csharp-2.31.19-linux-x64/.omnisharp/1.39.12-beta.9-net6.0/OmniSharp.dll
    PID: 6091

[fail]: OmniSharp.MSBuild.ProjectManager
        Failure while loading the analyzer reference 'Microsoft.Extensions.Logging.Generators': Unable to load Microsoft.Extensions.Logging.Generators
[fail]: OmniSharp.MSBuild.ProjectManager
        Failure while loading the analyzer reference 'Microsoft.Extensions.Logging.Generators': Unable to load Microsoft.Extensions.Logging.Generators
[fail]: OmniSharp.Stdio.Host

Code intellisense logs (/v2/getcodeactions):

System.InvalidOperationException: Unable to load Microsoft.Extensions.Logging.Generators
 ---> System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.Extensions.Logging.Generators, Version=8.0.10.21615, Culture=neutral, PublicKeyToken=adb9793829ddae60'. The system cannot find the file specified.

File name: 'Microsoft.Extensions.Logging.Generators, Version=8.0.10.21615, Culture=neutral, PublicKeyToken=adb9793829ddae60'

mkorsukov avatar May 30 '24 14:05 mkorsukov

Same issue after update to 2.33.17.

Startup log:

OmniSharp server started with .NET 8.0.301
.
    Path: /home/max/.vscode/extensions/ms-dotnettools.csharp-2.33.17-linux-x64/.omnisharp/1.39.12-beta.9-net6.0/OmniSharp.dll
    PID: 39271

[fail]: OmniSharp.MSBuild.ProjectManager
        Failure while loading the analyzer reference 'Microsoft.Extensions.Logging.Generators': Unable to load Microsoft.Extensions.Logging.Generators
[fail]: OmniSharp.MSBuild.ProjectManager
        Failure while loading the analyzer reference 'Microsoft.Extensions.Logging.Generators': Unable to load Microsoft.Extensions.Logging.Generators
[fail]: OmniSharp.MSBuild.ProjectManager
        Failure while loading the analyzer reference 'Microsoft.Extensions.Logging.Generators': Unable to load Microsoft.Extensions.Logging.Generators
[fail]: OmniSharp.Stdio.Host

Exception log:

System.InvalidOperationException: Unable to load Microsoft.Extensions.Logging.Generators
 ---> System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.Extensions.Logging.Generators, Version=8.0.10.26715, Culture=neutral, PublicKeyToken=adb9793829ddae60

mkorsukov avatar Jun 12 '24 20:06 mkorsukov

I just got the same issue, And it's random, meaning Some code completions work but not all of them.

[fail]: OmniSharp.Stdio.Host
        ************  Response (3.9963ms) ************ 
{
  "Request_seq": 100,
  "Command": "/v2/getcodeactions",
  "Running": true,
  "Success": false,
  "Message": "\"System.Reflection.ReflectionTypeLoadException: Unable to load one or more of the requested types.\\r\\nAccess is denied: 'Microsoft.AspNetCore.Razor.PooledObjects.PooledObject`1[System.Collections.Immutable.ImmutableArray`1+Builder[Microsoft.AspNetCore.Razor.Language.SourceMapping]]'.\\r\\nAccess is denied: 'Microsoft.AspNetCore.Razor.PooledObjects.PooledObject`1[System.Collections.Immutable.ImmutableArray`1+Builder[Microsoft.AspNetCore.Razor.Language.SourceMapping]]'.\\r\\n   at System.Reflection.RuntimeModule.GetTypes(RuntimeModule module)\\r\\n   at System.Reflection.RuntimeAssembly.get_DefinedTypes()\\r\\n   at System.Linq.Enumerable.SelectManySingleSelectorIterator`2.MoveNext()\\r\\n   at System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()\\r\\n   at System.Linq.Enumerable.WhereEnumerableIterator`1.MoveNext()\\r\\n   at System.Collections.Generic.LargeArrayBuilder`1.AddRange(IEnumerable`1 items)\\r\\n   at System.Collections.Generic.SparseArrayBuilder`1.ReserveOrAdd(IEnumerable`1 items)\\r\\n   at System.Linq.Enumerable.Concat2Iterator`1.ToArray()\\r\\n   at System.Collections.Immutable.ImmutableArray.CreateRange[T](IEnumerable`1 items)\\r\\n   at OmniSharp.Roslyn.CSharp.Services.Refactoring.V2.CachingCodeFixProviderForProjects.LoadFrom(Project project) in D:\\\\a\\\\1\\\\s\\\\src\\\\OmniSharp.Roslyn.CSharp\\\\Services\\\\Refactoring\\\\V2\\\\CachingCodeFixProviderForProjects.cs:line 95\\r\\n   at OmniSharp.Roslyn.CSharp.Services.Refactoring.V2.CachingCodeFixProviderForProjects.GetAllCodeFixesForProject(ProjectId projectId) in D:\\\\a\\\\1\\\\s\\\\src\\\\OmniSharp.Roslyn.CSharp\\\\Services\\\\Refactoring\\\\V2\\\\CachingCodeFixProviderForProjects.cs:line 57\\r\\n   at OmniSharp.Roslyn.CSharp.Services.Refactoring.V2.BaseCodeActionService`2.GetSortedCodeFixProviders(Document document) in D:\\\\a\\\\1\\\\s\\\\src\\\\OmniSharp.Roslyn.CSharp\\\\Services\\\\Refactoring\\\\V2\\\\BaseCodeActionService.cs:line 170\\r\\n   at OmniSharp.Roslyn.CSharp.Services.Refactoring.V2.BaseCodeActionService`2.AppendFixesAsync(Document document, TextSpan span, IEnumerable`1 diagnostics, List`1 codeActions) in D:\\\\a\\\\1\\\\s\\\\src\\\\OmniSharp.Roslyn.CSharp\\\\Services\\\\Refactoring\\\\V2\\\\BaseCodeActionService.cs:line 142\\r\\n   at OmniSharp.Roslyn.CSharp.Services.Refactoring.V2.BaseCodeActionService`2.CollectCodeFixesActions(Document document, TextSpan span, List`1 codeActions) in D:\\\\a\\\\1\\\\s\\\\src\\\\OmniSharp.Roslyn.CSharp\\\\Services\\\\Refactoring\\\\V2\\\\BaseCodeActionService.cs:line 134\\r\\n   at OmniSharp.Roslyn.CSharp.Services.Refactoring.V2.BaseCodeActionService`2.GetAvailableCodeActions(ICodeActionRequest request) in D:\\\\a\\\\1\\\\s\\\\src\\\\OmniSharp.Roslyn.CSharp\\\\Services\\\\Refactoring\\\\V2\\\\BaseCodeActionService.cs:line 86\\r\\n   at OmniSharp.Roslyn.CSharp.Services.Refactoring.V2.GetCodeActionsService.Handle(GetCodeActionsRequest request) in D:\\\\a\\\\1\\\\s\\\\src\\\\OmniSharp.Roslyn.CSharp\\\\Services\\\\Refactoring\\\\V2\\\\GetCodeActionsService.cs:line 34\\r\\n   at OmniSharp.Endpoint.EndpointHandler`2.GetFirstNotEmptyResponseFromHandlers(ExportHandler`2[] handlers, TRequest request) in D:\\\\a\\\\1\\\\s\\\\src\\\\OmniSharp.Host\\\\Endpoint\\\\EndpointHandler.cs:line 200\\r\\n   at OmniSharp.Endpoint.EndpointHandler`2.HandleRequestForLanguage(String language, TRequest request, RequestPacket packet) in D:\\\\a\\\\1\\\\s\\\\src\\\\OmniSharp.Host\\\\Endpoint\\\\EndpointHandler.cs:line 229\\r\\n   at OmniSharp.Endpoint.EndpointHandler`2.Process(RequestPacket packet, LanguageModel model, JToken requestObject) in D:\\\\a\\\\1\\\\s\\\\src\\\\OmniSharp.Host\\\\Endpoint\\\\EndpointHandler.cs:line 130\\r\\n   at OmniSharp.Stdio.Host.HandleRequest(String json, ILogger logger) in D:\\\\a\\\\1\\\\s\\\\src\\\\OmniSharp.Stdio\\\\Host.cs:line 218\\r\\nSystem.TypeLoadException: Access is denied: 'Microsoft.AspNetCore.Razor.PooledObjects.PooledObject`1[System.Collections.Immutable.ImmutableArray`1+Builder[Microsoft.AspNetCore.Razor.Language.SourceMapping]]'.\\r\\nSystem.TypeLoadException: Access is denied: 'Microsoft.AspNetCore.Razor.PooledObjects.PooledObject`1[System.Collections.Immutable.ImmutableArray`1+Builder[Microsoft.AspNetCore.Razor.Language.SourceMapping]]'.\"",
  "Body": null,
  "Seq": 489,
  "Type": "response"
}

DanteMarshal avatar Jun 26 '24 10:06 DanteMarshal

I'm chasing this same issue, and here it seems specific to certain projects. I can remove a necessary using from a class in one project, and quick fix menu to restore it from one of the errors where it's needed, and in another project that same set of steps causes this error and I get nothing in the quick fix menu at all (the one where there's an error is a Web API project, and the one that works is a classlib project).

C# plugin version v2.39.29.

jeremy-allocate avatar Jul 24 '24 00:07 jeremy-allocate

Could someone on the omnisharp dev team please confirm that this is not an abandoned project? There have been no major bug fixes in 2024 from what I can see looking at the recently closed tickets, and these threads (including https://github.com/dotnet/vscode-csharp/issues/6914) have been open long enough that versions of the C# extension that don't have this issue seem to no longer even be available on nuget.

jeremy-allocate avatar Jul 25 '24 19:07 jeremy-allocate

@jeremy-allocate I wouldn't say this project is abandoned. However, I think it is fair to say this project has little energy and is in need of new contributors.

If O# is something that interests you, I encourage you to look at issues. If you are able to reproduce them and provide details, that is always helpful. If there are issues you want to tackle, then I can help provide guidance.

JoeRobich avatar Jul 25 '24 23:07 JoeRobich

I plan to do a release once I can get Roslyn updated. Changes in how they plumb options throughout their features has broken O# with recent builds. Until we have an official release you can set dotnet.server.path to latest in your VS Code settings to pull the rolling build of O#.

JoeRobich avatar Jul 26 '24 04:07 JoeRobich

Thanks for the invitation and the response @JoeRobich, much appreciated. I do have reason to be invested in the continued development of O#, so I'll see if I can scrape together the time to contribute in some way.

I tried your suggestion above about setting "dotnet.server.path" to "latest", and now I see a different error.

Downloading package 'OmniSharp for Linux (.NET 6 / x64), Version = 1.39.12-beta.9' (47601 KB).................... Done! Installing package 'OmniSharp for Linux (.NET 6 / x64), Version = 1.39.12-beta.9' ... "Message": ""System.InvalidOperationException: Unable to load System.Text.Json.SourceGeneration ---> System.IO.FileNotFoundException: Could not load file or assembly 'System.Text.Json.SourceGeneration, Version=8.0.10.31311, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'. The system cannot find the file specified. File name: 'System.Text.Json.SourceGeneration, Version=8.0.10.31311, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' at System.Reflection.RuntimeAssembly.<InternalLoad>g____PInvoke|49_0(NativeAssemblyNameParts* __pAssemblyNameParts_native, ObjectHandleOnStack __requestingAssembly_native, StackCrawlMarkHandle __stackMark_native, Int32 __throwOnFileNotFound_native, ObjectHandleOnStack __assemblyLoadContext_native, ObjectHandleOnStack __retAssembly_native) at System.Reflection.RuntimeAssembly.InternalLoad(AssemblyName assemblyName, StackCrawlMark& stackMark, AssemblyLoadContext assemblyLoadContext, RuntimeAssembly requestingAssembly, Boolean throwOnFileNotFound) at System.Reflection.Assembly.Load(AssemblyName assemblyRef) at System.AppDomain.Load(AssemblyName assemblyRef) at Microsoft.CodeAnalysis.AnalyzerAssemblyLoader.LoadFromPath(String originalAnalyzerPath) --- End of inner exception stack trace --- at Microsoft.CodeAnalysis.AnalyzerAssemblyLoader.LoadFromPath(String originalAnalyzerPath) at Microsoft.CodeAnalysis.Diagnostics.AnalyzerFileReference.GetAssembly() at OmniSharp.Roslyn.CSharp.Services.Refactoring.V2.CachingCodeFixProviderForProjects.<>c.<LoadFrom>b__6_0(AnalyzerFileReference analyzerFileReference) in /home/vsts/work/1/s/src/OmniSharp.Roslyn.CSharp/Services/Refactoring/V2/CachingCodeFixProviderForProjects.cs:line 64 at System.Linq.Enumerable.SelectManySingleSelectorIterator2.MoveNext() at System.Linq.Enumerable.WhereSelectEnumerableIterator2.MoveNext() at System.Linq.Enumerable.WhereEnumerableIterator1.MoveNext() at System.Collections.Generic.LargeArrayBuilder1.AddRange(IEnumerable1 items) at System.Collections.Generic.SparseArrayBuilder1.ReserveOrAdd(IEnumerable1 items) at System.Linq.Enumerable.Concat2Iterator1.ToArray() at System.Collections.Immutable.ImmutableArray.CreateRange[T](IEnumerable1 items) at OmniSharp.Roslyn.CSharp.Services.Refactoring.V2.CachingCodeFixProviderForProjects.LoadFrom(Project project) in /home/vsts/work/1/s/src/OmniSharp.Roslyn.CSharp/Services/Refactoring/V2/CachingCodeFixProviderForProjects.cs:line 95 at OmniSharp.Roslyn.CSharp.Services.Refactoring.V2.CachingCodeFixProviderForProjects.GetAllCodeFixesForProject(ProjectId projectId) in /home/vsts/work/1/s/src/OmniSharp.Roslyn.CSharp/Services/Refactoring/V2/CachingCodeFixProviderForProjects.cs:line 57 at OmniSharp.Roslyn.CSharp.Services.Refactoring.V2.BaseCodeActionService2.GetSortedCodeFixProviders(Document document) in /home/vsts/work/1/s/src/OmniSharp.Roslyn.CSharp/Services/Refactoring/V2/BaseCodeActionService.cs:line 170 at OmniSharp.Roslyn.CSharp.Services.Refactoring.V2.BaseCodeActionService2.AppendFixesAsync(Document document, TextSpan span, IEnumerable1 diagnostics, List1 codeActions) in /home/vsts/work/1/s/src/OmniSharp.Roslyn.CSharp/Services/Refactoring/V2/BaseCodeActionService.cs:line 142 at OmniSharp.Roslyn.CSharp.Services.Refactoring.V2.BaseCodeActionService2.CollectCodeFixesActions(Document document, TextSpan span, List1 codeActions) in /home/vsts/work/1/s/src/OmniSharp.Roslyn.CSharp/Services/Refactoring/V2/BaseCodeActionService.cs:line 134 at OmniSharp.Roslyn.CSharp.Services.Refactoring.V2.BaseCodeActionService2.GetAvailableCodeActions(ICodeActionRequest request) in /home/vsts/work/1/s/src/OmniSharp.Roslyn.CSharp/Services/Refactoring/V2/BaseCodeActionService.cs:line 86 at OmniSharp.Roslyn.CSharp.Services.Refactoring.V2.GetCodeActionsService.Handle(GetCodeActionsRequest request) in /home/vsts/work/1/s/src/OmniSharp.Roslyn.CSharp/Services/Refactoring/V2/GetCodeActionsService.cs:line 34 at OmniSharp.Endpoint.EndpointHandler2.GetFirstNotEmptyResponseFromHandlers(ExportHandler2[] handlers, TRequest request) in /home/vsts/work/1/s/src/OmniSharp.Host/Endpoint/EndpointHandler.cs:line 200 at OmniSharp.Endpoint.EndpointHandler2.HandleRequestForLanguage(String language, TRequest request, RequestPacket packet) in /home/vsts/work/1/s/src/OmniSharp.Host/Endpoint/EndpointHandler.cs:line 229 at OmniSharp.Endpoint.EndpointHandler2.Process(RequestPacket packet, LanguageModel model, JToken requestObject) in /home/vsts/work/1/s/src/OmniSharp.Host/Endpoint/EndpointHandler.cs:line 130 at OmniSharp.Stdio.Host.HandleRequest(String json, ILogger logger) in /home/vsts/work/1/s/src/OmniSharp.Stdio/Host.cs:line

jeremy-allocate avatar Jul 26 '24 15:07 jeremy-allocate

@jeremy-allocate Looks like due to authentication changes in ADO we are no longer pushing rolling builds. I will report back once we have a new build pushed.

JoeRobich avatar Jul 26 '24 17:07 JoeRobich

I just want to say huge thank you to O# team and community for supporting such a good product. I have been using VS Code + O# + Linux for the last 4 years writing 150k+ lines of code (C#, Razor, SQL etc.). Switching from Visual Studio to VS Code was an interesting experience, and I love it. Thanks O# for building a good tool for C# / .NET Core development.

The issue I posted here, came around begining of 2024 (or end 2023). I hope it will be resolved soon, as I continue writing code a lot.

😄

mkorsukov avatar Jul 29 '24 15:07 mkorsukov

Rolling build 1.39.12-beta.30 should now be available. I will begin work on getting 1.39.12 released. It will then get inserted into the C# extension. First it will be part of a prerelease build of the extension then it will be part of the release build. So you will most likely need to use the dotnet.server.path: latest for a few weeks. Will update as we make progress on getting it into release.

JoeRobich avatar Jul 29 '24 23:07 JoeRobich

Just confirming that I was able to download the latest version and that it resolves the "quick fix" issue I was seeing!

O# log has the following errors, but they didn't affect any functionality that I could notice.

[fail]: OmniSharp.Roslyn.CSharp.Services.Refactoring.V2.CachingCodeFixProviderForProjects
        Getting concrete types from assembly 'Microsoft.CodeAnalysis.Razor.Compiler.Language, Version=7.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60' failed, error: System.Reflection.ReflectionTypeLoadException: Unable to load one or more of the requested types.
Access is denied: 'Microsoft.AspNetCore.Razor.PooledObjects.PooledObject`1[System.Collections.Immutable.ImmutableArray`1+Builder[Microsoft.AspNetCore.Razor.Language.SourceMapping]]'.
Access is denied: 'Microsoft.AspNetCore.Razor.PooledObjects.PooledObject`1[System.Collections.Immutable.ImmutableArray`1+Builder[Microsoft.AspNetCore.Razor.Language.SourceMapping]]'.
   at System.Reflection.RuntimeModule.GetTypes(RuntimeModule module)
   at System.Reflection.RuntimeModule.GetTypes()
   at OmniSharp.Roslyn.CSharp.Services.Refactoring.V2.CachingCodeFixProviderForProjects.GetConcreteTypes(Assembly assembly) in /home/vsts/work/1/s/src/OmniSharp.Roslyn.CSharp/Services/Refactoring/V2/CachingCodeFixProviderForProjects.cs:line 106
System.TypeLoadException: Access is denied: 'Microsoft.AspNetCore.Razor.PooledObjects.PooledObject`1[System.Collections.Immutable.ImmutableArray`1+Builder[Microsoft.AspNetCore.Razor.Language.SourceMapping]]'.
System.TypeLoadException: Access is denied: 'Microsoft.AspNetCore.Razor.PooledObjects.PooledObject`1[System.Collections.Immutable.ImmutableArray`1+Builder[Microsoft.AspNetCore.Razor.Language.SourceMapping]]'.

jeremy-allocate avatar Jul 30 '24 17:07 jeremy-allocate

@jeremy-allocate Thanks for the report! I will set aside some time later this week to take a look.

JoeRobich avatar Jul 30 '24 22:07 JoeRobich

Looks like I may have spoken too soon @JoeRobich. I and others on my team have continued to see the Quick Fix menu fail in Razor projects, but not as consistently as before (sometimes it works, sometimes not). Guessing that error above might have something to do with it even though I sometimes see it when the menu loads suggestions successfully. Will play with it a bit more to see if we can find anything that's consistent between the occurrences.

jeremy-allocate avatar Jul 31 '24 16:07 jeremy-allocate