加入收藏 | 设为首页 | 会员中心 | 我要投稿 好传媒网 (https://www.haochuanmei.com/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 站长学院 > MySql教程 > 正文

c# – 无法加载“MySql.Data”或其中一个依赖项.

发布时间:2021-03-08 17:04:54 所属栏目:MySql教程 来源:网络整理
导读:我已经为Visual Studio和.NET Connector(6.7.4.0)安装了MySQL.我之前安装了6.6.5.0.为什么还在寻找这个DLL? System.IO.FileLoadException was unhandled HResult=-2146234304 Message=Could not load file or assembly 'MySql.Data,Version=6.6.5.0,Culture

我已经为Visual Studio和.NET Connector(6.7.4.0)安装了MySQL.我之前安装了6.6.5.0.为什么还在寻找这个DLL?

System.IO.FileLoadException was unhandled
  HResult=-2146234304
  Message=Could not load file or assembly 'MySql.Data,Version=6.6.5.0,Culture=neutral,PublicKeyToken=c5687fc88969c44d' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
  Source=mscorlib
  FileName=MySql.Data,PublicKeyToken=c5687fc88969c44d
  FusionLog==== Pre-bind state information ===
LOG: User = Vaughan-PCVaughan Hilts
LOG: DisplayName = MySql.Data,PublicKeyToken=c5687fc88969c44d
 (Fully-specified)
LOG: Appbase = file:///C:/Users/Vaughan Hilts/Documents/GitHub/blastersgame/BlastersOnline/LobbyServer/bin/Debug/
LOG: Initial PrivatePath = NULL
Calling assembly : System.Data,Version=4.0.0.0,PublicKeyToken=b77a5c561934e089.
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:UsersVaughan HiltsDocumentsGitHubblastersgameBlastersOnlineLobbyServerbinDebugLobbyServer.vshost.exe.Config
LOG: Using host configuration file: 
LOG: Using machine configuration file from C:WindowsMicrosoft.NETFrameworkv4.0.30319configmachine.config.
LOG: Post-policy reference: MySql.Data,PublicKeyToken=c5687fc88969c44d
LOG: Attempting download of new URL file:///C:/Users/Vaughan Hilts/Documents/GitHub/blastersgame/BlastersOnline/LobbyServer/bin/Debug/MySql.Data.DLL.
WRN: Comparing the assembly name resulted in the mismatch: Minor Version
ERR: Failed to complete setup of assembly (hr = 0x80131040). Probing terminated.

  StackTrace:
       at System.RuntimeTypeHandle.GetTypeByName(String name,Boolean throwOnError,Boolean ignoreCase,Boolean reflectionOnly,StackCrawlMarkHandle stackMark,IntPtr pPrivHostBinder,Boolean loadTypeFromPartialName,ObjectHandleOnStack type)
       at System.RuntimeTypeHandle.GetTypeByName(String name,StackCrawlMark& stackMark,Boolean loadTypeFromPartialName)
       at System.RuntimeType.GetType(String typeName,StackCrawlMark& stackMark)
       at System.Type.GetType(String typeName)
       at System.Data.Common.DbProviderFactories.GetFactory(DataRow providerRow)
       at System.Data.Common.DbProviderFactories.GetFactory(String providerInvariantName)
       at System.Data.Entity.Internal.LazyInternalConnection.CreateConnectionFromProviderName(String providerInvariantName)
       at System.Data.Entity.Internal.LazyInternalConnection.InitializeFromConnectionStringSetting(ConnectionStringSettings appConfigConnection)
       at System.Data.Entity.Internal.LazyInternalConnection.TryInitializeFromAppConfig(String name,AppConfig config)
       at System.Data.Entity.Internal.LazyInternalConnection.Initialize()
       at System.Data.Entity.Internal.LazyInternalConnection.get_ProviderName()
       at System.Data.Entity.Internal.LazyInternalContext.InitializeContext()
       at System.Data.Entity.Internal.InternalContext.Initialize()
       at System.Data.Entity.Internal.InternalContext.GetEntitySetAndBaseTypeForType(Type entityType)
       at System.Data.Entity.Internal.Linq.InternalSet`1.Initialize()
       at System.Data.Entity.Internal.Linq.InternalSet`1.get_InternalContext()
       at System.Data.Entity.Infrastructure.DbQuery`1.System.Linq.IQueryable.get_Provider()
       at System.Linq.Queryable.FirstOrDefault[TSource](IQueryable`1 source)
       at LobbyServer.Lobby.Main(String[] args) in c:UsersVaughan HiltsDocumentsGitHubblastersgameBlastersOnlineLobbyServerLobby.cs:line 64
       at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly,String[] args)
       at System.AppDomain.ExecuteAssembly(String assemblyFile,Evidence assemblySecurity,String[] args)
       at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
       at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext,ContextCallback callback,Object state,Boolean preserveSyncCtx)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext,Object state)
       at System.Threading.ThreadHelper.ThreadStart()
  InnerException: 
最佳答案 您可以使用绑定重定向来解决此错误.绑定重定向是一种框架功能,它允许您指示对该特定程序集的任何请求(由版本/公钥标记等标识)应该由该程序集的另一个版本提供服务.

所以你应该在和下添加一个节点.在这里,它应该是什么样子;


请注意,publicKeyToken,文化信息可以在exeception中找到(代码中出现异常,因为它基于您上面的异常信息).

附:
请记住,如果这些版本之间存在任何实际的界面差异,您可能会因为我们所期望的不匹配而最终获得例外,但通常大多数提供商都不会破坏主要版本以外的内容,因此我们不会通常会看到这样的问题:)

(编辑:好传媒网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    热点阅读