【问题标题】:Error loading assembly 'MySql.Data.MySqlClient' when deploying ASP.net application to AWS将 ASP.net 应用程序部署到 AWS 时加载程序集“MySql.Data.MySqlClient”时出错
【发布时间】:2017-09-26 22:33:00
【问题描述】:

当我将我的 Asp.NET 应用程序发布到 AWS Elastic Beanstalk 实例时,我收到以下异常消息。该数据库位于 Amazon RDS 上。该应用程序使用本地 MySql 数据库在本地运行良好。我在 Stack Overflow 上尝试了许多建议的答案,但没有一个被证明有效。有人在部署 .NET 应用程序时遇到过这个问题吗?

实体框架提供程序类型 'MySql.Data.MySqlClient.MySqlProviderServices,MySql.Data.Entity.EF6, 版本=6.9.9.0,文化=中性,PublicKeyToken=c5687fc88969c44d' 在 ADO.NET 提供程序的应用程序配置文件中注册 无法加载具有不变名称“MySql.Data.MySqlClient”。制作 确保使用了程序集限定名称并且程序集是 可用于正在运行的应用程序。看 http://go.microsoft.com/fwlink/?LinkId=260882 了解更多信息。 在 System.Data.Entity.Infrastructure.DependencyResolution.ProviderServicesFactory.GetInstance(字符串 providerTypeName, String providerInvariantName)

在 System.Data.Entity.Internal.AppConfig.<.ctor>b__2(ProviderElement e)

在 System.Linq.Enumerable.WhereSelectEnumerableIterator`2.MoveNext()

在 System.Collections.Generic.List`1..ctor(IEnumerable`1 集合)

在 System.Linq.Enumerable.ToList[TSource](IEnumerable`1 源)

在 System.Lazy`1.CreateValue()

在 System.Lazy`1.LazyInitValue()

在 System.Data.Entity.Infrastructure.DependencyResolution.AppConfigDependencyResolver.RegisterDbProviderServices()

在 System.Data.Entity.Infrastructure.DependencyResolution.AppConfigDependencyResolver.GetServiceFactory(类型 类型,字符串名称)

在 System.Collections.Concurrent.ConcurrentDictionary`2.GetOrAdd(TKey 键,Func`2 valueFactory)

在 System.Data.Entity.Infrastructure.DependencyResolution.AppConfigDependencyResolver.GetService(类型 类型,对象键)

在 System.Linq.Enumerable.WhereSelectArrayIterator`2.MoveNext()

在 System.Linq.Enumerable.FirstOrDefault[TSource](IEnumerable`1 来源,Func`2 谓词)

在 System.Data.Entity.Infrastructure.DependencyResolution.CompositeResolver`2.GetService(类型 类型,对象键)

在 System.Data.Entity.Infrastructure.DependencyResolution.DbDependencyResolverExtensions.GetService[T](IDbDependencyResolver 解析器)

在 System.Data.Entity.DbContext.InitializeLazyInternalContext(IInternalConnection internalConnection,DbCompiledModel 模型)

在 MichHerbAcumaticaApi.Models.ApplicationDbContext.Create()

在 Microsoft.AspNet.Identity.Owin.IdentityFactoryMiddleware`2.d__0.MoveNext() --- 从之前抛出异常的位置结束堆栈跟踪 ---

在 System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(任务 任务)

在 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务 任务)

在 Microsoft.Owin.Host.SystemWeb.IntegratedPipeline.IntegratedPipelineContextStage.d__5.MoveNext() --- 从之前抛出异常的位置结束堆栈跟踪 ---

在 System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(任务 任务)

在 System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(任务 任务)

在 Microsoft.Owin.Host.SystemWeb.IntegratedPipeline.IntegratedPipelineContext.d__2.MoveNext() --- 从先前抛出异常的位置结束堆栈跟踪 ---

在 Microsoft.Owin.Host.SystemWeb.IntegratedPipeline.StageAsyncResult.End(IAsyncResult ar)

在 System.Web.HttpApplication.AsyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()

在 System.Web.HttpApplication.ExecuteStep(IExecutionStep 步骤, Boolean & completedSynchronously)

<packages>
  ......
  <package id="MySql.Data" version="6.9.9" targetFramework="net452" />
  <package id="MySql.Data.Entity" version="6.9.9" targetFramework="net452" />
  <package id="MySql.Web" version="6.9.9" targetFramework="net452" />
  .....
</packages>

我尝试了以下解决方案,但没有成功: https://stackoverflow.com/a/40574224/5481661

Entity Framework Provider type could not be loaded?

.NET MySQL Connector Conflicting DbProviderFactories

【问题讨论】:

  • 您能详细说明您的尝试吗? MySQL 连接器/NET 是部署的一部分吗?
  • 连接器是否需要单独安装在服务器上,或者它是 MySql 的 Nuget 包的一部分?我将 v6.9.9 用于 MySql 包。我在上面的 package.json 中包含了 MySql 部分。
  • 连接器是 MySql.Data NuGet 包的一部分。

标签: asp.net amazon-web-services amazon-elastic-beanstalk amazon-rds


【解决方案1】:

请检查您是否已遵循以下 mySQL 文档中的所有步骤。根据文档,它指出 “除非 MySQL Connector/Net 与独立 MSI 或 MySQL Installer 一起安装,它会添加引用,否则将以下数据提供程序信息插入 app.config 或 web.config 文件:” https://dev.mysql.com/doc/connector-net/en/connector-net-entityframework60.html

希望这会有所帮助。

【讨论】:

  • 我已经检查了我对本文档的所有设置,看来我的一切都是正确的。还是不行:(
  • 请检查以下设置是否已应用。 docs.aws.amazon.com/elasticbeanstalk/latest/dg/…
  • 我确实有那个设置(这是我最初使用的说明),但它不起作用。我最终启动了一个新的 AWS 实例并重新部署,它工作正常。不知道为什么?也许最后一个配置搞砸了
猜你喜欢
  • 1970-01-01
  • 2021-09-16
  • 2019-09-25
  • 1970-01-01
  • 2020-02-21
  • 2021-04-08
  • 1970-01-01
  • 1970-01-01
  • 2021-10-11
相关资源
最近更新 更多