小编max*_*pan的帖子

无法打开Visual Studio - 抛出错误'无法在安装过程中运行'

我试图打开Visual Studio,但它给出了一个错误:

设置正在进行时无法运行

在我重新启动机器之前运行正常.我已经安装了过去一年的这个版本.

截图

visual-studio

120
推荐指数
12
解决办法
5万
查看次数

如何每行显示三列?

我一直试图每行显示三列.是否可以使用flexbox?

我目前的CSS是这样的:

.mainDiv {
    display: flex;
    margin-left: 221px;
    margin-top: 43px;
}
Run Code Online (Sandbox Code Playgroud)

此代码将所有内容放在一行中.我想添加一个约束来显示每行三个记录.

html css html5 css3 flexbox

58
推荐指数
4
解决办法
12万
查看次数

使用Func委托与Async方法

我试图使用Func与异步方法.我收到了一个错误.

无法将异步lambda表达式转换为委托类型'Func<HttpResponseMesage>'.异步lambda表达式可能返回void,Task或者Task<T>都不能转换为'Func<HttpResponseMesage>'.

以下是我的代码:

public async Task<HttpResponseMessage> CallAsyncMethod()
{
    Console.WriteLine("Calling Youtube");
    HttpClient client = new HttpClient();
    var response = await client.GetAsync("https://www.youtube.com/watch?v=_OBlgSz8sSM");
    Console.WriteLine("Got Response from youtube");
    return response;
}

static void Main(string[] args)
{
    Program p = new Program();
    Task<HttpResponseMessage> myTask = p.CallAsyncMethod();
    Func<HttpResponseMessage> myFun =async () => await myTask;
    Console.ReadLine();
}
Run Code Online (Sandbox Code Playgroud)

c# lambda asynchronous

48
推荐指数
2
解决办法
5万
查看次数

获取范围使用asp.net核心中的JavaScript客户端验证Identity Server 4中的错误

从我的Javascript客户端应用程序向我的Identity Server应用程序发出请求时,我收到以下错误.

fail:IdentityServer4.Validation.ScopeValidator [0] 无效范围:openid

我已确保在Identity Server应用程序中添加范围.以下是我的代码.

IdentityServer应用程序(主机) Config.cs

  public class Config
{
    public static IEnumerable<ApiResource> GetApiResources()
    {
        return new List<ApiResource>
        {
            new ApiResource("api1","My API")
        };
    }

    public static IEnumerable<Client> GetClients()
    {
        return new List<Client>
        {
            new Client
            {
                 ClientId = "js",
                 ClientName = "javaScript Client",
                 AllowedGrantTypes = GrantTypes.Implicit,
                 AllowAccessTokensViaBrowser = true,
                 RedirectUris = { "http://localhost:5003/callback.html" },
                 PostLogoutRedirectUris = { "http://localhost:5003/index.html" },
                 AllowedCorsOrigins = { "http://localhost:5003" },
                 AllowedScopes =
                    {
                        IdentityServerConstants.StandardScopes.OpenId,
                        IdentityServerConstants.StandardScopes.Profile,
                        "api1"
                    }
            }
        };
    }
}
Run Code Online (Sandbox Code Playgroud)

Startup.cs

  public …
Run Code Online (Sandbox Code Playgroud)

c# oauth-2.0 openid-connect identityserver4 asp.net-core-webapi

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

在visual studiio 2017中的IServiceCollection中找不到AddMvc()

我创建了一个全新的asp,net core应用程序.我添加了mvc nuget包但我收到以下错误.

Microsoft.AspNetCore.Mvc.Core 1.1.3

'IServiceCollection'不包含'AddMvc'的定义,并且没有扩展方法'AddMvc'可以找到接受类型'IServiceCollection'的第一个参数(你是否缺少using指令或汇编引用?)

c# asp.net-core

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

无法将类型'System.Collections.Generic.List <>'隐式转换为'System.Threading.Tasks.Task <>>

我得到一个例外.

无法隐式转换'System.Collections.Generic.List<IntegraPay.Domain.SObjects.Industry>''System.Threading.Tasks.Task<System.Collections.Generic.IEnumerable<IntegraPay.Domain.SObjects.Industry>>'

以下是我的财产和方法.

  private List<WebFormFieldContent> WebFormFields { get; set; } = 
       new List<WebFormFieldContent>();

  Task<IEnumerable<WebFormFieldContent>> IRegistrationRepository.GetWebFormFields()
        {
            return WebFormFields;
        }
Run Code Online (Sandbox Code Playgroud)

c# async-await

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

从ASP.NET Core 2.0中的中间件获取请求正文在HttpContext中

我有一个简单的中间件,可获取请求的主体并将其存储在字符串中。它正在读取流,但问题是它不会调用我的控制器,而该控制器在我读取流并抛出错误后立即调用

需要一个非空的请求正文

。下面是我的代码。

  public async Task Invoke(HttpContext httpContext)
            {
                var timer = Stopwatch.StartNew();
                ReadBodyFromHttpContext(httpContext);
                await _next(httpContext);
                timer.Stop();
            }

   private string ReadBodyFromHttpContext(HttpContext httpContext)
        {
           return await new StreamReader(httpContext.Request.Body).ReadToEndAsync();
        }
Run Code Online (Sandbox Code Playgroud)

c# asp.net-core-2.0

6
推荐指数
3
解决办法
9772
查看次数

在实体框架核心中获取无效的列名“EmploymentTypeEntityEmploymentTypeID”

我收到以下错误。

消息:Microsoft.EntityFrameworkCore.DbUpdateException:更新条目时出错。有关详细信息,请参阅内部异常。----> System.Data.SqlClient.SqlException:无效的列名“EmploymentTypeEntityEmploymentTypeID”。

奇怪的是它结合了我的实体类名称和实体属性名称。

下面是我的代码。

系统测试文件

   using (var transaction = _referenceDataDbContext.Database.BeginTransaction())
            {
                _referenceDataDbContext.EmploymentType.AddRangeAsync(

                    new EmploymentTypeEntity
                    {
                        EmploymentTypeID = 1,
                        EmploymentType = "EmploymentType",
                        CategoryTypeID = 27,

                        SiteAddress = null,
                        CreatedBy = "UnitTest",
                        CreatedOn = DateTime.Now,
                        ModifiedBy = "UnitTest",
                        ModifiedOn = DateTime.Now,
                        RowVersion = new RowVersion(1),
                        EmploymentTypeGroups = new[]
                        {
                        new EmploymentTypeGroupEntity
                        {
                            EmploymentTypeGroupID = 11, GroupName = "Child Care", IsActive = true
                        }
                        }
                    }

                    }
                );

                _referenceDataDbContext.Database.ExecuteSqlCommand("SET IDENTITY_INSERT [ref].[EmploymentType] ON");

                _referenceDataDbContext.SaveChanges();
            }
Run Code Online (Sandbox Code Playgroud)

就业类型组.cs

  public class EmploymentTypeGroupEntity
    {
        [Key]
        public int? …
Run Code Online (Sandbox Code Playgroud)

c# entity-framework-core

6
推荐指数
1
解决办法
3880
查看次数

MVC 6 中下拉列表的 TagHelpers onchange 事件

我有一个下拉列表,我想将 Jquery onchange 事件绑定到 TagHelpers 选择标记。下面是我的代码。

 <select asp-for="BusinessType"
         asp-items="@Model.BusinessTypeCollection">
 </select>
Run Code Online (Sandbox Code Playgroud)

如何绑定标记的内联 onchange 事件。

像这样的东西。

 <select asp-for="BusinessType"
         asp-items="@Model.BusinessTypeCollection"
         onchange ="something">
 </select>
Run Code Online (Sandbox Code Playgroud)

c# asp.net-core-mvc

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

获取预期的顶级语句(例如“消息”)。同时将 proto 转换为 C#

我有一个名为 Person.proto 的简单原型文件,其中包含以下内容。我不明白我错过了什么。

syntax = "proto2";

message Person{
optional string name = 1;
}
Run Code Online (Sandbox Code Playgroud)

我正在使用的命令是

Protoc Person.proto --csharp_out=C:\Users\Owner\.nuget\packages\google.protocolbuffers\2.4.1.555\tools Person.cs
Run Code Online (Sandbox Code Playgroud)

人物.cs

public class Person
{

}
Run Code Online (Sandbox Code Playgroud)

c# protocol-buffers protobuf-net

5
推荐指数
1
解决办法
4265
查看次数