Microsoft.AspNetCore.Hosting.Abstractions清单定义与程序集引用不匹配

编程入门 行业动态 更新时间:2024-10-23 10:30:50
本文介绍了Microsoft.AspNetCore.Hosting.Abstractions清单定义与程序集引用不匹配的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

当我在类库中运行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清单定义与程序集引用不匹配

本文发布于:2023-11-03 16:13:50,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1555544.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:清单   不匹配   定义   程序   AspNetCore

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!