How to call function in .Net Framework to .Net cor

2019-08-05 07:38发布

问题:

I am doing a project that use both .net framework and .net core.

I want to call repository that fetch data in API controller of .net core but i get the following error:

System.TypeLoadException: 'Could not load type 'System.Web.HttpContext' from assembly 'System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.'

Pls help me, thank you.

回答1:

You are not in position to call functions in .NET core from .NET framework. Rather, I recomment that for the functions and classes shared between both of your projects, you write them in a library in .NET Standard. This will be accessible from both the .NET framework projects and .NET core projects.

For more information about NET architectural components (.NET standard, core and framework), kindly visit https://docs.microsoft.com/en-us/dotnet/standard/components

Thank you



标签: c# .net-core