【问题标题】:How to resolve error in net 6: Could not load type Microsoft.AspNetCore.Http.Internal.FormFile from assembly Microsoft.AspNetCore.Http Version=6.0.0.0 [duplicate]如何解决 net 6 中的错误:无法从程序集 Microsoft.AspNetCore.Http Version=6.0.0.0 加载类型 Microsoft.AspNetCore.Http.Internal.FormFile [重复]
【发布时间】:2023-01-01 19:00:18
【问题描述】:

运行项目时出现此错误:

System.TypeLoadException: 'Could not load type 'Microsoft.AspNetCore.Http.Internal.FormFile' from assembly 'Microsoft.AspNetCore.Http, Version=6.0.0.0

我使用点网 6.0

这些是我的依赖项:

<PropertyGroup>
    <TargetFramework>net6.0</TargetFramework>
    <ImplicitUsings>enable</ImplicitUsings>
    <Nullable>enable</Nullable>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Autofac" Version="6.4.0" />
    <PackageReference Include="Autofac.Extensions.DependencyInjection" Version="8.0.0" />
    <PackageReference Include="Autofac.Extras.CommonServiceLocator" Version="6.0.1" />
    <PackageReference Include="AutoMapper" Version="12.0.0" />
    <PackageReference Include="FluentValidation" Version="11.4.0" />
    <PackageReference Include="MediatR" Version="8.0.0" />
    <PackageReference Include="Microsoft.AspNetCore.Http" Version="2.2.0" />
    <PackageReference Include="Microsoft.AspNetCore.Http.Features" Version="2.2.0" />
    <PackageReference Include="RestSharp" Version="108.0.3" />
    <PackageReference Include="Serilog" Version="2.12.0" />
  </ItemGroup>

我不知道是什么问题!

我尝试了不同版本的“Microsoft.AspNetCore.Http”和“Microsoft.AspNetCore.Http.Features”包,但问题存在,我搜索解决方案,但没有帮助!

请某人帮助我!

谢谢你。

【问题讨论】:

    标签: c# .net-6.0 iformfile typeloadexception


    【解决方案1】:

    将 &lt;FrameworkReference&gt; 元素添加到您的项目文件中:target-aspnetcore

    <ItemGroup>
     <FrameworkReference Include="Microsoft.AspNetCore.App" />
     ...
    </ItemGroup>
    

    并检查项目的 .csproj。第一行应如下所示:

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

    要么:

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

    【讨论】:

      猜你喜欢
      • 2020-03-13
      • 2022-08-14
      • 2020-04-15
      • 1970-01-01
      • 2016-06-05
      • 2023-02-17
      • 2015-08-05
      • 2016-08-28
      • 1970-01-01
      相关资源
      最近更新 更多