[英]Could not load file or assembly
I've recently updated to the latest .net core 3.0 SDK, updated all my nugets to also include pre-release versions, however I keep getting this error come up when I try to do anything with Pomeolo / Entity Framework with MySQL.我最近更新到最新的 .net 核心 3.0 SDK,更新了我所有的 nugets 以还包括预发布版本,但是当我尝试使用 Pomeolo / Entity Framework4DC6737AZ4AFA4716732A014AFA471 做任何事情时,我不断收到这个错误。
System.IO.FileLoadException: Could not load file or assembly 'Microsoft.Extensions.Configuration.Abstractions, Version=2.2.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'. An operation is not legal in the current state. (0x80131509)
File name: 'Microsoft.Extensions.Configuration.Abstractions, Version=2.2.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'
---> System.InvalidOperationException: AssemblyLoadContext is unloading or was already unloaded.
at System.Runtime.Loader.AssemblyLoadContext.VerifyIsAlive()
at System.Runtime.Loader.AssemblyLoadContext.LoadFromAssemblyPath(String assemblyPath)
at AltV.Net.Host.ResourceAssemblyLoadContext.Load(AssemblyName assemblyName)
at System.Runtime.Loader.AssemblyLoadContext.ResolveUsingLoad(AssemblyName assemblyName)
at System.Runtime.Loader.AssemblyLoadContext.Resolve(IntPtr gchManagedAssemblyLoadContext, AssemblyName assemblyName)
at Microsoft.EntityFrameworkCore.Storage.Internal.NamedConnectionStringResolverBase.ResolveConnectionString(String connectionString)
at Microsoft.EntityFrameworkCore.Storage.RelationalConnection..ctor(RelationalConnectionDependencies dependencies)
--- End of stack trace from previous location where exception was thrown ---
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitConstructor(ConstructorCallSite constructorCallSite, ServiceProviderEngineScope scope)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitScoped(ScopedCallSite scopedCallSite, ServiceProviderEngineScope scope)
at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetService[T](IServiceProvider provider)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitScoped(ScopedCallSite scopedCallSite, ServiceProviderEngineScope scope)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitConstructor(ConstructorCallSite constructorCallSite, ServiceProviderEngineScope scope)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitScoped(ScopedCallSite scopedCallSite, ServiceProviderEngineScope scope)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitConstructor(ConstructorCallSite constructorCallSite, ServiceProviderEngineScope scope)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitScoped(ScopedCallSite scopedCallSite, ServiceProviderEngineScope scope)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitConstructor(ConstructorCallSite constructorCallSite, ServiceProviderEngineScope scope)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitScoped(ScopedCallSite scopedCallSite, ServiceProviderEngineScope scope)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitConstructor(ConstructorCallSite constructorCallSite, ServiceProviderEngineScope scope)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitScoped(ScopedCallSite scopedCallSite, ServiceProviderEngineScope scope)
at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService(IServiceProvider provider, Type serviceType)
at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetRequiredService[T](IServiceProvider provider)
at Microsoft.EntityFrameworkCore.DbContext.get_DbContextDependencies()
at Microsoft.EntityFrameworkCore.DbContext.get_InternalServiceProvider()
at Microsoft.EntityFrameworkCore.DbContext.get_DbContextDependencies()
at Microsoft.EntityFrameworkCore.DbContext.get_Model()
at Microsoft.EntityFrameworkCore.Internal.InternalDbSet`1.get_EntityType()
at Microsoft.EntityFrameworkCore.Internal.InternalDbSet`1.get_EntityQueryable()
at Microsoft.EntityFrameworkCore.Internal.InternalDbSet`1.System.Linq.IQueryable.get_Provider()
at System.Linq.Queryable.Where[TSource](IQueryable`1 source, Expression`1 predicate)
I have tried stable and pre-release versions, I have this file also included in Nuget and it's version is 2.2.0.0.我已经尝试过稳定版本和预发布版本,这个文件也包含在 Nuget 中,它的版本是 2.2.0.0。 This seems to be an issue with.Net Core 3.0 or Pomelo?
这似乎是.Net Core 3.0 或 Pomelo 的问题?
My code:我的代码:
try
{
Console.WriteLine("Before Context");
using Context context = new Context();
Console.WriteLine("After Context");
List<Models.Vehicle> vehicles = context.Vehicle.Where(x => x.Spawned).ToList();
Console.WriteLine($"Resetting {vehicles.Count} Vehicle Spawn Status");
foreach (Models.Vehicle vehicle in vehicles)
{
vehicle.Spawned = false;
context.SaveChanges();
}
Console.WriteLine("Completed resetting vehicle spawn statuses");
context.Dispose();
}
catch (Exception e)
{
Console.WriteLine(e);
throw;
}
I am getting to this line:我到了这条线:
Console.WriteLine("After Context");
You must use exactly the same .NET Core, ASP.NET Core, and EF Core preview version.您必须使用完全相同的 .NET Core、ASP.NET Core 和 EF Core 预览版。 Make sure all packages from dotnet or aspnet are
rc1
as for now.确保来自dotnet或aspnet的所有包现在都是
rc1
。 If some dependencies (including direct and indirect) in your project depend on any 2.2 packages that are from dotnet or aspnet and has a 3.0 new version, reference them as 3.0 rc1 version from your own project explicitly.如果您的项目中的某些依赖项(包括直接和间接)依赖于来自dotnet或aspnet并且具有 3.0 新版本的任何 2.2 包,请将它们明确引用为您自己项目中的 3.0 rc1 版本。
You must wait for a .NET Core 3 compatible version of the Pomelo provider.您必须等待 Pomelo 提供程序的 .NET Core 3 兼容版本。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.