我在将Web项目从RC1迁移到RC2时遇到了一些麻烦.当我切换时,我在整个项目中遇到了一堆这些错误.
类型'Func <,>'在未引用的程序集中定义.您必须添加对程序集'mscorlib,Version = 4.0.0.0,Culture = neutral,PublicKeyToken = b77a5c561934e089'的引用
看起来所有的linq函数和lambda表达式都不起作用.
这是我的project.json文件的样子:
"frameworks": {
"netcoreapp1.0": {
"dependencies": {
"System.Linq": "4.1.0-rc2-24027"
},
"imports": [ "net451", "portable-net45+win8" ]
}
},
"dependencies": {
"NETStandard.Library": "1.5.0-rc2-24027",
"Microsoft.EntityFrameworkCore": "1.0.0-rc2-final",
"Microsoft.EntityFrameworkCore.SqlServer": "1.0.0-rc2-final",
"System.ComponentModel.Annotations": "4.1.0-*"
}
Run Code Online (Sandbox Code Playgroud)
这意味着什么?我试过跑步dotnet restore,没有帮助.
我想试试新的.net核心.我正在关注https://www.microsoft.com/net/core上的指示,但它无法正常工作.
Reading package lists... Done
Building dependency tree
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:
The following packages have unmet dependencies:
dotnet-dev-1.0.0-preview1-002702 : Depends: dotnet-sharedframework-microsoft.netcore.app-1.0.0-rc2-3002702 but it is not going to be installed …Run Code Online (Sandbox Code Playgroud) 我在.NET Core项目中有一个大型测试套件.我可以使用Test Explorer窗口选择要运行的几个测试.
我也可以在命令行上运行整个测试套件dotnet test.有没有办法在命令行上只运行一个(或几个)测试?
我正在构建ASP.NET Core WebAPI,我正在尝试为控制器编写单元测试.我发现的大多数示例都来自较旧的WebAPI/WebAPI2平台,似乎与新的Core控制器无关.
我的控制器方法正在返回IActionResults.但是,该IActionResult对象只有一个ExecuteResultAsync()需要控制器上下文的方法.我手动实例化控制器,因此此实例中的控制器上下文为null,这会在调用时导致异常ExecuteResultAsync.从本质上讲,这是让我走上一条非常黑客的道路,让这些单元测试成功完成并且非常混乱.我想知道必须有一种更简单/更正确的API控制器测试方法.
此外,如果有所不同,我的控制器不使用async/await.
我想要实现的简单例子:
控制器方法:
[HttpGet(Name = "GetOrdersRoute")]
public IActionResult GetOrders([FromQuery]int page = 0)
{
try
{
var query = _repository.GetAll().ToList();
int totalCount = query.Count;
int totalPages = (int)Math.Ceiling((double)totalCount / pageSize) - 1;
var orders = query.Skip(pageSize * page).Take(pageSize);
return Ok(new
{
TotalCount = totalCount,
TotalPages = totalPages,
Orders = orders
});
}
catch (Exception ex)
{
return BadRequest(ex);
}
}
Run Code Online (Sandbox Code Playgroud)
单元测试:
[Fact]
public void GetOrders_WithOrdersInRepo_ReturnsOk()
{
// arrange
var …Run Code Online (Sandbox Code Playgroud) 好吧,作为一个新的.net开发生态系统,我有点迷失在Core工具,版本等等.
什么是预览以及它们与主版本编号有何关联?
在dotnet核心github存储库中,我们可以看到各种版本中提供了一些工具:
1.0.3于2016年12月13日发布
1.1 2016年11月16日发布
1.1.0预览1发布于2016年10月24日
1.0.2发布于2016年10月17日
1.0.1发布于2016年9月13日
2016年6月27日发布的RC2发布2015年5月16日RC1发布2015年11月18日
在DOTNET CLI回购(?我也已了解大厦工具),我们可以看到他们在谈论preview4,但在下载链接,一切都标志着预览5. 与他们谈论下载.NET核心SDK安装程序:是那里的SDK核心安装程序,所以另一个版本,或者它命名错误,它实际上只是CLI?或者SDK是否包含CLI,那么哪个版本?
它为您提供了一个dotnet-win-x64.latest.exe,似乎安装了.NET Core 1.0.1 Preview 5 ...
最后在Azure上,Web应用程序控制台将为您提供:
dotnet --version
D:\home\site\wwwroot
1.0.0-preview3-004056
Run Code Online (Sandbox Code Playgroud)
什么是正确的工具,以什么正确的版本启动新项目并在Azure上正确部署?
既然ASP.NET Core随VS 2017一起发布(3月发布),它们将在VS 2015中支持ASP.NET Core多长时间?
我的意思是project.json将不再使用,那么我们是否需要将现有项目移至VS 2017并且不要使用VS 2015来使用ASP.NET Core.
我有一个开发人员正在"构建失败".在.NET Core EF项目中运行add-migration时,没有解释构建失败的原因.你如何解决这个错误?
其他信息:
我们有一些其他开发人员使用相同的解决方案代码(包括我自己),这些代码没有添加迁移的问题.
这是我在Package Manager Console中看到的:
我们已经验证了项目的构建,并构建了整个解决方案.除了重启VS2015之外,我们已经完成了"dotnet restore"并多次重建.我们已经验证在解决方案资源管理器和Package Manager控制台下拉列表中都选择了正确的默认解决方案.我们已经确认他的计算机上安装了正确的SDK.关于接下来要检查什么,我感到很遗憾......任何时候我在添加迁移过程中都遇到了故障我已经获得了足够的信息指向我要检查的方向,但只是"构建失败了. " 是一个相当无用的错误输出.
对于.NET Core,AsyncLocal它是替代品CallContext.但是,目前还不清楚在ASP.NET Core中使用它是多么"安全".
在ASP.NET 4(MVC 5)和更早版本中,ASP.NETCallContext的线程敏捷性模型变得不稳定.因此,在ASP.NET中,实现每请求逻辑上下文行为的唯一安全方法是使用HttpContext.Current.Items.在幕后,HttpContext.Current.Items实现了CallContext,但它以一种对ASP.NET安全的方式完成.
相反,在OWIN/Katana Web API的上下文中,线程敏捷性模型不是问题.在仔细考虑如何正确处理它之后,我能够安全地使用CallContext .
但现在我正在处理ASP.NET Core.我想使用以下中间件:
public class MultiTenancyMiddleware
{
private readonly RequestDelegate next;
static int random;
private static AsyncLocal<string> tenant = new AsyncLocal<string>();
//This is the new form of "CallContext".
public static AsyncLocal<string> Tenant
{
get { return tenant; }
private set { tenant = value; }
}
//This is the new verion of [ThreadStatic].
public static ThreadLocal<string> LocalTenant; …Run Code Online (Sandbox Code Playgroud) 我有一个Web API解决方案(针对.NET 4.6),其中包含几个相当轻量级的.NET Core项目.我已将.NET Core项目打包为NuGet包,并将它们安装到Web API项目中.
一切都很好,但运行时,我在应用程序初始化时得到以下异常.
Method System.Net.Http.CloneableExtensions.Clone: type argument 'System.Net.Http.Headers.MediaTypeHeaderValue' violates the constraint of type parameter 'T'.
[VerificationException: Method System.Net.Http.CloneableExtensions.Clone: type argument 'System.Net.Http.Headers.MediaTypeHeaderValue' violates the constraint of type parameter 'T'.]
System.Net.Http.Formatting.MediaTypeConstants.get_ApplicationJsonMediaType() +0
System.Net.Http.Formatting.JsonMediaTypeFormatter..ctor() +64
System.Net.Http.Formatting.MediaTypeFormatterCollection.CreateDefaultFormatters() +41
System.Web.Http.HttpConfiguration.DefaultFormatters(HttpConfiguration config) +26
System.Web.Http.HttpConfiguration..ctor(HttpRouteCollection routes) +214
System.Web.Http.GlobalConfiguration.<CreateConfiguration>b__0() +60
System.Lazy`1.CreateValue() +411
System.Lazy`1.LazyInitValue() +183
System.Lazy`1.get_Value() +75
System.Web.Http.GlobalConfiguration.get_Configuration() +27
Runpath.Platform.Web.DependencyResolution.StructureMapBootStrapper.Initialise() in C:\Code3\Runpath\Markets\Platform\Main - Copy\Runpath.Platform.Web\DependencyResolution\StructureMapBootStrapper.cs:15
Runpath.Platform.Web.WebApiApplication.Application_Start() in C:\Code3\Runpath\Markets\Platform\Main - Copy\Runpath.Platform.Web\Global.asax.cs:30
[HttpException (0x80004005): Method System.Net.Http.CloneableExtensions.Clone: type argument 'System.Net.Http.Headers.MediaTypeHeaderValue' violates the constraint of type parameter 'T'.]
System.Web.HttpApplicationFactory.EnsureAppStartCalledForIntegratedMode(HttpContext context, …Run Code Online (Sandbox Code Playgroud) 在实体框架工作核心中更新数据库表数据的最佳方法是什么?
我们可以在EF6上使用哪些改进功能?
.net-core ×10
asp.net-core ×6
c# ×4
.net ×3
linq ×1
ubuntu ×1
unit-testing ×1
xunit.net ×1
xunit2 ×1