dotnet / vscode-csharp

Official C# support for Visual Studio Code
MIT License
2.86k stars 672 forks source link

Assembly conflict when trying to type something in Razor file #7469

Closed pontakornth closed 2 months ago

pontakornth commented 2 months ago

Type: Bug

Issue Description

When I try to type something in .cshtml file, there will be a random error. After I look into the log, I see assembly conflict.

The issue appears on both release and pre-release version of C# Dev Kit.

Steps to Reproduce

  1. Open VSCode
  2. Open an ASP.NET Core project with Razor Page
  3. Open a .cshtml file
  4. Type @Html. should make the error appear.

Expected Behavior

Auto complete appears if available. No effect on other files

Actual Behavior

Auto complete appears and then disappears. After that, autocomplete and some syntax highlighting in C# files do not work.

C# Logs

[stdout] fail: Microsoft.CodeAnalysis.LanguageServer.ExportProviderBuilder[0]
      /Users/pontakorn/.vscode/extensions/ms-dotnettools.csharp-2.39.29-darwin-x64/.xamlTools/Microsoft.VisualStudio.DesignTools.CodeAnalysis.dll with assembly name Microsoft.VisualStudio.DesignTools.CodeAnalysis, Version=17.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a conflicts with extension loaded from /Users/pontakorn/.vscode/extensions/ms-dotnettools.csharp-2.39.29-darwin-x64/.xamlTools
[stdout] fail: Microsoft.CodeAnalysis.LanguageServer.ExportProviderBuilder[0]
      /Users/pontakorn/.vscode/extensions/ms-dotnettools.csharp-2.39.29-darwin-x64/.xamlTools/Microsoft.VisualStudio.DesignTools.CodeAnalysis.Diagnostics.dll with assembly name Microsoft.VisualStudio.DesignTools.CodeAnalysis.Diagnostics, Version=17.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a conflicts with extension loaded from /Users/pontakorn/.vscode/extensions/ms-dotnettools.csharp-2.39.29-darwin-x64/.xamlTools
[stdout] {"pipeName":"/var/folders/3t/14q5n69j3vv0n0nym4l1dnpr0000gn/T/b44cc963.sock"}

Environment information

VSCode version: 1.92.2 C# Extension: 2.39.29 Using OmniSharp: false

Dotnet Information .NET SDK: Version: 8.0.303 Commit: 29ab8e3268 Workload version: 8.0.300-manifests.e4379c3d MSBuild version: 17.10.4+10fbfbf2e Runtime Environment: OS Name: Mac OS X OS Version: 14.5 OS Platform: Darwin RID: osx-x64 Base Path: /usr/local/share/dotnet/sdk/8.0.303/ .NET workloads installed: [aspire] Installation Source: SDK 8.0.300 Manifest Version: 8.1.0/8.0.100 Manifest Path: /usr/local/share/dotnet/sdk-manifests/8.0.100/microsoft.net.sdk.aspire/8.1.0/WorkloadManifest.json Install Type: FileBased Host: Version: 8.0.7 Architecture: x64 Commit: 2aade6beb0 .NET SDKs installed: 8.0.303 [/usr/local/share/dotnet/sdk] .NET runtimes installed: Microsoft.AspNetCore.App 8.0.7 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App] Microsoft.NETCore.App 8.0.7 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App] Other architectures found: None Environment variables: Not set global.json file: Not found Learn more: https://aka.ms/dotnet/info Download .NET: https://aka.ms/dotnet/download
Visual Studio Code Extensions |Extension|Author|Version|Folder Name| |---|---|---|---| |astro-vscode|astro-build|2.14.1|astro-build.astro-vscode-2.14.1-darwin-x64| |atelier-vscode-themes|Atelierbram|0.0.13|atelierbram.atelier-vscode-themes-0.0.13| |auto-close-tag|formulahendry|0.5.15|formulahendry.auto-close-tag-0.5.15| |auto-rename-tag|formulahendry|0.1.10|formulahendry.auto-rename-tag-0.1.10| |ayu|teabyii|1.0.5|teabyii.ayu-1.0.5| |better-comments|aaron-bond|3.0.2|aaron-bond.better-comments-3.0.2| |brackets-light-pro|fehey|0.4.6|fehey.brackets-light-pro-0.4.6| |browse-lite|antfu|0.3.9|antfu.browse-lite-0.3.9| |bun|Pandy|0.0.4|pandy.bun-0.0.4| |catppuccin-vsc|Catppuccin|3.15.2|catppuccin.catppuccin-vsc-3.15.2| |codeium|Codeium|1.12.6|codeium.codeium-1.12.6| |codesandbox-projects|CodeSandbox-io|0.2.137|codesandbox-io.codesandbox-projects-0.2.137| |csdevkit|ms-dotnettools|1.10.10|ms-dotnettools.csdevkit-1.10.10-darwin-x64| |csharp|ms-dotnettools|2.39.29|ms-dotnettools.csharp-2.39.29-darwin-x64| |dbclient-jdbc|cweijan|1.3.5|cweijan.dbclient-jdbc-1.3.5| |debugpy|ms-python|2024.10.0|ms-python.debugpy-2024.10.0-darwin-x64| |doki-theme|unthrottled|88.1.17|unthrottled.doki-theme-88.1.17| |dotenv|mikestead|1.0.1|mikestead.dotenv-1.0.1| |elixir-ls|JakeBecker|0.23.1|jakebecker.elixir-ls-0.23.1| |even-better-toml|tamasfe|0.19.2|tamasfe.even-better-toml-0.19.2| |explorer|vitest|1.2.0|vitest.explorer-1.2.0| |feather|dericcain|0.5.0|dericcain.feather-0.5.0| |github-vscode-theme|GitHub|6.3.4|github.github-vscode-theme-6.3.4| |gitlens|eamodio|15.3.1|eamodio.gitlens-15.3.1| |go|golang|0.42.0|golang.go-0.42.0| |gruvbox|jdinhlife|1.19.1|jdinhlife.gruvbox-1.19.1| |helium-icon-theme|helgardrichard|1.0.0|helgardrichard.helium-icon-theme-1.0.0| |i18n-ally|lokalise|2.12.0|lokalise.i18n-ally-2.12.0| |iconify|antfu|0.9.2|antfu.iconify-0.9.2| |indent-rainbow|oderwat|8.3.1|oderwat.indent-rainbow-8.3.1| |isort|ms-python|2023.10.1|ms-python.isort-2023.10.1| |jupyter|ms-toolsai|2024.7.0|ms-toolsai.jupyter-2024.7.0-darwin-x64| |jupyter-keymap|ms-toolsai|1.1.2|ms-toolsai.jupyter-keymap-1.1.2| |jupyter-renderers|ms-toolsai|1.0.19|ms-toolsai.jupyter-renderers-1.0.19| |language-stylus|sysoev|1.16.0|sysoev.language-stylus-1.16.0| |Lisp|mattn|0.1.12|mattn.lisp-0.1.12| |LiveServer|ritwickdey|5.7.9|ritwickdey.liveserver-5.7.9| |lunar|bereketsemagn|1.4.0|bereketsemagn.lunar-1.4.0| |makefile-tools|ms-vscode|0.10.26|ms-vscode.makefile-tools-0.10.26| |markdown-preview-enhanced|shd101wyy|0.8.13|shd101wyy.markdown-preview-enhanced-0.8.13| |material-icon-theme|PKief|5.9.0|pkief.material-icon-theme-5.9.0| |material-theme|zhuangtongfa|3.17.2|zhuangtongfa.material-theme-3.17.2| |nord-visual-studio-code|arcticicestudio|0.19.0|arcticicestudio.nord-visual-studio-code-0.19.0| |phoenix|phoenixframework|0.1.2|phoenixframework.phoenix-0.1.2| |postcss|csstools|1.0.9|csstools.postcss-1.0.9| |prettier-vscode|esbenp|11.0.0|esbenp.prettier-vscode-11.0.0| |pretty-ts-errors|YoavBls|0.6.0|yoavbls.pretty-ts-errors-0.6.0| |prisma|Prisma|5.18.0|prisma.prisma-5.18.0| |pymakr|Pycom|2.22.5|pycom.pymakr-2.22.5| |python|ms-python|2024.12.3|ms-python.python-2024.12.3-darwin-x64| |react-native-react-redux|EQuimper|2.0.6|equimper.react-native-react-redux-2.0.6| |remote-containers|ms-vscode-remote|0.380.0|ms-vscode-remote.remote-containers-0.380.0| |remote-ssh|ms-vscode-remote|0.113.1|ms-vscode-remote.remote-ssh-0.113.1| |remote-ssh-edit|ms-vscode-remote|0.86.0|ms-vscode-remote.remote-ssh-edit-0.86.0| |remote-wsl|ms-vscode-remote|0.88.2|ms-vscode-remote.remote-wsl-0.88.2| |rest-client|humao|0.25.1|humao.rest-client-0.25.1| |ruby-lsp|Shopify|0.7.16|shopify.ruby-lsp-0.7.16| |rust-analyzer|rust-lang|0.3.2078|rust-lang.rust-analyzer-0.3.2078-darwin-x64| |slidev|antfu|0.49.28|antfu.slidev-0.49.28| |solargraph|castwide|0.24.1|castwide.solargraph-0.24.1| |svelte-vscode|svelte|108.6.1|svelte.svelte-vscode-108.6.1| |sync-scroll|dqisme|1.3.1|dqisme.sync-scroll-1.3.1| |tailwindcss-intellisense-twin|lightyen|3.0.0|lightyen.tailwindcss-intellisense-twin-3.0.0| |tauri-vscode|tauri-apps|0.2.6|tauri-apps.tauri-vscode-0.2.6| |templ|a-h|0.0.26|a-h.templ-0.0.26| |terraform|hashicorp|2.32.2|hashicorp.terraform-2.32.2-darwin-x64| |todo-tree|Gruntfuggly|0.0.226|gruntfuggly.todo-tree-0.0.226| |tokyo-night|enkia|1.0.9|enkia.tokyo-night-1.0.9| |twind-intellisense|sastan|0.2.1|sastan.twind-intellisense-0.2.1| |unocss|antfu|0.62.3|antfu.unocss-0.62.3| |vite|antfu|0.2.5|antfu.vite-0.2.5| |vsc-material-theme|Equinusocio|34.5.2|equinusocio.vsc-material-theme-34.5.2| |vsc-material-theme-icons|equinusocio|3.8.7|equinusocio.vsc-material-theme-icons-3.8.7| |vscode-database-client2|cweijan|7.5.9|cweijan.vscode-database-client2-7.5.9| |vscode-deno|denoland|3.38.2|denoland.vscode-deno-3.38.2| |vscode-docker|ms-azuretools|1.29.2|ms-azuretools.vscode-docker-1.29.2| |vscode-dotnet-runtime|ms-dotnettools|2.1.5|ms-dotnettools.vscode-dotnet-runtime-2.1.5| |vscode-eslint|dbaeumer|3.0.10|dbaeumer.vscode-eslint-3.0.10| |vscode-github-actions|github|0.26.3|github.vscode-github-actions-0.26.3| |vscode-graphql|GraphQL|0.12.0|graphql.vscode-graphql-0.12.0| |vscode-graphql-syntax|GraphQL|1.3.6|graphql.vscode-graphql-syntax-1.3.6| |vscode-icons|vscode-icons-team|12.8.0|vscode-icons-team.vscode-icons-12.8.0| |vscode-import-cost|wix|3.3.0|wix.vscode-import-cost-3.3.0| |vscode-jupyter-cell-tags|ms-toolsai|0.1.9|ms-toolsai.vscode-jupyter-cell-tags-0.1.9| |vscode-jupyter-slideshow|ms-toolsai|0.1.6|ms-toolsai.vscode-jupyter-slideshow-0.1.6| |vscode-mdx|unifiedjs|1.8.10|unifiedjs.vscode-mdx-1.8.10| |vscode-pull-request-github|GitHub|0.94.0|github.vscode-pull-request-github-0.94.0| |vscode-pylance|ms-python|2024.8.1|ms-python.vscode-pylance-2024.8.1| |vscode-react-native|msjsdiag|1.13.0|msjsdiag.vscode-react-native-1.13.0| |vscode-remote-extensionpack|ms-vscode-remote|0.25.0|ms-vscode-remote.vscode-remote-extensionpack-0.25.0| |vscode-tailwindcss|bradlc|0.12.7|bradlc.vscode-tailwindcss-0.12.7| |vscode-theme-onelight|akamud|2.3.0|akamud.vscode-theme-onelight-2.3.0| |vscode-zig|ziglang|0.5.8|ziglang.vscode-zig-0.5.8| |vsfire|toba|1.4.1|toba.vsfire-1.4.1| |vsliveshare|ms-vsliveshare|1.0.5936|ms-vsliveshare.vsliveshare-1.0.5936| |windicss-intellisense|voorjaar|0.21.6|voorjaar.windicss-intellisense-0.21.6|;

Extension version: 2.39.29 VS Code version: Code 1.92.2 (Universal) (fee1edb8d6d72a0ddff41e5f71a671c23ed924b9, 2024-08-14T17:29:30.058Z) OS version: Darwin x64 23.5.0 Modes:

System Info |Item|Value| |---|---| |CPUs|Intel(R) Core(TM) i5-1038NG7 CPU @ 2.00GHz (8 x 2000)| |GPU Status|2d_canvas: enabled
canvas_oop_rasterization: disabled_off
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
skia_graphite: disabled_off
video_decode: enabled
video_encode: enabled
webgl: enabled
webgl2: enabled
webgpu: enabled
webnn: disabled_off| |Load (avg)|3, 6, 7| |Memory (System)|16.00GB (0.03GB free)| |Process Argv|./RazorPolls --crash-reporter-id e5140bbd-435c-4ece-b729-e04d5e66dfaf| |Screen Reader|no| |VM|0%|
A/B Experiments ``` vsliv368:30146709 vspor879:30202332 vspor708:30202333 vspor363:30204092 vscod805:30301674 binariesv615:30325510 vsaa593:30376534 py29gd2263:31024239 c4g48928:30535728 azure-dev_surveyone:30548225 vscrp:30673768 962ge761:30959799 pythongtdpath:30769146 welcomedialog:30910333 pythonnoceb:30805159 asynctok:30898717 pythonregdiag2:30936856 pythonmypyd1:30879173 h48ei257:31000450 pythontbext0:30879054 accentitlementst:30995554 dsvsc016:30899300 dsvsc017:30899301 dsvsc018:30899302 cppperfnew:31000557 dsvsc020:30976470 pythonait:31006305 dsvsc021:30996838 724cj586:31013169 pythoncenvpt:31062603 a69g1124:31058053 dvdeprecation:31068756 dwnewjupyter:31046869 impr_priority:31102340 refactort:31108082 pythonrstrctxt:31112756 wkspc-onlycs-c:31111717 pme_test_t:31118333 fje88620:31121564 ```
JoeRobich commented 2 months ago

I was able to reproduce this locally with version 2.39.29

Logging from the end of the completion request

[LanguageServerHost] [06:17:41.069][End]textDocument/completion
[Error - 11:17:41 PM] [LanguageServerHost] System.NullReferenceException: Object reference not set to an instance of an object.
   at Microsoft.CodeAnalysis.LanguageServer.RoslynLanguageServer.GetLanguageForRequest(String methodName, Object serializedParameters) in /_/src/LanguageServer/Protocol/RoslynLanguageServer.cs:line 211
   at Microsoft.CommonLanguageServerProtocol.Framework.RequestExecutionQueue`1.ProcessQueueAsync() in /_/src/LanguageServer/Microsoft.CommonLanguageServerProtocol.Framework/RequestExecutionQueue.cs:line 248
[LanguageServerHost] Error processing queue, shutting down
[Info  - 11:17:41 PM] Error processing queue, shutting down
[Info  - 11:17:41 PM] Connection to server got closed. Server will restart.
true
Using dotnet configured on PATH
Dotnet path: /usr/local/share/dotnet/dotnet
Activating C# + C# Dev Kit + C# IntelliCode...
Starting server at /Users/joeyrobichaud/.vscode/extensions/ms-dotnettools.csharp-2.39.29-darwin-arm64/.roslyn/Microsoft.CodeAnalysis.LanguageServer.dll
Server arguments /Users/joeyrobichaud/.vscode/extensions/ms-dotnettools.csharp-2.39.29-darwin-arm64/.roslyn/Microsoft.CodeAnalysis.LanguageServer.dll --logLevel Trace --razorSourceGenerator /Users/joeyrobichaud/.vscode/extensions/ms-dotnettools.csharp-2.39.29-darwin-arm64/.razor/Microsoft.CodeAnalysis.Razor.Compiler.dll --razorDesignTimePath /Users/joeyrobichaud/.vscode/extensions/ms-dotnettools.csharp-2.39.29-darwin-arm64/.razor/Targets/Microsoft.NET.Sdk.Razor.DesignTime.targets --starredCompletionComponentPath /Users/joeyrobichaud/.vscode/extensions/ms-dotnettools.vscodeintellicode-csharp-2.1.11-darwin-arm64/components/starred-suggestions/platforms/darwin-arm64/node_modules/@vsintellicode/starred-suggestions-csharp.darwin-arm64 --devKitDependencyPath /Users/joeyrobichaud/.vscode/extensions/ms-dotnettools.csharp-2.39.29-darwin-arm64/.roslynDevKit/Microsoft.VisualStudio.LanguageServices.DevKit.dll --sessionId 9c4c2191-04a8-466f-8567-a23ea9b289df1724739434320 --extension /Users/joeyrobichaud/.vscode/extensions/ms-dotnettools.csharp-2.39.29-darwin-arm64/.xamlTools/Microsoft.VisualStudio.DesignTools.CodeAnalysis.dll --extension /Users/joeyrobichaud/.vscode/extensions/ms-dotnettools.csharp-2.39.29-darwin-arm64/.xamlTools/Microsoft.VisualStudio.DesignTools.CodeAnalysis.Diagnostics.dll --extension /Users/joeyrobichaud/.vscode/extensions/ms-dotnettools.csharp-2.39.29-darwin-arm64/.xamlTools/Microsoft.VisualStudio.DesignTools.CodeAnalysis.dll --extension /Users/joeyrobichaud/.vscode/extensions/ms-dotnettools.csharp-2.39.29-darwin-arm64/.xamlTools/Microsoft.VisualStudio.DesignTools.CodeAnalysis.Diagnostics.dll --telemetryLevel all --extensionLogDirectory /Users/joeyrobichaud/Library/Application Support/Code/logs/20240821T223520/window8/exthost/ms-dotnettools.csharp
waiting for named pipe information from server...
[stdout] trce: Program[0]
      Server started with process ID 26450
trce: Program[0]
      .NET Runtime Version: .NET 8.0.7
[stdout] trce: Microsoft.CodeAnalysis.LanguageServer.ExportProviderBuilder[0]
      Creating /Users/joeyrobichaud/.vscode/extensions/ms-dotnettools.vscodeintellicode-csharp-2.1.11-darwin-arm64/components/starred-suggestions/platforms/darwin-arm64/node_modules/@vsintellicode/starred-suggestions-csharp.darwin-arm64 load context for /Users/joeyrobichaud/.vscode/extensions/ms-dotnettools.vscodeintellicode-csharp-2.1.11-darwin-arm64/components/starred-suggestions/platforms/darwin-arm64/node_modules/@vsintellicode/starred-suggestions-csharp.darwin-arm64/Microsoft.VisualStudio.IntelliCode.CSharp.dll
[stdout] trce: Microsoft.CodeAnalysis.LanguageServer.ExportProviderBuilder[0]
      Creating /Users/joeyrobichaud/.vscode/extensions/ms-dotnettools.csharp-2.39.29-darwin-arm64/.xamlTools load context for /Users/joeyrobichaud/.vscode/extensions/ms-dotnettools.csharp-2.39.29-darwin-arm64/.xamlTools/Microsoft.VisualStudio.DesignTools.CodeAnalysis.dll
[stdout] fail: Microsoft.CodeAnalysis.LanguageServer.ExportProviderBuilder[0]
      /Users/joeyrobichaud/.vscode/extensions/ms-dotnettools.csharp-2.39.29-darwin-arm64/.xamlTools/Microsoft.VisualStudio.DesignTools.CodeAnalysis.dll with assembly name Microsoft.VisualStudio.DesignTools.CodeAnalysis, Version=17.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a conflicts with extension loaded from /Users/joeyrobichaud/.vscode/extensions/ms-dotnettools.csharp-2.39.29-darwin-arm64/.xamlTools
[stdout] fail: Microsoft.CodeAnalysis.LanguageServer.ExportProviderBuilder[0]
      /Users/joeyrobichaud/.vscode/extensions/ms-dotnettools.csharp-2.39.29-darwin-arm64/.xamlTools/Microsoft.VisualStudio.DesignTools.CodeAnalysis.Diagnostics.dll with assembly name Microsoft.VisualStudio.DesignTools.CodeAnalysis.Diagnostics, Version=17.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a conflicts with extension loaded from /Users/joeyrobichaud/.vscode/extensions/ms-dotnettools.csharp-2.39.29-darwin-arm64/.xamlTools
[stdout] trce: Microsoft.CodeAnalysis.LanguageServer.ExportProviderBuilder[0]
      Composing MEF catalog using:

The exception thrown after Completion causes the Language Server to restart which is where we encounter the conflicts trying to reload certain assemblies.

Closing as I cannot reproduce this issue with prerelease version 2.41.26 or later of the C# extension.

[LanguageServerHost] [06:23:09.114][End]textDocument/completion
[LanguageServerHost] Using C# from request text document
[ExtensionTypeRefResolver] Resolving type, Roslyn.LanguageServer.Protocol.InlayHintParams
[MEF Assembly Loader] Loading assembly Microsoft.CodeAnalysis.LanguageServer.Protocol, Version=4.12.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
[ExtensionTypeRefResolver] Resolving type, Roslyn.LanguageServer.Protocol.InlayHint[]
[MEF Assembly Loader] Loading assembly Microsoft.CodeAnalysis.LanguageServer.Protocol, Version=4.12.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
[ExtensionTypeRefResolver] Resolving type, Microsoft.CodeAnalysis.LanguageServer.Handler.InlayHint.InlayHintHandler
[MEF Assembly Loader] Loading assembly Microsoft.CodeAnalysis.LanguageServer.Protocol, Version=4.12.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
[LanguageServerHost] virtualcsharp-razor:///Users/joeyrobichaud/Source/TestRazor3/Pages/Index.cshtml__virtual.cs found in workspace Host

@pontakornth Please try switching to the pre-release version until we ship a new release build.