Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Could not find assembly Microsoft.VisualStudio.DesignTools.CodeAnalysis #1686

Closed
AnthonyElcocks opened this issue Dec 13, 2024 · 3 comments · Fixed by dotnet/roslyn#76617
Assignees
Labels
Milestone

Comments

@AnthonyElcocks
Copy link

AnthonyElcocks commented Dec 13, 2024

Describe the Issue

I have followed many 'solutions'. Uninstall/reinstall the extensions
Delete temp folder
Set .net path in options
Used .NET8 and .NET9
Extend the timeout in settings to 60000, and some bigger numbers
Every time I get the following in the C# OUTPUT panel when VS Code starts...

2024-12-13 12:48:22.276 [info] Using dotnet configured on PATH
2024-12-13 12:48:22.278 [info] Dotnet path: C:\Program Files\dotnet\dotnet.exe
2024-12-13 12:48:22.278 [info] Activating C# + C# Dev Kit...
2024-12-13 12:48:24.371 [error] [stderr] Unhandled exception: 
2024-12-13 12:48:24.392 [error] [stderr] System.IO.FileNotFoundException: Could not find assembly Microsoft.VisualStudio.DesignTools.CodeAnalysis, Version=17.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a with code base c:\Projects\Learn C in any extension context.
   at Microsoft.CodeAnalysis.LanguageServer.CustomExportAssemblyLoader.LoadAssemblyFromCodeBase(AssemblyName assemblyName, String codeBaseUriStr) in /_/src/LanguageServer/Microsoft.CodeAnalysis.LanguageServer/CustomExportAssemblyLoader.cs:line 95
   at Microsoft.VisualStudio.Composition.Reflection.ResolverExtensions.GetManifest(Resolver resolver, AssemblyName assemblyName)
   at Microsoft.VisualStudio.Composition.Reflection.ResolverExtensions.TryUseFastReflection(TypeRef typeRef, Module& manifest)
   at Microsoft.VisualStudio.Composition.Reflection.ResolverExtensions.Resolve(ParameterRef parameterRef)
   at Microsoft.VisualStudio.Composition.ComposedPart.Validate(IReadOnlyDictionary`2 metadataViews)+MoveNext()
   at System.Collections.Generic.List`1.AddRange(IEnumerable`1 collection)
   at Microsoft.VisualStudio.Composition.CompositionConfiguration.Create(ComposableCatalog catalog)
   at Microsoft.CodeAnalysis.LanguageServer.ExportProviderBuilder.CreateExportProviderAsync(ExtensionAssemblyManager extensionManager, IAssemblyLoader assemblyLoader, String devKitDependencyPath, ILoggerFactory loggerFactory) in /_/src/LanguageServer/Microsoft.CodeAnalysis.LanguageServer/ExportProviderBuilder.cs:line 57
   at Program.<<Main>$>g__RunAsync|0_0(ServerConfiguration serverConfiguration, CancellationToken cancellationToken) in /_/src/LanguageServer/Microsoft.CodeAnalysis.LanguageServer/Program.cs:line 89
   at System.CommandLine.CliCommand.<>c__DisplayClass32_0.<<SetAction>b__0>d.MoveNext()
--- End of stack trace from previous location ---
   at System.CommandLine.Invocation.InvocationPipeline.InvokeAsync(ParseResult parseResult, CancellationToken cancellationToken)

2024-12-13 12:48:24.422 [info] Language server process exited with 1
2024-12-13 12:48:24.432 [info] [Error - 12:48:24 PM] Microsoft.CodeAnalysis.LanguageServer client: couldn't create connection to server.
2024-12-13 12:48:24.432 [info] Error: Language server process exited unexpectedly
    at ChildProcess.<anonymous> (c:\Projects\Learn C#\dot-net-extensions\ms-dotnettools.csharp-2.55.29-win32-x64\dist\extension.js:2:1178170)
    at ChildProcess.emit (node:events:530:35)
    at Process.ChildProcess._handle.onexit (node:internal/child_process:293:12)

Steps To Reproduce

Start VS Code
See error Microsoft.CodeAnalysis.LanguageServer client: couldn't create connection to server.

Expected Behavior

There should be no error when VS Code is started

Environment Information

Windows 11 Enterprise 10.0.261000
VS Code 1.96.0
C# Dev Kit Version 1.14.14

@AnthonyElcocks AnthonyElcocks added the bug Something isn't working label Dec 13, 2024
@AnthonyElcocks
Copy link
Author

I found my answer...It is because the folder for the project was named Learn C#
Changing it to Learn C Sharp resolved the issue

@AbhitejJohn
Copy link

@AnthonyElcocks : Thanks for sharing and glad you were able to unblock as well. Tagging @dibarbet for thoughts on this.

@dibarbet dibarbet self-assigned this Jan 4, 2025
@dibarbet dibarbet added this to the Jan2025 milestone Jan 4, 2025
dibarbet added a commit to dotnet/roslyn that referenced this issue Jan 6, 2025
Resolves microsoft/vscode-dotnettools#1686

When vscode is installed in (or an extension assembly is loaded from) a
path that contains a URI reserved character, the server crashes. This is
because VS-MEF (for compatibility with clr behavior) sets the code base
to a file URI with an unencoded path.

When parsing the URI, some reserved characters cause the path component
to be incorrectly split into query or fragment components if unescaped.
Then we get an invalid file path from the URI and cannot load the
extension dll.
@dibarbet
Copy link
Member

dibarbet commented Jan 6, 2025

Will be resolved in an upcoming prerelease (likely next week)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants