当我在类库中运行Entitfy框架核心命令 add-migration MyMigrationName 时,出现以下错误
When I run the Entitfy framework core command add-migration MyMigrationName in a class library I get the following error
无法加载文件或程序集'Microsoft.AspNetCore.Hosting.Abstractions,版本= 1.1.1.0,文化=中性,PublicKeyToken = adb9793829ddae60'或其中之一依赖关系.找到的程序集的清单定义不匹配程序集参考.(来自HRESULT的异常:0x80131040)
Could not load file or assembly 'Microsoft.AspNetCore.Hosting.Abstractions, Version=1.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
有趣的是,我的应用程序中没有引用抽象.
Funny thing there is no reference in my application to Abstractions.
这是我的csproj
Here is my csproj
<Project Sdk="Microsoft.NET.Sdk"> <PropertyGroup Label="Globals"> <SccProjectName>SAK</SccProjectName> <SccProvider>SAK</SccProvider> <SccAuxPath>SAK</SccAuxPath> <SccLocalPath>SAK</SccLocalPath> </PropertyGroup> <PropertyGroup> <TargetFramework>net452</TargetFramework> <AssemblyName>MyProjectName</AssemblyName> <OutputType>Library</OutputType> <PackageId>MyProjectName</PackageId> <NetStandardImplicitPackageVersion>1.6.0</NetStandardImplicitPackageVersion> <GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute> <GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute> <GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute> <RootNamespace>MyProjectName</RootNamespace> </PropertyGroup> <ItemGroup> <None Update="appsettings.json"> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> </None> </ItemGroup> <ItemGroup> <PackageReference Include="DocumentFormat.OpenXml" Version="2.5.0" /> <PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="1.1.2" /> <PackageReference Include="Microsoft.CSharp" Version="4.3.0" /> <PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="1.1.2" /> <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="1.1.2" /> <PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="1.1.1" /> <PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="1.1.2" /> <PackageReference Include="System.Collections" Version="4.3.0" /> <PackageReference Include="System.Linq" Version="4.3.0" /> <PackageReference Include="System.Runtime" Version="4.3.0" /> <PackageReference Include="System.Threading" Version="4.3.0" /> </ItemGroup> <ItemGroup Condition=" '$(TargetFramework)' == 'net452' "> <Reference Include="System" /> <Reference Include="Microsoft.CSharp" /> </ItemGroup> <ItemGroup> <DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="1.0.0" /> </ItemGroup> </Project> 推荐答案为了使NuGet将适当的绑定重定向添加到类库项目,您需要在 *.csproj 文件.
In order to get NuGet to add the appropriate binding redirects to class library projects, you need to add the following to your *.csproj file.
<PropertyGroup> <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects> <GenerateBindingRedirectsOutputType>true</GenerateBindingRedirectsOutputType> </PropertyGroup>更多推荐
Microsoft.AspNetCore.Hosting.Abstractions清单定义与程序集引用不匹配
发布评论