0

I have made a dll in .net core 6 and I want to call it in an asp.net project having framework 4.8. I just clicked Add Reference and browsed the dll. When I run the project, it gives the following exception:

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

Any ideas how to solve this?

7
  • You can't. That's it. .NET 6 is .NET Core 6. You can't call .NET Core libraries from .NET Framework libraries Commented Jul 25, 2022 at 7:18
  • 2
    Does this answer your question? Mixing .Net Framework app with .Net Core library Commented Jul 25, 2022 at 7:19
  • Another similar Invoke method from .Net Core library in .Net framework application: You can't, it has to be a .NET Standard library Commented Jul 25, 2022 at 7:21
  • What are you trying to do? If this is a new application it should target .NET Core, not .NET Framework. If you want to use one of the Microsoft.Extensions.* packages, you won't have problems if you add them directly, as they target .NET Standard 2.0. If you use a library that uses the Microsoft.Extensions.*, you should change it into a .NET Standard library if you want to use it in .NET Framework applications Commented Jul 25, 2022 at 7:24
  • @PanagiotisKanavos I have created a .net core dll to distribute. I am trying to create a web UI as a demo app for the dll. I don't have any experience in creating web UIs with .net core this is why I am using simple asp.net framework 4.8. Commented Jul 25, 2022 at 11:08

1 Answer 1

1

You could try targeting it to .NET Standard 2.0

https://learn.microsoft.com/en-us/dotnet/standard/net-standard?tabs=net-standard-2-0. It could then be consumed by .NET Framework 4.8. Your ability to do this would depend on what libraries you consume and all of them having a .NET Standard 2.0 or lower target.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.