netstandard20 中的 System.Data.Linq [英] System.Data.Linq in netstandard20

查看:27
本文介绍了netstandard20 中的 System.Data.Linq的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个引用 .Net 4.6 项目的 netstandard20 项目,除了调用 .Net 4.6 项目中的任何功能外,所有编译和运行都得到了以下错误.

<块引用>

FileNotFoundException:无法加载文件或程序集System.Data.Linq,版本=4.0.0.0,文化=中性,PublicKeyToken=b77a5c561934e089".系统找不到指定的文件.

在 VS 2017 中,在 Dependancies/SDK/Microsoft.NETCore.App 下的项目资源管理器中,我可以看到 System.Data.dllSystem.Data.Common.dll 但没有引用 System.Data.Linq.dll,我假设这是我的问题,它没有被拉进来.

如何让我的项目包含 System.Data.Linq.dll?

如果我包含 C:Program Files (x86)Reference AssembliesMicrosoftFramework.NETFrameworkv4.6System.Data.Linq.dll 我得到以下错误><块引用>

BadImageFormatException: 无法加载文件或程序集System.Data.Linq,版本=4.0.0.0,Culture=neutral,PublicKeyToken=b77a5c561934e089".不应为执行加载引用程序集.它们只能在仅反射加载器上下文中加载.(来自 HRESULT 的异常:0x80131058)

解决方案

System.Data.Linq 不是 .NET Standard 2.0 和 .NET Core 2.0 的一部分,因此不能在该平台上使用.

即使您已经能够通过兼容性垫片添加对 .NET 4.6 项目的引用,它在运行时还是会因为目标运行时不可用的功能而失败

I have a netstandard20 project that references a .Net 4.6 Project, all compiles and runs except where I call any functionality in the .Net 4.6 project, I get the following error.

FileNotFoundException: Could not load file or assembly 'System.Data.Linq, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'. The system cannot find the file specified.

In VS 2017, in the project explorer under Dependancies / SDK / Microsoft.NETCore.App I can see System.Data.dll and System.Data.Common.dll but no reference to System.Data.Linq.dll, I am assuming this is my problem and it has not been pulled in.

How do I get my project to include System.Data.Linq.dll?

If I include C:Program Files (x86)Reference AssembliesMicrosoftFramework.NETFrameworkv4.6System.Data.Linq.dll I get the following error

BadImageFormatException: Could not load file or assembly 'System.Data.Linq, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'. Reference assemblies should not be loaded for execution. They can only be loaded in the Reflection-only loader context. (Exception from HRESULT: 0x80131058)

解决方案

System.Data.Linq is not part of .NET Standard 2.0 and .NET Core 2.0 and therefore cannot be used on that platform.

Even tough you have been able add a reference to a .NET 4.6 project via the compatibility shims, it fails at runtime because of a feature that is not available on the target runtime

这篇关于netstandard20 中的 System.Data.Linq的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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