我有一个包含对象模型的 asp.net 5 类库,我需要与面向 .Net Framework 4.0 Client Profile 的 WinForms 应用程序共享该对象模型。
我已经从 asp.net 5 类库创建了一个 Nuget 包,并尝试从 WinForms 应用程序引用这个 NuGet 包。但是,在添加引用时出现以下错误:
Could not install package 'package name 1.0.0'. You are trying to install this package into a project that targets '.NETFramework,Version=v4.0', but the package does not contain any assembly references or content files that are compatible with that framework. For more information, contact the package author.
我尝试在我的 project.json 文件的“框架”部分中添加 DNX40 作为目标框架,如下所示。
{
"authors": [ "author" ],
"dependencies": {
},
"description": "Shared object models",
"frameworks": {
"dnx40": { },
"dnx451": { },
"dnxcore50": {
"dependencies": {
"System.Collections": "4.0.10-beta-22816",
"System.Linq": "4.0.0-beta-22816",
"System.Threading": "4.0.10-beta-22816",
"Microsoft.CSharp": "4.0.0-beta-22816"
}
}
},
"licenseUrl": "",
"projectUrl": "",
"tags": [ "" ],
"version": "1.0.0-*"
}
我怀疑我针对的是错误的框架版本。
但如何将 .Net Framework 4.0 Client Profile 指定为目标框架?这可能吗?
最佳答案
使用net40
:
"frameworks": {
"net40": {},
"dnx451": { },
"dnxcore50": {}
}
关于nuget - 从面向 .Net 4.0 客户端配置文件的 Win Forms 应用程序引用由 asp.net 5 类库创建的 nuget 包,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31177539/