Completion crashes with InvalidCastException on CompletionList type
See original GitHub issueExtension version: 1.23.2 VS Code version: Code 1.49.2 (e5e9e69aed6e1984f7499b7af85b3d05f9a6883a, 2020-09-24T16:29:41.983Z) OS version: Windows_NT x64 10.0.19041
Steps to reproduce problem:
- create console project with ‘dotnet new console’
- start to write some c# code
- no code completion for c# extension 1.23.2 version
- after downgrading c# extension to 1.23.1 code completion works OK
System.InvalidCastException: Nie można zrzutować
[A]System.Threading.Tasks.Task`1[System.ValueTuple`2[Microsoft.CodeAnalysis.Completion.CompletionList,System.Boolean]] na
[B]System.Threading.Tasks.Task`1[System.ValueTuple`2[Microsoft.CodeAnalysis.Completion.CompletionList,System.Boolean]].
Typ A pochodzi od mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 w kontekście LoadNeither w lokalizacji C:\\\\WINDOWS\\\\Microsoft.Net\\\\assembly\\\\GAC_64\\\\mscorlib\\\\v4.0_4.0.0.0__b77a5c561934e089\\\\mscorlib.dll.
Typ B pochodzi od mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 w kontekście LoadNeither w lokalizacji C:\\\\WINDOWS\\\\Microsoft.Net\\\\assembly\\\\GAC_64\\\\mscorlib\\\\v4.0_4.0.0.0__b77a5c561934e089\\\\mscorlib.dll.\\r\\n
w OmniSharp.Roslyn.CSharp.Services.Intellisense.CompletionItemExtensions.GetCompletionsInternalAsync(CompletionService completionService, Document document, Int32 caretPosition, CompletionTrigger trigger, ImmutableHashSet`1 roles, OptionSet options, CancellationToken cancellationToken) w D:\\\\a\\\\1\\\\s\\\\src\\\\OmniSharp.Roslyn.CSharp\\\\Services\\\\Intellisense\\\\CompletionItemExtensions.cs:wiersz 64\\r\\n w OmniSharp.Roslyn.CSharp.Services.Completion.CompletionService.<Handle>d__7.MoveNext() w D:\\\\a\\\\1\\\\s\\\\src\\\\OmniSharp.Roslyn.CSharp\\\\Services\\\\Completion\\\\CompletionService.cs:wiersz 120\\r\\n--- Koniec śladu stosu z poprzedniej lokalizacji, w której wystąpił wyjątek ---\\r\\n w System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\\r\\n w System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\\r\\n w OmniSharp.Endpoint.EndpointHandler`2.<GetFirstNotEmptyResponseFromHandlers>d__19.MoveNext()\\r\\n--- Koniec śladu stosu z poprzedniej lokalizacji, w której wystąpił wyjątek ---\\r\\n w System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\\r\\n w System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\\r\\n w OmniSharp.Endpoint.EndpointHandler`2.<HandleRequestForLanguage>d__20.MoveNext() w D:\\\\a\\\\1\\\\s\\\\src\\\\OmniSharp.Host\\\\Endpoint\\\\EndpointHandler.cs:wiersz 230\\r\\n--- Koniec śladu stosu z poprzedniej lokalizacji, w której wystąpił wyjątek ---\\r\\n w System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\\r\\n w System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\\r\\n w OmniSharp.Endpoint.EndpointHandler`2.<Process>d__16.MoveNext() w D:\\\\a\\\\1\\\\s\\\\src\\\\OmniSharp.Host\\\\Endpoint\\\\EndpointHandler.cs:wiersz 131\\r\\n--- Koniec śladu stosu z poprzedniej lokalizacji, w której wystąpił wyjątek ---\\r\\n w System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\\r\\n w System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\\r\\n w OmniSharp.Stdio.Host.<HandleRequest>d__13.MoveNext() w D:\\\\a\\\\1\\\\s\\\\src\\\\OmniSharp.Stdio\\\\Host.cs:wiersz 215
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:53 (8 by maintainers)
Top Results From Across the Web
Visual Studio crash with System.InvalidCastException at ...
It looks like the crash is caused, because Visual Studio loads assemblies from our project into it's app domain. Our code then crashes...
Read more >dbForge Studio for SQL Server History - Devart
Fixed incorrect script generation for table-based types in specific environments ... Added support for new functions in the Completion List, Quick Info, ...
Read more >C# GUI keeps crashing due to System.InvalidCastException ...
I'm trying to write my own GUI for a Program in C#, which translate Morsecode to text. My IDE doesn't show any errors...
Read more >Changes in Oxygene 4.0 - RemObjects
39141: Compiler fails when referenced types are duplicates ... 38439: Selecting an ampersand escaped member from the auto-complete list always adds a new ......
Read more >InvalidCastException Class (System) - Microsoft Learn
NET Framework supports automatic conversion from derived types to their base ... An InvalidCastException exception is caused by developer error and should ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Ok, I found something.
If I modify file
OmniSharp.exe.config
located in.vscode\extensions\ms-dotnettools.csharp-1.23.13\.omnisharp\1.37.12
and remove this section:Then the exception goes away, and code completion starts working!
I don’t know why this binding redirect is added on compilation, however I discovered McMaster.Extensions.CommandLineUtils/2.2.4 was depending on 4.4.0 of System.ValueTuple while omnisharp-roslyn depends on 4.5.0. Newer versions of McMaster.Extensions.CommandLineUtils depend on 4.5.0. When I upgraded the dependency, the binding redirect was no longer added to
OmniSharp.exe.config
I have made a pull request in
omnisharp-roslyn
to upgrade the dependency.Multiple loading of the OmniSharp.MSBuild assembly should be resolved with the following two changes being merged https://github.com/OmniSharp/omnisharp-vscode/pull/4642 & https://github.com/OmniSharp/omnisharp-vscode/pull/4643. We expect to have a pre-release build shortly that we will validate for publishing.