Unhandled exception. System.IO.FileNotFoundException: Could not load file or assembly 'System.Console, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified.

chaowen guo 21 Reputation points
2025-09-18T06:58:29.83+00:00

I have a Cli.dll and need to run it as dotnet Cli.dll. In ubuntu, everything works fine. But in debian, I get Unhandled exception. System.IO.FileNotFoundException: Could not load file or assembly 'System.Console, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified. But when i run dotnet --list-runtimes I can see System.Console.dll right in /usr/share/dotnet/shared/Microsoft.NETCore.App/8.0.12. Why dotnet can not find System.Console?

I use

curl https://packages.microsoft.com/config/debian/11/packages-microsoft-prod.deb -O packages-microsoft-prod.deb
dpkg -i packages-microsoft-prod.deb
rm packages-microsoft-prod.deb
apt update
apt install -y --no-install-recommends dotnet-sdk-8.0

to install the dotnet the debian is bullseye, ubuntu in on 24.04 and 22.04

I want to know why and how to fix the problem?

Developer technologies | .NET | .NET Runtime
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Surya Amrutha Vaishnavi Lanka (INFOSYS LIMITED) 810 Reputation points Microsoft External Staff
    2025-09-19T06:37:41.53+00:00

    This issue occurs due to missing or misconfigured **.runtimeconfig.json or .deps.json **files, incorrect framework references in the project.

    Here are some steps which may be helpful

    1.Ensure Proper Runtime Configuration

    Make sure your Cli.dll is accompanied by:

    • Cli.runtimeconfig.json
    • Cli.deps.json

    2.Use FrameworkReference Instead of PackageReference

    If you're using a non-SDK-style project or manually referencing DLLs, switch to using FrameWorkReference.

    3.Manually Set Runtime Path

    If you're running the app manually, set the runtime path explicitly

    4.Avoid --no-install-recommends

    When installing the SDK, avoid stripping recommended packages


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.