小编Lui*_*Flo的帖子

更新到ASP.NET Core 2.0 - 软件包与netcoreapp2.0不兼容

我正在尝试更新到.NET Core 2.0,但是我在使用该引用安装的所有软件包上都收到了这些错误

问题可能是:

我在输出中得到了netcoreapp1.0的引用

Microsoft.EntityFrameworkCore.Tools.DotNet 2.0.0软件包与netcoreapp1.0(.NETCoreApp,Version = v1.0)不兼容.Microsoft.EntityFrameworkCore.Tools.DotNet 2.0.0软件包支持:netcoreapp2.0(.NETCoreApp,Version = v2.0)一个或多个软件包与.NETCoreApp,Version = v1.0不兼容.检测到的包:Microsoft.ApplicationInsights.AspNetCore从2.1.1到2.0.0 Microsoft.AspNetCore.All(> = 2.0.0) - > Microsoft.AspNetCore.ApplicationInsights.HostingStartup(> = 2.0.0) - > Microsoft. ApplicationInsights.AspNetCore(> = 2.1.1)应用程序(> = 1.0.0) - > Microsoft.ApplicationInsights.AspNetCore(> = 2.0.0)

之后,我收到所有组件的消息:

Microsoft.AspNetCore.ANYPACKAGE 2.0.0软件包与netcoreapp2.0(.NETCoreApp,Version = v2.0)不兼容.Microsoft.AspNetCore.WebSockets 2.0.0软件包支持:netstandard2.0(.NETStandard,Version = v2.0)

这是手册:

https://docs.microsoft.com/en-us/aspnet/core/migration/1x-to-2x/

SDK已更新至2.0

在此输入图像描述

这是我的csproj

<Project Sdk="Microsoft.NET.Sdk.Web">

  <PropertyGroup>
    <TargetFramework>netcoreapp2.0</TargetFramework>
  </PropertyGroup>

  <PropertyGroup>
    <AssetTargetFallback>$(AssetTargetFallback);portable-net45+win8+wp8+wpa81;</AssetTargetFallback>
  </PropertyGroup>

  <ItemGroup>
    <Compile Remove="wwwroot\lib\kendo-ui-core\**" />
    <Content Remove="wwwroot\lib\kendo-ui-core\**" />
    <EmbeddedResource Remove="wwwroot\lib\kendo-ui-core\**" />
    <None Remove="wwwroot\lib\kendo-ui-core\**" />
  </ItemGroup>

  <ItemGroup>
    <Content Include="wwwroot\css\bootstrap-lumen.css" />
    <Content Include="wwwroot\css\bootstrap-sand.css" /> …
Run Code Online (Sandbox Code Playgroud)

.net asp.net asp.net-core

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

无法从ASP.NET Core 2.0中的IdentityUser和IdentityRole继承

我正在尝试更新到.NET Core 2.0,但会弹出几个错误:

问题:

我有两个类,ApplicationRole和ApplicationUser,它继承IdentityRole和IdentityUser的一些属性.

随着Core 2.0的更新,我收到以下错误,声称无法找到IdentityRole和IdentityUser.

但是,该软件包Microsoft.AspNetCore.Identity.EntityFrameworkCore 2.0安装在新版本的.NET Core中

关于IdentityRole:

消息1:

找不到类型或命名空间名称'IdentityRole'(是否缺少using指令或程序集引用?)

消息2:

'Application.Models.ApplicationRole'类型不能用作泛型类型或方法'IdentityDbContext'中'TRole'类型的参数.没有从"Application.Models.ApplicationRole"到"Microsoft.AspNetCore.Identity.IdentityRole"的隐式引用转换.

ApplicationRole的定义:

public class ApplicationRole:IdentityRole
{
    public string Description { get; set; }
    public DateTime CreatedDated { get; set; }
    public string IPAddress { get; set; }
}
Run Code Online (Sandbox Code Playgroud)

关于IdentityUser:

消息1:

找不到类型或命名空间名称'IdentityUser'(是否缺少using指令或程序集引用?)

消息2:

'Application.Models.ApplicationUser'类型不能用作泛型类型或方法'IdentityDbContext'中'TUser'类型的参数.没有从"Application.Models.ApplicationUser"到"M​​icrosoft.AspNetCore.Identity.IdentityUser"的隐式引用转换.

ApplicationUser的定义

public class ApplicationUser:IdentityUser
{
    public string Name { get; set; }
}
Run Code Online (Sandbox Code Playgroud)

下面的指南定义了这些类及其用法如下:

http://www.c-sharpcorner.com/article/asp-net-core-mvc-authentication-and-role-based-authorization-with-asp-net-core/

随着Core 2.0的改变,我想知道IdentityRole和IdentityUser是如何改变的,所以我不能再继承它们了.

.net c# asp.net

14
推荐指数
3
解决办法
9255
查看次数

软件包与netcoreapp2.0不兼容

今天这个错误再次出现了.Visual Studio无法识别Microsoft.AspNetCore.All中的大多数软件包,但我也遇到了以下问题:

  • Microsoft.Extensions.Logging.Debug
  • Microsoft.VisualStudio.Web.CodeGenerators.Mvc
  • Microsoft.EntityFrameworkCore.Tools.DotNet

每个包的错误信息都是这样的:

Microsoft.VisualStudio.Web.CodeGenerators.Mvc 2.0.0软件包与netcoreapp2.0(.NETCoreApp,Version = v2.0)不兼容.Microsoft.VisualStudio.Web.CodeGenerators.Mvc 2.0.0软件包支持:netstandard2.0(.NETStandard,Version = v2.0)

在执行以下操作之前,我已通过此问题:

  • 将VS更新到15.3.1版
  • 将SDK更新到2.0版

现在,我已将NuGet.Commandline更新为4.3,但问题仍然存在.

我也得到这个警报:

无法解决"System.Collections.NonGeneric,Version = 4.1.0.0,Culture = neutral,PublicKeyToken = b03f5f7f11d50a3a"和"System.Collections.NonGeneric,Version = 4.0.1.0,Culture = neutral,PublicKeyToken =之间的冲突b03f5f7f11d50a3a"."System.Collections.NonGeneric,Version = 4.1.0.0,Culture = neutral,PublicKeyToken = b03f5f7f11d50a3a"将被任意选择.应用程序D:\ Visual Studio\MSBuild\15.0\Bin\Microsoft.Common.CurrentVersion.targets 1964

我会研究其他任何更新?欢迎任何帮助.谢谢

.net c# visual-studio

9
推荐指数
2
解决办法
7174
查看次数

Visual Studio 2017 - 找不到AssemblyInfo.cs

今天,构建我的解决方案,这个问题出现了:

[错误]找不到文件'...\Projects\Application\Application\obj\Release \netcoreapp2.0\Application.AssemblyInfo.cs'.

我找到了其他版本Visual Studio的解决方案,但2017年没有

有关如何重新生成的任何建议?

亲切的问候

c# visual-studio-2017

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

Azure上的架构更新:列名称不存在

我有两个数据库,一个在本地,同一个数据库,但在Azure上发布.

对于本地数据库,我做了一些改动:添加一对多关系就是其中之一.模型涉及的是DeviceDigitalSystem

public class Device
{
    [Key]
    public int DeviceID { get; set; }
    //FK
    public int DigitalSystemID { get; set; }

    [ForeignKey("DigitalSystemID")]
    public DigitalSystem DigitalSystems { get; set; }
}

public class DigitalSystem
{
    [Key]
    public int DigitalSystemID { get; set; }

    public virtual ICollection<Device> Devices { get; set; }
} 
Run Code Online (Sandbox Code Playgroud)

这样,本地数据库中的表就会更新并包含该DigitalSystemID字段.

在此输入图像描述

但是,当我生成脚本并尝试部署架构时,会出现此错误:

错误信息:

在此输入图像描述

题:

我不明白这个错误,因为我相信列是声明的.有人能帮我理解吗?如何在Azure上将此架构更新部署到我的数据库?

提前致谢.

更新:

这是DeviceAzure上表的结构.

在此输入图像描述

它没有DigitalSystemID列,但这是我想要实现的,将Azure同步到localDB.这不是通过更新架构来完成的吗?

当我尝试部署架构时,这是'数据迁移助手'的结果[注意5错误(一个是我在这里描述的那个)]:

在此输入图像描述

通过Visual Studio进行架构比较:

我试图比较模式以检测差异.然而,比较结果表明没有差异,这没有任何意义: …

azure asp.net-core-mvc

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

ASP.NET自定义模型绑定:DateTime

问题

此时,我有一个问题,其中我的Get操作试图读取发送的不同格式的DateTime参数。

虽然发送的DateTime具有以下格式:0:dd/MM/yyyy Get Actions期望:0:MM/dd/yyyy

解决方法(也许)

为了更改Get操作所期望的,我使用了自定义模型绑定。

GET动作

    public async Task<IActionResult> Details(int? id, [ModelBinder(typeof(PModelBinder))]DateTime date)
Run Code Online (Sandbox Code Playgroud)

ModelBinder类

现在这里缺少一些东西,我不知道如何正确完成它:

public class PModelBinder : IModelBinder
{
    public Task BindModelAsync(ModelBindingContext bindingContext)
    {
        string theDate = bindingContext.HttpContext.Request.QueryString["date"]; 
        //What should I write inside the []? 
        //I've tried QueryString["date"] which is the name of the parameter but it says is wrong
        DateTime dt = new DateTime();
        bool success = DateTime.TryParse(date); //Should I apply ParseExact? How should I do it?
        if (success)
        {
            return new //what …
Run Code Online (Sandbox Code Playgroud)

c# datetime asp.net-core-mvc

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

为 DropdownList 使用枚举:缺少 using 指令或程序集引用

我正在尝试在 ASP.NET Core 中创建一个带有枚举属性的下拉列表。

这是模型(视图模型):

namespace Application.Models.ApplicationviewModels
{
    public class StoreIndexData
    {
        [Display(Name = "Departamento")]
        public int DepartmentID { get; set; }
        public string DepartmentName { get; set; }    

        [Display(Name = "Distrito")]    
        public int DistrictID { get; set; }
        public string DistrictName { get; set; }
        [EnumDataType(typeof(tiendacadenaenum))]
        public tiendacadenaenum tienda_cadena {get;set;}
    }
    public enum tiendacadenaenum
        {
        [Display(Name = "Cencosud")]
        Cencosud,
        [Display(Name = "Cinerama")]
        Cinerama,
    }
}
Run Code Online (Sandbox Code Playgroud)

这是视图的一部分:

@model Application.Models.ApplicationviewModels.StoreIndexData
@using Application.Models

    <div class="form-group">
        <label asp-for="tienda_cadena" class="cold-md-2"></label>
        <div class="col-md-10">
            <select asp-for="tienda_cadena" …
Run Code Online (Sandbox Code Playgroud)

c# enums asp.net-core-mvc asp.net-core

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