Hi Khaled Haniche,
Thank you for reaching out Microsoft Q&A regarding the issue you encountered while launching your application.
I understand that you received the error code 0xc000012f (Bad Image) related to hostfxr.dll, followed by a prompt to install a newer version of .NET Core. Even after replacing the DLL and installing the suggested runtime, the issue persists.
To help resolve this, I recommend the following steps:
Step 1: Run System File Checker and DISM
-Open Command Prompt as Administrator and run:
sfc /scannow
DISM.exe /Online /Cleanup-image /Restorehealth
-Restart your device to apply changes then check again.
Step 2: Reinstall .NET Runtime
Uninstall all existing .NET runtimes via Control Panel.
- Download and install the latest version from https://dotnet.microsoft.com/en-us/download/dotnet.
- Restart your computer after installation.
Step 3: Install Visual C++ Redistributables
Please ensure the latest supported Visual C++ Redistributables are installed:
https://learn.microsoft.com/en-us/cpp/windows/latest-supported-vc-redist?view=msvc-170
Step 4: Perform a Clean Boot
This helps rule out third-party software conflicts:
-Press Win + R, type msconfig, and press Enter.
- Under Services, check "Hide all Microsoft services" and click Disable all.
- Under Startup, open Task Manager and disable all items.
Restart your PC and try launching the app again.
*Disclaimer: A "clean boot" starts Windows with a minimal set of drivers and startup programs. It helps to determine whether a background service is interfering with your game or program and to isolate the cause of a problem.
These steps of "clean boot" might look complicated at first glance. However, to avoid any trouble for you, please follow them in order and step-by-step so that it will help you get back on track.
In case the issue still persists, please let me know the exact application you're using and whether your app targets a specific .NET Core version. I’ll be happy to assist further.