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

The library hostfxr.dll was found, but loading it from <Program files> failed #6258

Closed
dibarbet opened this issue Aug 30, 2023 · 7 comments
Closed

Comments

@dibarbet
Copy link
Member

From dotnet/vscode-dotnet-runtime#1338

Failed to find dotnet info from path, falling back to acquire runtime via ms-dotnettools.vscode-dotnet-runtime
The architecture of the .NET runtime (x64) does not match the architecture of the extension (x86).
Dotnet path: C:\Program Files\dotnet\dotnet.exe
Activating C# + C# Dev Kit...
Failed to load the dll from [C:\Program Files\dotnet\host\fxr\7.0.10\hostfxr.dll], HRESULT: 0x800700C1
The library hostfxr.dll was found, but loading it from C:\Program Files\dotnet\host\fxr\7.0.10\hostfxr.dll failed

Installing .NET prerequisites might help resolve this problem.
https://go.microsoft.com/fwlink/?linkid=798306
[Error - 10:15:33] Server initialization failed.
Message: Pending response rejected since connection got disposed
Code: -32097
[Info - 10:15:33] Connection to server got closed. Server will restart.
true
[Error - 10:15:33] Microsoft.CodeAnalysis.LanguageServer client: couldn't create connection to server.
Message: Pending response rejected since connection got disposed
Code: -32097
Failed to find dotnet info from path, falling back to acquire runtime via ms-dotnettools.vscode-dotnet-runtime
The architecture of the .NET runtime (x64) does not match the architecture of the extension (x86).
Dotnet path: C:\Program Files\dotnet\dotnet.exe
Activating C# + C# Dev Kit...
Failed to load the dll from [C:\Program Files\dotnet\host\fxr\7.0.10\hostfxr.dll], HRESULT: 0x800700C1
The library hostfxr.dll was found, but loading it from C:\Program Files\dotnet\host\fxr\7.0.10\hostfxr.dll failed
Installing .NET prerequisites might help resolve this problem.
https://go.microsoft.com/fwlink/?linkid=798306
[Error - 10:15:33] Server initialization failed.
Message: Pending response rejected since connection got disposed
Code: -32097
[Info - 10:15:33] Connection to server got closed. Server will restart.
true
[Error - 10:15:33] Microsoft.CodeAnalysis.LanguageServer client: couldn't create connection to server.
Message: Pending response rejected since connection got disposed
Code: -32097
Failed to find dotnet info from path, falling back to acquire runtime via ms-dotnettools.vscode-dotnet-runtime
The architecture of the .NET runtime (x64) does not match the architecture of the extension (x86).
Dotnet path: C:\Program Files\dotnet\dotnet.exe
Activating C# + C# Dev Kit...
Failed to load the dll from [C:\Program Files\dotnet\host\fxr\7.0.10\hostfxr.dll], HRESULT: 0x800700C1
The library hostfxr.dll was found, but loading it from C:\Program Files\dotnet\host\fxr\7.0.10\hostfxr.dll failed
Installing .NET prerequisites might help resolve this problem.
https://go.microsoft.com/fwlink/?linkid=798306
[Error - 10:15:34] Server initialization failed.
Message: Pending response rejected since connection got disposed
Code: -32097
[Info - 10:15:34] Connection to server got closed. Server will restart.
true
[Error - 10:15:34] Microsoft.CodeAnalysis.LanguageServer client: couldn't create connection to server.
Message: Pending response rejected since connection got disposed
Code: -32097
[Error - 10:15:34] Restarting server failed
Message: Pending response rejected since connection got disposed
Code: -32097
Failed to find dotnet info from path, falling back to acquire runtime via ms-dotnettools.vscode-dotnet-runtime
The architecture of the .NET runtime (x64) does not match the architecture of the extension (x86).
Dotnet path: C:\Program Files\dotnet\dotnet.exe
Activating C# + C# Dev Kit...
Failed to load the dll from [C:\Program Files\dotnet\host\fxr\7.0.10\hostfxr.dll], HRESULT: 0x800700C1
The library hostfxr.dll was found, but loading it from C:\Program Files\dotnet\host\fxr\7.0.10\hostfxr.dll failed
Installing .NET prerequisites might help resolve this problem.
https://go.microsoft.com/fwlink/?linkid=798306
[Error - 10:15:34] Server initialization failed.
Message: Pending response rejected since connection got disposed
Code: -32097
[Info - 10:15:34] Connection to server got closed. Server will restart.
true
[Error - 10:15:34] Microsoft.CodeAnalysis.LanguageServer client: couldn't create connection to server.
Message: Pending response rejected since connection got disposed
Code: -32097
[Error - 10:15:34] Restarting server failed
Message: Pending response rejected since connection got disposed
Code: -32097
Failed to find dotnet info from path, falling back to acquire runtime via ms-dotnettools.vscode-dotnet-runtime
The architecture of the .NET runtime (x64) does not match the architecture of the extension (x86).
Dotnet path: C:\Program Files\dotnet\dotnet.exe
Activating C# + C# Dev Kit...
Failed to load the dll from [C:\Program Files\dotnet\host\fxr\7.0.10\hostfxr.dll], HRESULT: 0x800700C1
The library hostfxr.dll was found, but loading it from C:\Program Files\dotnet\host\fxr\7.0.10\hostfxr.dll failed
Installing .NET prerequisites might help resolve this problem.
https://go.microsoft.com/fwlink/?linkid=798306
[Error - 10:15:34] Server initialization failed.
Message: Pending response rejected since connection got disposed
Code: -32097
[Error - 10:15:34] The Microsoft.CodeAnalysis.LanguageServer server crashed 5 times in the last 3 minutes. The server will not be restarted. See the output for more information.
[Error - 10:15:34] Microsoft.CodeAnalysis.LanguageServer client: couldn't create connection to server.
Message: Pending response rejected since connection got disposed
Code: -32097
[Error - 10:15:34] Restarting server failed
Message: Pending response rejected since connection got disposed
Code: -32097

@dibarbet
Copy link
Member Author

dibarbet commented Aug 30, 2023

@Hongmo97

What architecture is your machine? If its x64 it looks like vscode downloaded the wrong extension architecture. This can occasionally happen during updates and we're working on resolving it. To resolve try following these steps

  1. Uninstall C# (and devkit) extensions from vscode
  2. Open the extensions folder:
image
  1. Close vscode
  2. Delete all the extensions folders for C# and devkit.
  3. Reinstall the extensions.

If that doesn't work, I could use more info:

  1. Do you have a value specified for the dotnet path in either dotnet.dotnetPath or dotnetAcquisitionExtension.existingDotnetPath in your settings?
  2. Can you provide the output of dotnet --info
  3. Can you set the dotnet.server.trace setting to Trace and share the C# output window logs?

@Hongmo97
Copy link

Hello, thank you for your reply.
My current issue is that after upgrading C # 2.0, the extension always prompts for Downloading. NET version (s) 7.0.10.... And Failed to find dotnet information from path, falling back to acquire runtime via ms dotnettools. vscode dotnet runtime
The architecture of the. NET runtime (x64) does not match the architecture of the extension (x86)
I'm trying to use it to remove the Downloading. NET version (s) 7.0.10 prompt
DotnetAcquisitionExtension. existingDotnetPath:[
{
"ExtensionId": "ms dotnettools. csharp",
Path: "C: Program Files dotnet dotnet. exe"
},
{
"ExtensionId": "ms dotnettools. csdevkit",
Path: "C: Program Files dotnet dotnet. exe"
},
{
"ExtensionId": "visualstudiotoolsforunity. vstuc",
Path: "C: Program Files dotnet dotnet. exe"
}
]

But this resulted in the error output above. I tried reinstalling vscode and dotnet, but it was of no use

This is the output of my dotnet -- info
.NET SDK:
Version: 7.0.400
Commit: 73bf45718d

运行时环境:
OS Name: Windows
OS Version: 10.0.19045
OS Platform: Windows
RID: win10-x64
Base Path: C:\Program Files\dotnet\sdk\7.0.400\

Host:
Version: 7.0.10
Architecture: x64
Commit: a6dbb800a4

.NET SDKs installed:
7.0.400 [C:\Program Files\dotnet\sdk]

.NET runtimes installed:
Microsoft.AspNetCore.App 7.0.10 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 7.0.10 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.WindowsDesktop.App 7.0.10 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

Other architectures found:
x86 [C:\Program Files (x86)\dotnet]
registered at [HKLM\SOFTWARE\dotnet\Setup\InstalledVersions\x86\InstallLocation]

Environment variables:
Not set

global.json file:
Not found

Learn more:
https://aka.ms/dotnet/info

Download .NET:
https://aka.ms/dotnet/download

@dibarbet
Copy link
Member Author

I am fairly sure this issue is caused because the wrong extension platform was installed by vscode (a known bug).

Can you tell me what the full folder name of the installed C# extension is? It should be something like ms-dotnettools.csharp-<version>-<platform>. If there are multiple versions please list them all. You can find that by executing the workbench.extensions.action.openExtensionsFolder command
image

If the extension platform says 'win32-ia32' it means vscode downloaded the wrong extension platform. This can happen occasionally. The x64 dotnet version isn't compatible with the win32-ia32 version of the extension. You will need to uninstall the extension, close vscode, delete those folders, and reinstall.

@reuhil16
Copy link

reuhil16 commented Sep 1, 2023

@Hongmo97

What architecture is your machine? If its x64 it looks like vscode downloaded the wrong extension architecture. This can occasionally happen during updates and we're working on resolving it. To resolve try following these steps

1. Uninstall C# (and devkit) extensions from vscode

2. Open the extensions folder:
image
3. Close vscode

4. Delete all the extensions folders for C# and devkit.

5. Reinstall the extensions.

If that doesn't work, I could use more info:

1. Do you have a value specified for the dotnet path in either `dotnet.dotnetPath` or `dotnetAcquisitionExtension.existingDotnetPath` in your settings?

2. Can you provide the output of `dotnet --info`

3. Can you set the `dotnet.server.trace` setting to `Trace` and share the C# output window logs?

I believe I am also having this issue. My logs look identitical to the reporter's and I can confirm the following:

  • My machine is x64.
  • I do see win32-ia32 in the extension folder name.
  • I do not have dotnet.dotnetPath set in my settings.json
  • I do have dotnetAcquisitionExtension.existingDotnetPath set to
      "dotnetAcquisitionExtension.existingDotnetPath": [
          {
              "extensionId": "ms-dotnettools.csharp",
              "path": "C:\\Program Files\\dotnet\\dotnet.exe"
          }
      ]
    
    but I only set this while trying to debug this issue. Unsetting it does not seem to change anything. There is indeed a dotnet installation at the specified location .
  • Following your outlined steps did not resolve the issue, and the version that was reinstalled at the end of it still had win32-ia32 in its path.
  • In frustration I uninstalled all my extensions, closed VS Code, deleted all folders in the extension folder then opened VS Code again and installed the C# extension again. Same issue, same win32-ia32 in the path.

Output of dotnet --info:

.NET SDK (reflecting any global.json):
 Version:   6.0.413
 Commit:    10710f7d8e

Runtime Environment:
 OS Name:     Windows
 OS Version:  10.0.19045
 OS Platform: Windows
 RID:         win10-x64
 Base Path:   C:\Program Files\dotnet\sdk\6.0.413\

global.json file:
  Not found

Host:
  Version:      6.0.21
  Architecture: x64
  Commit:       e40b3abf1b

.NET SDKs installed:
  2.1.403 [C:\Program Files\dotnet\sdk]
  6.0.413 [C:\Program Files\dotnet\sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.All 2.1.5 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.All 2.1.30 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
  Microsoft.AspNetCore.App 2.1.5 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 2.1.30 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.AspNetCore.App 6.0.21 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 2.1.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 2.1.30 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 3.1.32 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.NETCore.App 6.0.21 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
  Microsoft.WindowsDesktop.App 3.1.32 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  Microsoft.WindowsDesktop.App 6.0.21 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

Download .NET:
  https://aka.ms/dotnet-download

Learn about .NET Runtimes and SDKs:
  https://aka.ms/dotnet/runtimes-sdk-info

C# Extension output after setting dotnet.server.trace to Trace:

Failed to find dotnet info from path, falling back to acquire runtime via ms-dotnettools.vscode-dotnet-runtime
The architecture of the .NET runtime (x64) does not match the architecture of the extension (x86).
Dotnet path: c:\Users\[My Username]\AppData\Roaming\Code\User\globalStorage\ms-dotnettools.vscode-dotnet-runtime\.dotnet\7.0.10\dotnet.exe
Activating C# standalone...
Starting server at c:\Users\[My Username]\.vscode\extensions\ms-dotnettools.csharp-2.0.416-win32-ia32\.roslyn\Microsoft.CodeAnalysis.LanguageServer.exe
Failed to load the dll from [c:\Users\[My Username]\AppData\Roaming\Code\User\globalStorage\ms-dotnettools.vscode-dotnet-runtime\.dotnet\7.0.10\host\fxr\7.0.10\hostfxr.dll], HRESULT: 0x800700C1
The library hostfxr.dll was found, but loading it from c:\Users\[My Username]\AppData\Roaming\Code\User\globalStorage\ms-dotnettools.vscode-dotnet-runtime\.dotnet\7.0.10\host\fxr\7.0.10\hostfxr.dll failed
  - Installing .NET prerequisites might help resolve this problem.
     https://go.microsoft.com/fwlink/?linkid=798306
[Error - 5:43:19 PM] Server initialization failed.
  Message: Pending response rejected since connection got disposed
  Code: -32097 
[Info  - 5:43:19 PM] Connection to server got closed. Server will restart.
true
[Error - 5:43:19 PM] Microsoft.CodeAnalysis.LanguageServer client: couldn't create connection to server.
  Message: Pending response rejected since connection got disposed
  Code: -32097 
Failed to find dotnet info from path, falling back to acquire runtime via ms-dotnettools.vscode-dotnet-runtime
The architecture of the .NET runtime (x64) does not match the architecture of the extension (x86).
Dotnet path: c:\Users\[My Username]\AppData\Roaming\Code\User\globalStorage\ms-dotnettools.vscode-dotnet-runtime\.dotnet\7.0.10\dotnet.exe
Activating C# standalone...
Starting server at c:\Users\[My Username]\.vscode\extensions\ms-dotnettools.csharp-2.0.416-win32-ia32\.roslyn\Microsoft.CodeAnalysis.LanguageServer.exe
Failed to load the dll from [c:\Users\[My Username]\AppData\Roaming\Code\User\globalStorage\ms-dotnettools.vscode-dotnet-runtime\.dotnet\7.0.10\host\fxr\7.0.10\hostfxr.dll], HRESULT: 0x800700C1
The library hostfxr.dll was found, but loading it from c:\Users\[My Username]\AppData\Roaming\Code\User\globalStorage\ms-dotnettools.vscode-dotnet-runtime\.dotnet\7.0.10\host\fxr\7.0.10\hostfxr.dll failed
  - Installing .NET prerequisites might help resolve this problem.
     https://go.microsoft.com/fwlink/?linkid=798306
[Error - 5:43:19 PM] Server initialization failed.
  Message: Pending response rejected since connection got disposed
  Code: -32097 
[Info  - 5:43:19 PM] Connection to server got closed. Server will restart.
true
[Error - 5:43:19 PM] Microsoft.CodeAnalysis.LanguageServer client: couldn't create connection to server.
  Message: Pending response rejected since connection got disposed
  Code: -32097 
Failed to find dotnet info from path, falling back to acquire runtime via ms-dotnettools.vscode-dotnet-runtime
The architecture of the .NET runtime (x64) does not match the architecture of the extension (x86).
Dotnet path: c:\Users\[My Username]\AppData\Roaming\Code\User\globalStorage\ms-dotnettools.vscode-dotnet-runtime\.dotnet\7.0.10\dotnet.exe
Activating C# standalone...
Starting server at c:\Users\[My Username]\.vscode\extensions\ms-dotnettools.csharp-2.0.416-win32-ia32\.roslyn\Microsoft.CodeAnalysis.LanguageServer.exe
Failed to load the dll from [c:\Users\[My Username]\AppData\Roaming\Code\User\globalStorage\ms-dotnettools.vscode-dotnet-runtime\.dotnet\7.0.10\host\fxr\7.0.10\hostfxr.dll], HRESULT: 0x800700C1
The library hostfxr.dll was found, but loading it from c:\Users\[My Username]\AppData\Roaming\Code\User\globalStorage\ms-dotnettools.vscode-dotnet-runtime\.dotnet\7.0.10\host\fxr\7.0.10\hostfxr.dll failed
  - Installing .NET prerequisites might help resolve this problem.
     https://go.microsoft.com/fwlink/?linkid=798306
[Error - 5:43:20 PM] Server initialization failed.
  Message: Pending response rejected since connection got disposed
  Code: -32097 
[Info  - 5:43:20 PM] Connection to server got closed. Server will restart.
true
[Error - 5:43:20 PM] Microsoft.CodeAnalysis.LanguageServer client: couldn't create connection to server.
  Message: Pending response rejected since connection got disposed
  Code: -32097 
[Error - 5:43:20 PM] Restarting server failed
  Message: Pending response rejected since connection got disposed
  Code: -32097 
Failed to find dotnet info from path, falling back to acquire runtime via ms-dotnettools.vscode-dotnet-runtime
The architecture of the .NET runtime (x64) does not match the architecture of the extension (x86).
Dotnet path: c:\Users\[My Username]\AppData\Roaming\Code\User\globalStorage\ms-dotnettools.vscode-dotnet-runtime\.dotnet\7.0.10\dotnet.exe
Activating C# standalone...
Starting server at c:\Users\[My Username]\.vscode\extensions\ms-dotnettools.csharp-2.0.416-win32-ia32\.roslyn\Microsoft.CodeAnalysis.LanguageServer.exe
Failed to load the dll from [c:\Users\[My Username]\AppData\Roaming\Code\User\globalStorage\ms-dotnettools.vscode-dotnet-runtime\.dotnet\7.0.10\host\fxr\7.0.10\hostfxr.dll], HRESULT: 0x800700C1
The library hostfxr.dll was found, but loading it from c:\Users\[My Username]\AppData\Roaming\Code\User\globalStorage\ms-dotnettools.vscode-dotnet-runtime\.dotnet\7.0.10\host\fxr\7.0.10\hostfxr.dll failed
  - Installing .NET prerequisites might help resolve this problem.
     https://go.microsoft.com/fwlink/?linkid=798306
[Error - 5:43:20 PM] Server initialization failed.
  Message: Pending response rejected since connection got disposed
  Code: -32097 
[Info  - 5:43:20 PM] Connection to server got closed. Server will restart.
true
[Error - 5:43:20 PM] Microsoft.CodeAnalysis.LanguageServer client: couldn't create connection to server.
  Message: Pending response rejected since connection got disposed
  Code: -32097 
[Error - 5:43:20 PM] Restarting server failed
  Message: Pending response rejected since connection got disposed
  Code: -32097 
Failed to find dotnet info from path, falling back to acquire runtime via ms-dotnettools.vscode-dotnet-runtime
The architecture of the .NET runtime (x64) does not match the architecture of the extension (x86).
Dotnet path: c:\Users\[My Username]\AppData\Roaming\Code\User\globalStorage\ms-dotnettools.vscode-dotnet-runtime\.dotnet\7.0.10\dotnet.exe
Activating C# standalone...
Starting server at c:\Users\[My Username]\.vscode\extensions\ms-dotnettools.csharp-2.0.416-win32-ia32\.roslyn\Microsoft.CodeAnalysis.LanguageServer.exe
Failed to load the dll from [c:\Users\[My Username]\AppData\Roaming\Code\User\globalStorage\ms-dotnettools.vscode-dotnet-runtime\.dotnet\7.0.10\host\fxr\7.0.10\hostfxr.dll], HRESULT: 0x800700C1
The library hostfxr.dll was found, but loading it from c:\Users\[My Username]\AppData\Roaming\Code\User\globalStorage\ms-dotnettools.vscode-dotnet-runtime\.dotnet\7.0.10\host\fxr\7.0.10\hostfxr.dll failed
  - Installing .NET prerequisites might help resolve this problem.
     https://go.microsoft.com/fwlink/?linkid=798306
[Error - 5:43:21 PM] Server initialization failed.
  Message: Pending response rejected since connection got disposed
  Code: -32097 
[Error - 5:43:21 PM] The Microsoft.CodeAnalysis.LanguageServer server crashed 5 times in the last 3 minutes. The server will not be restarted. See the output for more information.
[Error - 5:43:21 PM] Microsoft.CodeAnalysis.LanguageServer client: couldn't create connection to server.
  Message: Pending response rejected since connection got disposed
  Code: -32097 
[Error - 5:43:21 PM] Restarting server failed
  Message: Pending response rejected since connection got disposed
  Code: -32097 

@dibarbet
Copy link
Member Author

dibarbet commented Sep 1, 2023

Following your outlined steps did not resolve the issue, and the version that was reinstalled at the end of it still had win32-ia32 in its path.

Very weird - this really seems like a vscode / marketplace bug. If you're on an x64 machine you should be getting the x64 extension version.

One question - do you by chance have the x86 version of vscode installed? You can check in Help -> About. It'll say Windows_NT ia32 for the OS
image

I noticed I got the ia32 version of the extension if I use the ia32 version of vscode, even on a x64 OS.

@reuhil16
Copy link

reuhil16 commented Sep 4, 2023

One question - do you by chance have the x86 version of vscode installed? You can check in Help -> About. It'll say Windows_NT ia32 for the OS

I noticed I got the ia32 version of the extension if I use the ia32 version of vscode, even on a x64 OS.

This was the problem. After installing VSCode x64 I was able to install the x64 version of the extension and it is working correctly.

I did notice that the installer I downloaded was called VSCodeSetup-x64-1.81.1.exe while the installer I had initially used was just called VSCodeSetup-stable.exe without reference to architecture (version 1.6.1 downloaded and installed in 2016). This makes me wonder if there was at some point a single installer that was supposed to detect my architecture and install the correct binaries, or even defaulted to an x86 version, potentially meaning many people with long-running installations are unintentially running the wrong version. Although its equally possible I just messed up back in 2016 and your file naming convention was just different.

In any case its all working now, thanks for your help dibarbet.

@dibarbet
Copy link
Member Author

dibarbet commented Sep 5, 2023

Great to hear it works!

For some additional context on why this changes in 2.x - O# previously used to do a runtime download of the server which would download based on the actual underlying OS platform. So even if you got the ia32 version of the extension it would still use an x64 version. But now we package the server inside the extension itself and so it gets the ia32 server version.

Closing this issue as I think the cause is clear. I filed #6280 to track surfacing a better error message here.

@dibarbet dibarbet closed this as completed Sep 5, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants