gpt4 book ai didi

visual-studio - 如何修复 Visual Studio 2015 中引用的 netstandard1.5 库项目的智能感知?

转载 作者:行者123 更新时间:2023-12-04 03:45:07 24 4
gpt4 key购买 nike

我有四个库项目都以 netstandard1.5 框架为目标。其中一些依赖于另一个,智能感知在这四个项目下运行良好。

我正在尝试在我的 ASP.NET netcoreapp1.0 项目中使用这些库。但是当我以 netcoreapp1.0 框架为目标时,找不到类型(在 visual studio 中用红色标出)。项目hower编译运行成功。

只要我切换到我的网络 API 中的 netstandard1.5 框架,库的类型就会被识别,我会获得智能感知。

关于如何解决这个问题或我做错了什么有什么想法吗?

这是其中一个库项目的 project.json(它们几乎相同):

{
"version": "1.0.0-*",

"frameworks": {
"netstandard1.5": {
"imports": [ "dnxcore50", "portable-net45+win8" ],
"dependencies": {
"NETStandard.Library": "1.5.0-rc2-24027",

"System.Security.Principal": "4.0.1-rc2-24027"
}
}
},
"dependencies": {
"Microsoft.AspNetCore.Identity": "1.0.0-rc2-final",
"Microsoft.EntityFrameworkCore": "1.0.0-rc2-final",
"HoehenSucht.Models": "1.0.0-*",
"Microsoft.NETCore.Portable.Compatibility": "1.0.1-rc2-24027"
}
}

这是 api 的 project.json:

{
"version": "1.0.0-*",
"buildOptions": {
"emitEntryPoint": true
},
"dependencies": {
"HoehenSucht.Framework": "1.0.0-*",
"HoehenSucht.Models": "1.0.0-*",
"HoehenSucht.Repositories": "1.0.0-*",
"HoehenSucht.Services": "1.0.0-*",
"HoehenSucht.Authentication": "1.0.0-*",
"Microsoft.ApplicationInsights.AspNetCore": "1.0.0-rc2-final",
"Microsoft.Extensions.Configuration": "1.0.0-rc2-final",
"Microsoft.Extensions.Logging": "1.0.0-rc2-final",
"Microsoft.Extensions.Logging.Console": "1.0.0-rc2-final",
"Microsoft.Extensions.Logging.Debug": "1.0.0-rc2-final",
"Autofac.Extensions.DependencyInjection": "4.0.0-rc2-240",
"AutoMapper": "4.2.1",
"Microsoft.VisualStudio.Web.BrowserLink.Loader": "14.0.0-rc1-final",
"System.Security.Principal": "4.0.1-rc2-24027",
"System.Reflection": "4.1.0-rc2-24027",
"IdentityServer4.AccessTokenValidation": "1.0.0-beta6",
"Microsoft.AspNetCore.Authorization": "1.0.0-rc2-final",
"Microsoft.AspNetCore.Diagnostics": "1.0.0-rc2-final",
"Microsoft.AspNetCore.Mvc": "1.0.0-rc2-final",
"Microsoft.AspNetCore.Hosting": "1.0.0-rc2-final",
"Microsoft.AspNetCore.Server.Kestrel": "1.0.0-rc2-final",
"Microsoft.EntityFrameworkCore": "1.0.0-rc2-final",
"Microsoft.EntityFrameworkCore.SqlServer": "1.0.0-rc2-final",
"Microsoft.EntityFrameworkCore.Tools": "1.0.0-preview1-final",
"Autofac": "4.0.0-rc2-240",
"Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore": "1.0.0-rc2-final",
"HoehenSucht.API.Models": "1.0.0-*",
"Microsoft.Extensions.Configuration.EnvironmentVariables": "1.0.0-rc2-final",
"Microsoft.AspNetCore.StaticFiles": "1.0.0-rc2-final",
"Microsoft.AspNetCore.Server.IISIntegration": "1.0.0-rc2-final",
"System.Linq": "4.1.0-rc2-24027",
"Microsoft.Extensions.Configuration.FileExtensions": "1.0.0-rc2-final",
"Microsoft.Extensions.Configuration.Json": "1.0.0-rc2-final",
"System.Linq.Parallel": "4.0.1-rc2-24027",
},
"frameworks": {
"netcoreapp1.0": {
"dependencies": {
"Microsoft.NETCore.App": {
"type": "platform",
"version": "1.0.0-*"
},
"System.Collections": "4.0.11-rc2-24027",
},
"imports": [ "dnxcore50", "portable-net45+win8" ]
}
},
"tools": {
"Microsoft.EntityFrameworkCore.Tools": {
"version": "1.0.0-preview1-final",
"imports": [
"portable-net45+win8+dnxcore50",
"portable-net45+win8"
]
}
}
}

最佳答案

Resharper 是这里的问题,而不是 Visual Studio。

http://blog.jetbrains.com/dotnet/2016/05/27/resharper-ultimate-2016-2-eap-kicks-off/

Initial support of ASP.NET Core 1.0 RC2, including support for tag helpers in terms of code completion, navigation, search and refactorings. At this point, ASP.NET Core web applications are supported if they’re targeting .NET Framework but are not supported if they’re targeting .NET Core. We’re looking to improve this in subsequent builds.

因此,如果您有一个面向 .netstandard1.5 的库,Resharper 将无法正确显示智能感知信息,但项目会编译。

但是,如果您将 .netcoreapp1.0 框架作为附加框架添加到 project.json 文件中,Resharper 将工作并且您将获得完整的智能感知支持。

 frameworks": {
"netstandard1.5": {
"imports": [ "dnxcore50", "portable-net45+win8" ],
"dependencies": {
"NETStandard.Library": "1.5.0-rc2-24027",

"System.Security.Principal": "4.0.1-rc2-24027"
}
},
".netcoreapp1.0": {
"imports": [ "dnxcore50", "portable-net45+win8" ]
}
},

关于visual-studio - 如何修复 Visual Studio 2015 中引用的 netstandard1.5 库项目的智能感知?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37551539/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com