如何将.Net Framework中的函数调用到.Net Core [英] How to call function in .Net Framework to .Net core

查看:601
本文介绍了如何将.Net Framework中的函数调用到.Net Core的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在做一个使用.net框架和.net核心的项目.

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

我想调用在.net core的API控制器中获取数据的存储库,但出现以下错误:

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

System.TypeLoadException:'无法从程序集'System.Web,Version = 4.0.0.0,Culture = neutral,PublicKeyToken = b03f5f7f11d50a3a'中加载类型'System.Web.HttpContext'.'

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

请帮助我,谢谢.

推荐答案

您无法从.NET框架调用.NET Core中的函数.相反,我建议对于两个项目之间共享的功能和类,将它们写在.NET Standard的库中. .NET框架项目和.NET核心项目都可以访问.

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.

有关NET体系结构组件(.NET标准,核心和框架)的更多信息,请访问

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

谢谢

这篇关于如何将.Net Framework中的函数调用到.Net Core的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆