failed load hostfxr.dll at .net9 self-container app on win10,win7

SIR WANG 0 Reputation points
2025-12-02T03:03:59.5266667+00:00

i write a client app with .net9 vs2026, and publish with self-container.
but it can't be run when i double-click on (win10,win7) part of my client machine.
i look eventlog and get this. how to reslove this?

i got a information for win7, install a fix, see to https://www.catalog.update.microsoft.com/Search.aspx?q=KB4457144
but win10?

bug info:
Description: A .NET application failed.

Application: Ossi.App.exe

Path: D:\新治超检测站级系统\Ossi.App\Ossi.App.exe

Message: Failed to load the dll from [D:\新治超检测站级系统\Ossi.App\hostfxr.dll], HRESULT: 0x80070017

The library hostfxr.dll was found, but loading it from D:\新治超检测站级系统\Ossi.App\hostfxr.dll failed

Failed to resolve hostfxr.dll [D:\新治超检测站级系统\Ossi.App\hostfxr.dll]. Error code: 0x80008082

Developer technologies | .NET | .NET Runtime
{count} votes

1 answer

Sort by: Most helpful
  1. Varsha Dundigalla(INFOSYS LIMITED) 3,725 Reputation points Microsoft External Staff
    2025-12-02T11:19:09.0066667+00:00

    Thank you for reaching out.

    The error Failed to load hostfxr.dll (HRESULT: 0x80070017) means the app cannot read the required runtime file. This usually happens because:

    • Files in the published folder are corrupted or incomplete.
    • Antivirus or security services block or modify files after first run.
    • On Windows 7, missing SHA‑2 support (KB4457144 update) prevents .NET 9 apps from running.
    • Disk or copy errors during deployment.

    Steps you can try

    1. Verify published files
      • Re-publish the app as Self-contained for the correct OS architecture (x64/x86).
      • Copy files using a reliable method (avoid partial ZIP extraction).
    2. Check OS prerequisites
    3. Run as Administrator
      • Right-click the .exeRun as Administrator to avoid permission issues.
    4. Disable antivirus temporarily
      • Some security tools block hostfxr.dll. Test after disabling antivirus/firewall.
    5. Repair corrupted files
      • If error persists, delete the app folder and copy fresh files from the publish output.
    6. Check Event Viewer logs
      • Look for disk errors or security service interference (Software Protection Service restart).

    Tips:

    • Always publish with dotnet publish -r win10-x64 --self-contained true.
    • Use single-folder deployment and verify integrity before shipping.
    • Avoid modifying files after publishing.

    Please let us know if you require any further assistance, we’re happy to help.

    If you found this information useful, kindly mark this as "Accept Answer".


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.