0

I've created a new Web-API project and referenced a newly created class library with the dotnet cli. Both projects are included in the solution.

I've installed the Apple Sillicon version of VSCode (1.64.2) along with the arm64 Dotnet-Sdk (6.0.200).

Here're the commands I've used:

dotnet new sln -n test
dotnet new webapi -n testapi
dotnet new classlib -n testlib

dotnet sln add testapi
dotnet sln add testlib

cd testapi
dotnet add reference ../testlib

When I try to use for example the auto-import of using statements inside the testapi project it states no codea ctions available. When I try the same in the testlib project it's working as expected.

In the Omnisharp Log I see the following error:

[warn]: OmniSharp.Stdio.Host
        ************ Request ************
{
  "Type": "request",
  "Seq": 120,
  "Command": "/v2/getcodeactions",
  "Arguments": {
    "FileName": "/Users/XXX/Projects/testapi/Program.cs",
    "Line": 18,
    "Column": 11
  }
}
[fail]: OmniSharp.Stdio.Host
        ************  Response (43.8339ms) ************ 
{
  "Request_seq": 120,
  "Command": "/v2/getcodeactions",
  "Running": true,
  "Success": false,
  "Message": "\"System.Reflection.ReflectionTypeLoadException: Exception of type 'System.Reflection.ReflectionTypeLoadException' was thrown.\\nCould not load file or assembly 'Microsoft.CodeAnalysis, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies.\\n  at (wrapper managed-to-native) System.Reflection.Assembly.GetTypes(System.Reflection.Assembly,bool)\\n  at System.Reflection.Assembly.GetTypes () [0x00000] in <36514b14425c4337b446653c547aa9c3>:0 \\n  at System.Reflection.Assembly+<get_DefinedTypes>d__127.MoveNext () [0x0001e] in <36514b14425c4337b446653c547aa9c3>:0 \\n  at System.Linq.Enumerable+SelectManySingleSelectorIterator`2[TSource,TResult].MoveNext () [0x0006f] in <14c1495deda74532849f8ec10b438611>:0 \\n  at System.Linq.Enumerable+WhereSelectEnumerableIterator`2[TSource,TResult].MoveNext () [0x00059] in <14c1495deda74532849f8ec10b438611>:0 \\n  at System.Linq.Enumerable+WhereEnumerableIterator`1[TSource].MoveNext () [0x0004e] in <14c1495deda74532849f8ec10b438611>:0 \\n  at System.Collections.Generic.LargeArrayBuilder`1[T].AddRange (System.Collections.Generic.IEnumerable`1[T] items) [0x0003d] in <14c1495deda74532849f8ec10b438611>:0 \\n  at System.Collections.Generic.SparseArrayBuilder`1[T].AddRange (System.Collections.Generic.IEnumerable`1[T] items) [0x00000] in <14c1495deda74532849f8ec10b438611>:0 \\n  at System.Collections.Generic.SparseArrayBuilder`1[T].ReserveOrAdd (System.Collections.Generic.IEnumerable`1[T] items) [0x00017] in <14c1495deda74532849f8ec10b438611>:0 \\n  at System.Linq.Enumerable+Concat2Iterator`1[TSource].ToArray () [0x00015] in <14c1495deda74532849f8ec10b438611>:0 \\n  at System.Linq.Enumerable.ToArray[TSource] (System.Collections.Generic.IEnumerable`1[T] source) [0x0001f] in <14c1495deda74532849f8ec10b438611>:0 \\n  at System.Collections.Immutable.ImmutableArray.CreateRange[T] (System.Collections.Generic.IEnumerable`1[T] items) [0x0004d] in <be358f84962848a48784e4a9d001abe1>:0 \\n  at System.Collections.Immutable.ImmutableArray.ToImmutableArray[TSource] (System.Collections.Generic.IEnumerable`1[T] items) [0x0000f] in <be358f84962848a48784e4a9d001abe1>:0 \\n  at OmniSharp.Roslyn.CSharp.Services.Refactoring.V2.CachingCodeFixProviderForProjects.LoadFrom (Microsoft.CodeAnalysis.Project project) [0x000d5] in <7833e4dfb11c41969fc8bb341c494975>:0 \\n  at OmniSharp.Roslyn.CSharp.Services.Refactoring.V2.CachingCodeFixProviderForProjects.GetAllCodeFixesForProject (Microsoft.CodeAnalysis.ProjectId projectId) [0x00045] in <7833e4dfb11c41969fc8bb341c494975>:0 \\n  at OmniSharp.Roslyn.CSharp.Services.Refactoring.V2.BaseCodeActionService`2[TRequest,TResponse].GetSortedCodeFixProviders (Microsoft.CodeAnalysis.Document document) [0x00011] in <7833e4dfb11c41969fc8bb341c494975>:0 \\n  at OmniSharp.Roslyn.CSharp.Services.Refactoring.V2.BaseCodeActionService`2[TRequest,TResponse].AppendFixesAsync (Microsoft.CodeAnalysis.Document document, Microsoft.CodeAnalysis.Text.TextSpan span, System.Collections.Generic.IEnumerable`1[T] diagnostics, System.Collections.Generic.List`1[T] codeActions) [0x0003e] in <7833e4dfb11c41969fc8bb341c494975>:0 \\n  at OmniSharp.Roslyn.CSharp.Services.Refactoring.V2.BaseCodeActionService`2[TRequest,TResponse].CollectCodeFixesActions (Microsoft.CodeAnalysis.Document document, Microsoft.CodeAnalysis.Text.TextSpan span, System.Collections.Generic.List`1[T] codeActions) [0x001c1] in <7833e4dfb11c41969fc8bb341c494975>:0 \\n  at OmniSharp.Roslyn.CSharp.Services.Refactoring.V2.BaseCodeActionService`2[TRequest,TResponse].GetAvailableCodeActions (OmniSharp.Models.V2.CodeActions.ICodeActionRequest request) [0x001a4] in <7833e4dfb11c41969fc8bb341c494975>:0 \\n  at OmniSharp.Roslyn.CSharp.Services.Refactoring.V2.GetCodeActionsService.Handle (OmniSharp.Models.V2.CodeActions.GetCodeActionsRequest request) [0x0006b] in <7833e4dfb11c41969fc8bb341c494975>:0 \\n  at OmniSharp.Endpoint.EndpointHandler`2[TRequest,TResponse].GetFirstNotEmptyResponseFromHandlers (OmniSharp.Endpoint.Exports.ExportHandler`2[TRequest,TResponse][] handlers, TRequest request) [0x00099] in <5f96298298f74346ad96eb79547a94e4>:0 \\n  at OmniSharp.Endpoint.EndpointHandler`2[TRequest,TResponse].HandleRequestForLanguage (System.String language, TRequest request, OmniSharp.Protocol.RequestPacket packet) [0x00163] in <5f96298298f74346ad96eb79547a94e4>:0 \\n  at OmniSharp.Endpoint.EndpointHandler`2[TRequest,TResponse].Process (OmniSharp.Protocol.RequestPacket packet, OmniSharp.Endpoint.LanguageModel model, Newtonsoft.Json.Linq.JToken requestObject) [0x0024b] in <5f96298298f74346ad96eb79547a94e4>:0 \\n  at OmniSharp.Stdio.Host.HandleRequest (System.String json, Microsoft.Extensions.Logging.ILogger logger) [0x000f3] in <25aad3e40a2c409a9df3868c7895a306>:0 \\nSystem.TypeLoadException: Could not load file or assembly 'Microsoft.CodeAnalysis, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies.\"",
  "Body": null,
  "Seq": 11156,
  "Type": "response"
}
[warn]: OmniSharp.Stdio.Host
        ************ Request ************
{
  "Type": "request",
  "Seq": 123,
  "Command": "/v2/getcodeactions",
  "Arguments": {
    "FileName": "/Users/XXX/Projects/testapi/Program.cs",
    "Line": 18,
    "Column": 11
  }
}
[fail]: OmniSharp.Stdio.Host
        ************  Response (43.9858ms) ************ 
{
  "Request_seq": 123,
  "Command": "/v2/getcodeactions",
  "Running": true,
  "Success": false,
  "Message": "\"System.Reflection.ReflectionTypeLoadException: Exception of type 'System.Reflection.ReflectionTypeLoadException' was thrown.\\nCould not load file or assembly 'Microsoft.CodeAnalysis, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies.\\n  at (wrapper managed-to-native) System.Reflection.Assembly.GetTypes(System.Reflection.Assembly,bool)\\n  at System.Reflection.Assembly.GetTypes () [0x00000] in <36514b14425c4337b446653c547aa9c3>:0 \\n  at System.Reflection.Assembly+<get_DefinedTypes>d__127.MoveNext () [0x0001e] in <36514b14425c4337b446653c547aa9c3>:0 \\n  at System.Linq.Enumerable+SelectManySingleSelectorIterator`2[TSource,TResult].MoveNext () [0x0006f] in <14c1495deda74532849f8ec10b438611>:0 \\n  at System.Linq.Enumerable+WhereSelectEnumerableIterator`2[TSource,TResult].MoveNext () [0x00059] in <14c1495deda74532849f8ec10b438611>:0 \\n  at System.Linq.Enumerable+WhereEnumerableIterator`1[TSource].MoveNext () [0x0004e] in <14c1495deda74532849f8ec10b438611>:0 \\n  at System.Collections.Generic.LargeArrayBuilder`1[T].AddRange (System.Collections.Generic.IEnumerable`1[T] items) [0x0003d] in <14c1495deda74532849f8ec10b438611>:0 \\n  at System.Collections.Generic.SparseArrayBuilder`1[T].AddRange (System.Collections.Generic.IEnumerable`1[T] items) [0x00000] in <14c1495deda74532849f8ec10b438611>:0 \\n  at System.Collections.Generic.SparseArrayBuilder`1[T].ReserveOrAdd (System.Collections.Generic.IEnumerable`1[T] items) [0x00017] in <14c1495deda74532849f8ec10b438611>:0 \\n  at System.Linq.Enumerable+Concat2Iterator`1[TSource].ToArray () [0x00015] in <14c1495deda74532849f8ec10b438611>:0 \\n  at System.Linq.Enumerable.ToArray[TSource] (System.Collections.Generic.IEnumerable`1[T] source) [0x0001f] in <14c1495deda74532849f8ec10b438611>:0 \\n  at System.Collections.Immutable.ImmutableArray.CreateRange[T] (System.Collections.Generic.IEnumerable`1[T] items) [0x0004d] in <be358f84962848a48784e4a9d001abe1>:0 \\n  at System.Collections.Immutable.ImmutableArray.ToImmutableArray[TSource] (System.Collections.Generic.IEnumerable`1[T] items) [0x0000f] in <be358f84962848a48784e4a9d001abe1>:0 \\n  at OmniSharp.Roslyn.CSharp.Services.Refactoring.V2.CachingCodeFixProviderForProjects.LoadFrom (Microsoft.CodeAnalysis.Project project) [0x000d5] in <7833e4dfb11c41969fc8bb341c494975>:0 \\n  at OmniSharp.Roslyn.CSharp.Services.Refactoring.V2.CachingCodeFixProviderForProjects.GetAllCodeFixesForProject (Microsoft.CodeAnalysis.ProjectId projectId) [0x00045] in <7833e4dfb11c41969fc8bb341c494975>:0 \\n  at OmniSharp.Roslyn.CSharp.Services.Refactoring.V2.BaseCodeActionService`2[TRequest,TResponse].GetSortedCodeFixProviders (Microsoft.CodeAnalysis.Document document) [0x00011] in <7833e4dfb11c41969fc8bb341c494975>:0 \\n  at OmniSharp.Roslyn.CSharp.Services.Refactoring.V2.BaseCodeActionService`2[TRequest,TResponse].AppendFixesAsync (Microsoft.CodeAnalysis.Document document, Microsoft.CodeAnalysis.Text.TextSpan span, System.Collections.Generic.IEnumerable`1[T] diagnostics, System.Collections.Generic.List`1[T] codeActions) [0x0003e] in <7833e4dfb11c41969fc8bb341c494975>:0 \\n  at OmniSharp.Roslyn.CSharp.Services.Refactoring.V2.BaseCodeActionService`2[TRequest,TResponse].CollectCodeFixesActions (Microsoft.CodeAnalysis.Document document, Microsoft.CodeAnalysis.Text.TextSpan span, System.Collections.Generic.List`1[T] codeActions) [0x001c1] in <7833e4dfb11c41969fc8bb341c494975>:0 \\n  at OmniSharp.Roslyn.CSharp.Services.Refactoring.V2.BaseCodeActionService`2[TRequest,TResponse].GetAvailableCodeActions (OmniSharp.Models.V2.CodeActions.ICodeActionRequest request) [0x001a4] in <7833e4dfb11c41969fc8bb341c494975>:0 \\n  at OmniSharp.Roslyn.CSharp.Services.Refactoring.V2.GetCodeActionsService.Handle (OmniSharp.Models.V2.CodeActions.GetCodeActionsRequest request) [0x0006b] in <7833e4dfb11c41969fc8bb341c494975>:0 \\n  at OmniSharp.Endpoint.EndpointHandler`2[TRequest,TResponse].GetFirstNotEmptyResponseFromHandlers (OmniSharp.Endpoint.Exports.ExportHandler`2[TRequest,TResponse][] handlers, TRequest request) [0x00099] in <5f96298298f74346ad96eb79547a94e4>:0 \\n  at OmniSharp.Endpoint.EndpointHandler`2[TRequest,TResponse].HandleRequestForLanguage (System.String language, TRequest request, OmniSharp.Protocol.RequestPacket packet) [0x00163] in <5f96298298f74346ad96eb79547a94e4>:0 \\n  at OmniSharp.Endpoint.EndpointHandler`2[TRequest,TResponse].Process (OmniSharp.Protocol.RequestPacket packet, OmniSharp.Endpoint.LanguageModel model, Newtonsoft.Json.Linq.JToken requestObject) [0x0024b] in <5f96298298f74346ad96eb79547a94e4>:0 \\n  at OmniSharp.Stdio.Host.HandleRequest (System.String json, Microsoft.Extensions.Logging.ILogger logger) [0x000f3] in <25aad3e40a2c409a9df3868c7895a306>:0 \\nSystem.TypeLoadException: Could not load file or assembly 'Microsoft.CodeAnalysis, Version=4.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies.\"",
  "Body": null,
  "Seq": 11176,
  "Type": "response"
}
frank
  • 1,217
  • 2
  • 10
  • 18

1 Answers1

0

Figured out what's the problem. It is related to dotnet SDK 6.0.200. So when rolling back to SDK version 6.0.100 everything works fine. (It is not related to arm or x86_64 version of the SDK)

frank
  • 1,217
  • 2
  • 10
  • 18