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