C# ';中System.MethodAccessException出错;Microsoft.Extensions.Logging.Configuration.LoggerProvider

C# ';中System.MethodAccessException出错;Microsoft.Extensions.Logging.Configuration.LoggerProvider,c#,asp.net,asp.net-mvc,C#,Asp.net,Asp.net Mvc,我使用VisualStudio创建了一个新的web项目,它是.NETFramework 4.8中.NETCore2.2下的MVC 当我使用nuget获取Microsoft.EntityFrameworkCore.SqlServer时 并开始运行(调试),我得到以下异常 System.MethodAccessException: 'Attempt by method 'Microsoft.Extensions.Logging.Configuration.LoggerProviderConfigur

我使用VisualStudio创建了一个新的web项目,它是.NETFramework 4.8中.NETCore2.2下的MVC

当我使用nuget获取Microsoft.EntityFrameworkCore.SqlServer时 并开始运行(调试),我得到以下异常

System.MethodAccessException: 'Attempt by method 'Microsoft.Extensions.Logging.Configuration.LoggerProviderConfigurationFactory.GetConfiguration(System.Type)' 
to access method 'Microsoft.Extensions.Logging.ProviderAliasUtilities.GetAlias(System.Type)' failed.'
我的项目属性仅此而已

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

  <PropertyGroup>
    <TargetFramework>net48</TargetFramework>
    <DebugType>full</DebugType>
  </PropertyGroup>


  <ItemGroup>
    <PackageReference Include="Microsoft.AspNetCore" Version="2.2.0" />
    <PackageReference Include="Microsoft.AspNetCore.CookiePolicy" Version="2.2.8" />
    <PackageReference Include="Microsoft.AspNetCore.Mvc" Version="2.2.0" />
    <PackageReference Include="Microsoft.AspNetCore.StaticFiles" Version="2.2.0" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="3.1.0" />
    <PackageReference Include="Serilog.AspNetCore" Version="3.2.0" />
    <PackageReference Include="Serilog.Settings.Configuration" Version="3.1.0" />
    <PackageReference Include="Serilog.Sinks.File" Version="4.1.0" />
  </ItemGroup>
</Project>

网络48
满的
你能帮我解决这个问题吗?
谢谢

该解决方案正在下载Microsoft.Extensions软件包并更新版本,以便与之等效。 以下是主要答案和讨论:

我怀疑问题是由于不匹配的软件包版本造成的。你会 当然需要将所有EntityFrameworkCore包更新为相同的版本 版本我希望您还需要使用最新的3.1 Microsoft.Extensions软件包的版本,自EF软件包 取决于这些软件包的3.1版本


您好,我尝试添加到我的项目中,但它仍然有问题:(有什么建议吗?我是通过nuget解决方案来做的。)