从 .NET Core 1.0 类库引用 mscorlib 4.0.0.0 [英] Referencing mscorlib 4.0.0.0 from .NET Core 1.0 class library
问题描述
我有一个面向 .NET 4.6.1 的 .NET Core 1.0 类库,并引用了 .NET Standard Library 1.6.0 和 Identity Framework 2.2.1
I have a .NET Core 1.0 class library which targets .NET 4.6.1 and references the .NET Standard Library 1.6.0 and Identity Framework 2.2.1
project.json
{
"version": "1.0.0-*",
"dependencies": {
"Microsoft.AspNet.Identity.EntityFramework": "2.2.1",
"System.Runtime": "4.1.0",
"NETStandard.Library": "1.6.0"
},
"frameworks": {
"netstandard1.6": {
"imports": [
"net461"
]
}
}
}
在我的项目中,我只是创建身份模型,它扩展了基本的身份框架模型(用户、角色等).当我尝试编译时,会发生这种情况...
In my project I'm just creating the identity models, which extend the base Identity Framework models (User, Role etc). When I try to compile, this happens...
任何想法如何解决这个问题?
Any ideas how to resolve this?
推荐答案
你的项目文件有两个问题,一个容易修复,一个不可能修复;)
There are two problems with your project file here, one simple to fix, one impossible to fix ;)
- 您的项目不针对
net461
和netstandard1.6
.你的 project.json 说的是:为netstandard1.6
构建目标并欺骗 NuGet 并声称你是net461
(这就是import
确实......不相信我,查一下;)).由于您的 project.json 欺骗了 NuGet,您可以添加Microsoft.AspNet.Identity.EntityFramework
.并行添加net461
和netstandard1.6
也无济于事,因为您无法添加依赖项. - NuGet 依赖项
Microsoft.AspNet.Identity.EntityFramework
于 2015 年发布,基于 .NET Framework(基于 mscorlib),而不是基于 .NET Standard/.NET Core(基于 System.Runtime).对于依赖项基于mscorlib
而不是System.Runtime
的事实,谎言无济于事.
- Your project does not target
net461
andnetstandard1.6
. What your project.json says is: Build target fornetstandard1.6
and lie to NuGet and claim you arenet461
(that lying is whatimport
does ... do not believe me, look it up ;)). And since your project.json lied to NuGet, you where able to addMicrosoft.AspNet.Identity.EntityFramework
. Addingnet461
andnetstandard1.6
in parallel will not help you either because you cannot add the dependency then. - The NuGet dependency
Microsoft.AspNet.Identity.EntityFramework
is released in 2015 and based on the .NET Framework (mscorlib based) and not on .NET Standard / .NET Core (System.Runtime based). The lying does not help about the fact that the dependency is based onmscorlib
and notSystem.Runtime
.
您可以尝试的是(正确地)并行定位 net461
和 netstandard1.6
并尝试使用 Microsoft.AspNet.Identity 进行并行实现.EntityFramework
和 Microsoft.AspNetCore.Identity.EntityFrameworkCore
分别使用 #ifdefs.但是,结果会有多有用,我不知道将使用什么结果库;)
What you could try, is targeting (correctly) in parallel net461
and netstandard1.6
and try to do a parallel implementation with Microsoft.AspNet.Identity.EntityFramework
and Microsoft.AspNetCore.Identity.EntityFrameworkCore
respectively using #ifdefs. However, how useful the result would be, I have no idea for what the resulting library would be used ;)
这篇关于从 .NET Core 1.0 类库引用 mscorlib 4.0.0.0的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!