小编Rom*_*syk的帖子

找不到匹配命令"dotnet-watch"的可执行文件

尝试使用dotnet watch但得到错误:

找不到匹配命令"dotnet-watch"的可执行文件

dotnet --version
1.0.0-rc4-0004834
Run Code Online (Sandbox Code Playgroud)

安装了.NET Core 1.1 SDK和.NET Core 1.1运行时

我的.csproj档案:

 <ItemGroup>
    <PackageReference Include="Microsoft.AspNetCore" Version="1.0.3" />
    <PackageReference Include="Microsoft.DotNet.Cli.Utils" Version="1.0.0-rc4-004771" />
    <PackageReference Include="Microsoft.Extensions.CommandLineUtils" Version="1.1.0" />
    <PackageReference Include="Microsoft.Extensions.Logging" Version="1.1.0" />
    <PackageReference Include="Microsoft.Extensions.Logging.Console" Version="1.1.0" />
    <PackageReference Include="Microsoft.NETCore.App" Version="1.1.0" />
    <PackageReference Include="Microsoft.DotNet.Watcher.Tools" Version="1.1.0-preview4-final" />
  </ItemGroup>
Run Code Online (Sandbox Code Playgroud)

dotnet restore 已经完成了

我怎么解决这个问题?

.net-core asp.net-core

9
推荐指数
1
解决办法
5027
查看次数

如何使用mysql中的select语句调用存储过程

我有电话声明

 CALL report_procedure
('2013-02-01',now(),'2015-01-01','1');
Run Code Online (Sandbox Code Playgroud)

我想在选择查询中使用它.我试过像

Select * from ( CALL report_procedure
    ('2013-02-01',now(),'2015-01-01','1'));
Run Code Online (Sandbox Code Playgroud)

但是发生错误.喜欢

错误代码:1064.您的SQL语法有错误; 查看与您的MySQL服务器版本对应的手册,以获得正确的语法(CALL report_procedure('2013-02-01',now(),'2015-01-01','1')在第3行0.297秒

任何人都可以建议我在mysql中的Select语句中调用存储过程的方法吗?

mysql select stored-procedures

8
推荐指数
1
解决办法
2万
查看次数

SingleResult和UnitTesting

BaseApiController班上有以下方法:

public virtual HttpResponseMessage GetById(int id)
{
   var entity = repository.GetById(id);

   if (entity == null)
   {                
     var message = string.Format("No {0} with ID = {1}", GenericTypeName, id);
     return ErrorMsg(HttpStatusCode.NotFound, message);
   }

   return Request.CreateResponse(HttpStatusCode.OK, SingleResult.Create(repository.Table.Where(t => t.ID == id)));
}
Run Code Online (Sandbox Code Playgroud)

我正在使用SingleResultOData请求(因为$expand如果我不创建SingleResult,单个实体不起作用).
但是现在我在具体控制器(例如AddressApiController)上遇到了这个方法的UnitTests问题.我总是得到NULL结果:

[TestMethod]
public void Get_By_Id()
{
    //Arrange
    var moq = CreateMockRepository();
    var controller = new AddressApiController(moq);
    controller.Request = new HttpRequestMessage()
    controller.Request.SetConfiguration(new HttpConfiguration())
    // Action
    HttpResponseMessage response = controller.GetById(1);
    var result = response.Content.ReadAsAsync<T>().Result; …
Run Code Online (Sandbox Code Playgroud)

c# asp.net-mvc asp.net-web-api

8
推荐指数
1
解决办法
848
查看次数

DI容器2层

我正在尝试使用像Ninject这样的IoC来设计WebApi应用程序.我有以下几层(3个项目):

  • 域(存储库)层
  • 服务
  • Web API应用程序核心

Repository层具有接口IRepository<T>和一些实现.并且在Service中还存在IService<T>具有两种不同实现的接口.

如果我在WebApi项目中使用DI容器(Ninject)绑定IService<T>ServiceConcrete<T>服务项目中的DI容器来绑定IRepository<T>RepositoryConcrete<T>?,请指教我吗?

或者我应该在WebAppi项目中只使用一个DI?

c# architecture dependency-injection asp.net-web-api

8
推荐指数
1
解决办法
629
查看次数

Visual Studio 2015 Update 2的Service Fabric工具似乎已被破坏

我已经安装了SF SDK 2.1.150(VS2015),克隆了https://github.com/Azure-Samples/service-fabric-dotnet-getting-started并在以管理员身份运行的Visual Studio 2015 Update 2中打开.我无法选择WordCount应用程序作为启动项目:

在此输入图像描述

尝试从"Service Fabric应用程序"模板创建新项目,在"新建项目"对话框中单击"确定"后,我收到错误消息:

预计1个出口的合同名称为"Microsoft.VisualStudio.Azure.Fabric.Shared.IShellService",但在应用适用的约束后找到0.

我尝试使用控制面板"程序"修复SDK组件"Microsoft Azure Service Fabric 5.1.150.9590","Microsoft Azure Service Fabric SDK 2.1.150.9590"和"Microsoft Azure Service Fabric for Visual Studio 2015 1.1.40531.2"和功能"小程序.我已经卸载并重新安装了SDK,重启机器无济于事.

请问有什么想法吗?

visual-studio-2015 azure-service-fabric

8
推荐指数
1
解决办法
1441
查看次数

将数组作为命令行参数传递给 Asp.Net Core

需要将数组作为命令行参数传递给 Asp.Net Core 托管服务。

添加的提供者

config
  .AddJsonFile("appsettings.json")
  .AddCommandLine(args);
Run Code Online (Sandbox Code Playgroud)

我在应用程序的某个地方

var actions = _configuration.GetSection("actions").Get<List<string>>();
foreach (var action in actions)
{
   Console.WriteLine(action);
}
Run Code Online (Sandbox Code Playgroud)

尝试运行应用程序

dotnet MyService.dll --actions Action1,Action2
dotnet MyService.dll --actions [Action1,Action2]
dotnet MyService.dll --actions ["Action1","Action2"]
Run Code Online (Sandbox Code Playgroud)

但没有结果,actions就是null

当我添加"actions": ["Action1","Action2"]到 appsettings.json 时,绑定效果很好。

如何将数组作为命令行参数传递?

我可以通过这种方式获得它_configuration.GetValue<string>("actions").Split(",");,但是如何将其绑定到列表?

c# command-line-arguments .net-core asp.net-core

8
推荐指数
1
解决办法
1659
查看次数

使用HttpResponse.Redirect重定向到新的URL C#MVC

我正在努力解决这个问题HttpResponse.Redirect.我以为它会包括在内System.Web但我得到了

"响应"名称在当前上下文中不存在"错误.

这是整个控制器:

using System.Net;
using System.Net.Http;
using System.Text;
using System.Web;
using System.Web.Http;

namespace MvcApplication1.Controllers
{
    public class SmileyController : ApiController
    {
        public HttpResponseMessage Get(string id)
        {
            Response.Redirect("http://www.google.com");
            return new HttpResponseMessage
            {
                Content = new StringContent("[]", new UTF8Encoding(), "application/json"),
                StatusCode = HttpStatusCode.NotFound,
            };
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

c# asp.net-mvc

7
推荐指数
1
解决办法
3万
查看次数

为什么新的ASP.NET Identity表停止使用Guid(uniqueidentifier类型)作为键?

我试图理解为什么新的ASP.NET身份表停止使用Guid(uniqueidentifier类型)作为键 - 相反它现在正在使用nvarchar(128)但仍保持Guid一个string...

这不是一个巨大的浪费吗?(uniqueidentifier只有2 integers对整体Guid作为36个字符string)

我怀疑实体框架可能对此负责......

更改为uniqueidentifier键是否安全?

谁能告诉我使用36个字符串有什么好处?

asp.net entity-framework entity-framework-6 asp.net-identity

7
推荐指数
1
解决办法
1478
查看次数

无法使用X509Certificate2找到指定的对象

我正在尝试加载包含要访问的密钥的文件Google Calendar API.遵循本教程. 为此,我创建了这段代码:

var certificate = new X509Certificate2("client_secret.json", "notasecret", X509KeyStorageFlags.Exportable);
Run Code Online (Sandbox Code Playgroud)

client_secret.json在我的解决方案中上传了文件,这是文件的路径:"...\Visual Studio 2015\Projects\Calendar\Calendar\bin\Debug\client_secret.json"

但似乎代码无法找到该文件并返回此错误:

无法使用X509Certificate2找到指定的对象

我还在文件Always copy上设置了Copy in the output directory要读取的属性.

c# x509certificate2

7
推荐指数
1
解决办法
1705
查看次数

从 PostMan 调用 asp.net core web api

我正在尝试从 PostMan 调用以下函数(asp.net web api core):

[HttpPost]
public InfluencerSearchResultWithFacets Post(string q, string group, List<string> subGroups)
{
   return GetSearchResult("",null,null);
}
Run Code Online (Sandbox Code Playgroud)

但我收到以下错误:需要一个非空的请求正文

我已经像这样设置了 PostMan: 在此处输入图片说明

在此处输入图片说明

我也尝试添加到正文: 在此处输入图片说明

c# asp.net-web-api postman

7
推荐指数
1
解决办法
1万
查看次数