Fix the error "Could not load file or assembly 'System.Runtime, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified"

iman padid 20 Reputation points
2024-12-31T09:51:42.41+00:00
I am using "Asp.net Web Application (.net framework ver 4.8)" and Class Library .net8 but when I reference it I get an error.

Server Error in '/' Application.

Could not load file or assembly 'System.Runtime, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
 Description: 

Assembly Load Trace:


Version Information:
Developer technologies | .NET | Entity Framework Core
Developer technologies | ASP.NET | ASP.NET Core
Developer technologies | .NET | Other
Developer technologies | ASP.NET | Other
Developer technologies | C#
{count} votes

Accepted answer
  1. Anonymous
    2025-01-01T03:29:10.0666667+00:00

    Hi @iman padid

    I am using "Asp.net Web Application (.net framework ver 4.8)" and Class Library .net8 but when I reference it I get an error. Could not load file or assembly 'System.Runtime, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.

    The issue arises because .NET Framework (your ASP.NET Web Application) and .NET 8 (your Class Library) are fundamentally different runtime platforms. They are not directly compatible because .NET 8 uses the .NET Core/Modern .NET runtime, while .NET Framework targets the legacy .NET runtime and supports libraries compatible with it.

    More difference between them, refer to the following articles:

    .NET vs. .NET Framework for server apps

    ASP.NET Core targeting .NET Framework

    According to your description, I assume you want to create a class library which is compatible with both .NET Framework 4.8 and .NET 8. If that's the case, you can try to change the target framework of your class library to .NET Standard 2.0 or .NET Standard 2.1, or create a new .NET Standard 2.0 or .NET Standard 2.1 class library, these versions are compatible with both .NET Framework 4.8 and .NET 8.

    Besides, you can also create a .NET Framework 4.8 Class library and use it in your web application. Or you can upgrade the web application from .NET Framework to Asp.net core, then you can use your .NET 8 class library.

    Refer to: Upgrade from ASP.NET Framework to ASP.NET Core


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    Best regards,

    Dillion

    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

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