c# - netstandard20 中的 System.Data.Linq

标签 c# .net-standard .net-standard-2.0

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

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.



在 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 Assemblies\Microsoft\Framework\.NETFramework\v4.6\System.Data.Linq.dll我收到以下错误

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 的需要在 .NET Standard 2.0 库中使用 Mindbox.Data.Linq NuGet 包。

安装后,您应该可以使用 System.Data.Linq命名空间就像您在为 .NET Framework 编写时一样!

关于c# - netstandard20 中的 System.Data.Linq,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45935148/

相关文章:

c# - String.Trim() 删除的所有字符的列表?

c# - .NET Standard F# 库不能正确存储非英文字符

c# - 如何解决多个库中存在的 HttpClient

.net - 无法安装 .NET Standard 2.0

c# - 将日期和时间从 JavaScript 解析为 C#

Webmatrix 和 JQgrid 中的 C# razor

c# - 使用 Mailgun API 和 RestSharp C# 发送 HTML 电子邮件,导致消息在包含&符号 "&"时被截断

c# - 在 nuget 包中包含引用的项目

Azure Function 给出错误 : System. 此平台不支持绘图

c# - 来自引用的 .NET Standard 项目的多个 DLL