我已安装Automapper并AutoMapper.Extensions.Microsoft.DependencyInjection进入我的项目.我已将该行添加到ConfigureServices了Startup.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都添加了我读过的自动提示指南,以这种方式实现.
我不知道为什么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:\Users\myself\.nuget\packages,现在我的所有.NET Core项目都抱怨System或者Void找不到任何原始类型。尝试了以下
现在我该怎么做?