相关疑难解决方法(0)

尝试将AutoMapper添加到.NetCore1.1 - 无法识别services.AddAutoMapper()

我已安装AutomapperAutoMapper.Extensions.Microsoft.DependencyInjection进入我的项目.我已将该行添加到ConfigureServicesStartup.cs.

public void ConfigureServices(IServiceCollection services)
{
    // Add framework services.
    services.AddMvc();
    // . . .
    services.AddAutoMapper();
}
Run Code Online (Sandbox Code Playgroud)

我还是得到一条红线services.AddAutoMapper().它说:

以下方法或属性之间的调用是不明确的:ServiceCollectionExtensions.AddAutoMapper(IServiceCollection,params Assembly [])和ServiceCollectionExtensions.AddAutoMapper(IServiceCollection,params Type [])

为什么会这样?所有的.NET Core都添加了我读过的自动提示指南,以这种方式实现.

.net automapper asp.net-core-mvc .net-core asp.net-core

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

“ IServiceCollection”不包含“ AddSpaStaticFiles”的定义

我不知道为什么Startup.cs引发此错误。我尝试了这里建议的解决方案(包括重新启动计算机和运行dotnet restore),但没有运气。有任何想法吗?

CS1061'IServiceCollection'不包含'AddSpaStaticFiles'的定义,并且找不到可以接受的扩展方法'AddSpaStaticFiles'接受类型为'IServiceCollection'的第一个参数(是否缺少using指令或程序集引用?)

在此处输入图片说明

在startup.cs顶部使用语句:

using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Myproject.Models;

using Microsoft.EntityFrameworkCore;
using Microsoft.AspNetCore.Identity;
using Microsoft.AspNetCore.Authentication.JwtBearer;
using Microsoft.IdentityModel.Tokens;
using System.Text;
//Install-Package Microsoft.AspNetCore.Session
//Install-Package AutoMapper.Extensions.Microsoft.DependencyInjection
Run Code Online (Sandbox Code Playgroud)

我的.csproj文件包含:

  <ItemGroup>
    <PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="5.0.1" />
    <PackageReference Include="Microsoft.AspNetCore.Session" Version="2.1.1" />
    <PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="5.2.4" />
    <PackageReference Include="Flurl.Http" Version="2.2.1" />
    <PackageReference Include="jQuery" Version="3.3.1" />
    <PackageReference Include="jQuery.Validation" Version="1.17.0" />
    <PackageReference Include="LeanKit.API.Client" Version="1.2.6" />
    <PackageReference Include="Newtonsoft.Json" Version="11.0.2" />

    <PackageReference Include="Microsoft.AspNetCore.All" Version="2.0.5" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="2.0.2" />
    <PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="2.0.2" />
  </ItemGroup>

  <ItemGroup>
    <DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" …
Run Code Online (Sandbox Code Playgroud)

c# asp.net

4
推荐指数
1
解决办法
2952
查看次数

删除了我本地软件包缓存中的所有Nuget软件包,现在我根本无法使用VS

我删除了里面的所有文件和文件夹C:\Users\myself\.nuget\packages,现在我的所有.NET Core项目都抱怨System或者Void找不到任何原始类型。尝试了以下

  • Nuget.exe-还原c:\ path \ to \ myslnfile.sln -PackageDirectory C:\ Users \ myself \ .nuget \ packages
  • 建立解决方案
  • 创建一个新项目(新项目抱怨同样的事情)

现在我该怎么做?

.net-core visual-studio-2017

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