我有一个引用 .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.dll
和 System.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/