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:
Entity Framework Core
Entity Framework Core
A lightweight, extensible, open-source, and cross-platform version of the Entity Framework data access technology.
769 questions
.NET
.NET
Microsoft Technologies based on the .NET software framework.
4,014 questions
ASP.NET Core
ASP.NET Core
A set of technologies in the .NET Framework for building web applications and XML web services.
4,717 questions
ASP.NET
ASP.NET
A set of technologies in the .NET Framework for building web applications and XML web services.
3,552 questions
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
11,158 questions
{count} votes

Accepted answer
  1. Zhi Lv - MSFT 32,816 Reputation points Microsoft Vendor
    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.