locked
C# application looking for runtime in wrong location RRS feed

  • Question

  • I have the .NET SDK installed on my Windows laptop and am able to run a simple C# HelloWorld program. .Net is installed at C:\Program Files\dotnet and I also have that set in my PATH variable.

    I'm now trying to run another C# application. It's run with an exe but all I can see is a cmd window quickly flash on the screen. The following error is in my Event Viewer:

    Description: A .NET Core application failed.
    Application: Cdi.FinancialCalculator.Api.exe
    Path: C:\workspace\DataInsights\content\di.Calculator.Api.exe
    Message: A fatal error occurred. The required library hostfxr.dll could not be found.
    If this is a self-contained application, that library should exist in [C:\workspace\DataInsights\content\].
    If this is a framework-dependent application, install the runtime in the global location [C:\Program Files (x86)\dotnet] or use the DOTNET_ROOT(x86) environment variable to specify the runtime location or register the runtime location in [HKLM\SOFTWARE\dotnet\Setup\InstalledVersions\x86\InstallLocation].
    
    The .NET Core runtime can be found at:
      - https://aka.ms/dotnet-core-applaunch?missing_runtime=true&arch=x86&rid=win10-x86

    It's like this application is looking for the .NET runtime in the wrong location. How do I resolve this?

    Friday, September 11, 2020 7:31 AM

All replies

  • I have the .NET SDK installed on my Windows laptop and am able to run a simple C# HelloWorld program. .Net is installed at C:\Program Files\dotnet and I also have that set in my PATH variable.

    I'm now trying to run another C# application. It's run with an exe but all I can see is a cmd window quickly flash on the screen. The following error is in my Event Viewer:

    Description: A .NET Core application failed.
    Application: Cdi.FinancialCalculator.Api.exe
    Path: C:\workspace\DataInsights\content\di.Calculator.Api.exe
    Message: A fatal error occurred. The required library hostfxr.dll could not be found.
    If this is a self-contained application, that library should exist in [C:\workspace\DataInsights\content\].
    If this is a framework-dependent application, install the runtime in the global location [C:\Program Files (x86)\dotnet] or use the DOTNET_ROOT(x86) environment variable to specify the runtime location or register the runtime location in [HKLM\SOFTWARE\dotnet\Setup\InstalledVersions\x86\InstallLocation].
    
    The .NET Core runtime can be found at:
      - https://aka.ms/dotnet-core-applaunch?missing_runtime=true&arch=x86&rid=win10-x86

    It's like this application is looking for the .NET runtime in the wrong location. How do I resolve this?

    As the error says, you need your DotNET SDK installation to be located in C:\Program Files (x86)\dotnet or else the real path needs to be represented in the DOTNET_ROOT(x86) environment variable, not the PATH. 

    Are you sure you ever actually installed a 32-bit SDK in the first place?  If the SDK was universal then you could just make a copy from C:\Program Files\dotnet to C:\Program Files (x86)\dotnet, but I don't work with DotNET Core because WPF is garbage and the Metro-Style apps it spits out are worse than garbage, so I don't know if that's good advice or not.


    Before you can learn anything new you have to learn that there's stuff you don't know.

    Friday, September 11, 2020 3:17 PM
  • Here is the same issue solved by a windows update.

    Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.

    NuGet BaseConnectionLibrary for database connections.

    StackOverFlow
    profile for Karen Payne on Stack Exchange

    Friday, September 11, 2020 6:15 PM
  • I added the DOTNET_ROOT(x86) environment variable but when I now try to run the application I get

    Description: A .NET Core application failed.
    Application: di.Calculator.Api.exe
    Path: C:\Workspace\DataInsights\content\di.FinancialCalculator.Api.exe
    Message: Failed to load the dll from [C:\Program Files\dotnet\host\fxr\3.1.3\hostfxr.dll], HRESULT: 0x800700C1
    The library hostfxr.dll was found, but loading it from C:\Program Files\dotnet\host\fxr\3.1.3\hostfxr.dll failed
      - Installing .NET Core prerequisites might help resolve this problem.
         https://go.microsoft.com/fwlink/?linkid=798306
    

    Monday, September 14, 2020 7:35 PM
  • I added the DOTNET_ROOT(x86) environment variable but when I now try to run the application I get

    Description: A .NET Core application failed.
    Application: di.Calculator.Api.exe
    Path: C:\Workspace\DataInsights\content\di.FinancialCalculator.Api.exe
    Message: Failed to load the dll from [C:\Program Files\dotnet\host\fxr\3.1.3\hostfxr.dll], HRESULT: 0x800700C1
    The library hostfxr.dll was found, but loading it from C:\Program Files\dotnet\host\fxr\3.1.3\hostfxr.dll failed
      - Installing .NET Core prerequisites might help resolve this problem.
         https://go.microsoft.com/fwlink/?linkid=798306

    So the issue is that you don't have the 32-bit version of the SDK installed.  Remove your DOTNET_ROOT(x86) env var and go download and install the 32-bit SDK.

    Before you can learn anything new you have to learn that there's stuff you don't know.

    Monday, September 14, 2020 7:46 PM