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

前端之家收集整理的这篇文章主要介绍了c# – 无法加载“MySql.Data”或其中一个依赖项.前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

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

  1. System.IO.FileLoadException was unhandled
  2. HResult=-2146234304
  3. 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)
  4. Source=mscorlib
  5. FileName=MysqL.Data,PublicKeyToken=c5687fc88969c44d
  6. FusionLog==== Pre-bind state information ===
  7. LOG: User = Vaughan-PC\Vaughan Hilts
  8. LOG: DisplayName = MysqL.Data,PublicKeyToken=c5687fc88969c44d
  9. (Fully-specified)
  10. LOG: Appbase = file:///C:/Users/Vaughan Hilts/Documents/GitHub/blastersgame/BlastersOnline/LobbyServer/bin/Debug/
  11. LOG: Initial PrivatePath = NULL
  12. Calling assembly : System.Data,Version=4.0.0.0,PublicKeyToken=b77a5c561934e089.
  13. ===
  14. LOG: This bind starts in default load context.
  15. LOG: Using application configuration file: C:\Users\Vaughan Hilts\Documents\GitHub\blastersgame\BlastersOnline\LobbyServer\bin\Debug\LobbyServer.vshost.exe.Config
  16. LOG: Using host configuration file:
  17. LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config.
  18. LOG: Post-policy reference: MysqL.Data,PublicKeyToken=c5687fc88969c44d
  19. LOG: Attempting download of new URL file:///C:/Users/Vaughan Hilts/Documents/GitHub/blastersgame/BlastersOnline/LobbyServer/bin/Debug/MysqL.Data.DLL.
  20. WRN: Comparing the assembly name resulted in the mismatch: Minor Version
  21. ERR: Failed to complete setup of assembly (hr = 0x80131040). Probing terminated.
  22. StackTrace:
  23. at System.RuntimeTypeHandle.GetTypeByName(String name,Boolean throwOnError,Boolean ignoreCase,Boolean reflectionOnly,StackCrawlMarkHandle stackMark,IntPtr pPrivHostBinder,Boolean loadTypeFromPartialName,ObjectHandleOnStack type)
  24. at System.RuntimeTypeHandle.GetTypeByName(String name,StackCrawlMark& stackMark,Boolean loadTypeFromPartialName)
  25. at System.RuntimeType.GetType(String typeName,StackCrawlMark& stackMark)
  26. at System.Type.GetType(String typeName)
  27. at System.Data.Common.DbProviderFactories.GetFactory(DataRow providerRow)
  28. at System.Data.Common.DbProviderFactories.GetFactory(String providerInvariantName)
  29. at System.Data.Entity.Internal.LazyInternalConnection.CreateConnectionFromProviderName(String providerInvariantName)
  30. at System.Data.Entity.Internal.LazyInternalConnection.InitializeFromConnectionStringSetting(ConnectionStringSettings appConfigConnection)
  31. at System.Data.Entity.Internal.LazyInternalConnection.TryInitializeFromAppConfig(String name,AppConfig config)
  32. at System.Data.Entity.Internal.LazyInternalConnection.Initialize()
  33. at System.Data.Entity.Internal.LazyInternalConnection.get_ProviderName()
  34. at System.Data.Entity.Internal.LazyInternalContext.InitializeContext()
  35. at System.Data.Entity.Internal.InternalContext.Initialize()
  36. at System.Data.Entity.Internal.InternalContext.GetEntitySetAndBaseTypeForType(Type entityType)
  37. at System.Data.Entity.Internal.Linq.InternalSet`1.Initialize()
  38. at System.Data.Entity.Internal.Linq.InternalSet`1.get_InternalContext()
  39. at System.Data.Entity.Infrastructure.DbQuery`1.System.Linq.IQueryable.get_Provider()
  40. at System.Linq.Queryable.FirstOrDefault[TSource](IQueryable`1 source)
  41. at LobbyServer.Lobby.Main(String[] args) in c:\Users\Vaughan Hilts\Documents\GitHub\blastersgame\BlastersOnline\LobbyServer\Lobby.cs:line 64
  42. at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly,String[] args)
  43. at System.AppDomain.ExecuteAssembly(String assemblyFile,Evidence assemblySecurity,String[] args)
  44. at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
  45. at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
  46. at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext,ContextCallback callback,Object state,Boolean preserveSyncCtx)
  47. at System.Threading.ExecutionContext.Run(ExecutionContext executionContext,Object state)
  48. at System.Threading.ThreadHelper.ThreadStart()
  49. InnerException:
最佳答案
您可以使用绑定重定向解决错误.绑定重定向是一种框架功能,它允许您指示对该特定程序集的任何请求(由版本/公钥标记等标识)应该由该程序集的另一个版本提供服务.

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

  1. MysqL.Data" publicKeyToken="c5687fc88969c44d" culture="neutral" />

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

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

猜你在找的MySQL相关文章