I recently bumped the target runtime for a console application from .NET 6 to .NET 8, rebuilt, and now it throws a cryptic error on launch. The process exits immediately, and the usual diagnostic output isn't showing up. Has anyone run into this before?
The first thing I checked was whether the runtime was actually installed. I ran dotnet --list-runtimes and .NET 8 showed up fine. Next, I verified the TargetFramework in the project file matched what I expected, and I double-checked that there were no lingering appsettings.Development.json overrides pointing to an older SDK.
What usually trips this up is a mismatch between the runtime and the SDK, or the app relying on a native dependency that was compiled against a different ABI. If you have any C++/CLI wrappers, third-party native DLLs, or even certain NuGet packages with native assets, they can refuse to load under a newer runtime. Another common culprit is the Microsoft.AspNetCore.App shared framework version drifting out of sync with your target.
A quick way to narrow it down is to run the app under a debugger or with dotnet run --verbosity diagnostic. If you see a BadImageFormatException or a failure to load a specific assembly, that usually points to an architecture or version mismatch rather than a pure configuration issue.
If you're still stuck, paste the exact exception and the contents of your .csproj here. It might also help to confirm whether you're using a self-contained deployment or relying on the shared runtime on the target machine.