Failed to load "MySql.Data" or one of these dependencies.

I installed MySQL for Visual Studio and .NET Connector (6.7.4.0). I previously had 6.6.5.0 installed. Why is he still looking for this 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 manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040) Source=mscorlib FileName=MySql.Data, Version=6.6.5.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d FusionLog==== Pre-bind state information === LOG: User = Vaughan-PC\Vaughan Hilts LOG: DisplayName = MySql.Data, Version=6.6.5.0, Culture=neutral, 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, Culture=neutral, PublicKeyToken=b77a5c561934e089. === LOG: This bind starts in default load context. LOG: Using application configuration file: C:\Users\Vaughan Hilts\Documents\GitHub\blastersgame\BlastersOnline\LobbyServer\bin\Debug\LobbyServer.vshost.exe.Config LOG: Using host configuration file: LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework\v4.0.30319\config\machine.config. LOG: Post-policy reference: MySql.Data, Version=6.6.5.0, Culture=neutral, 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, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean loadTypeFromPartialName) at System.RuntimeType.GetType(String typeName, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, 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:\Users\Vaughan Hilts\Documents\GitHub\blastersgame\BlastersOnline\LobbyServer\Lobby.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, ContextCallback callback, Object state, Boolean preserveSyncCtx) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) at System.Threading.ThreadHelper.ThreadStart() InnerException: 
+4
source share
5 answers

You can use binding redirection to solve this error. Redirection redirection is a structure function that allows you to specify that any requests for a particular assembly (identified by the version / public key token, etc.) must be served by another version of this assembly.

So you have to add node under and. Here's how it should look:

 <runtime> <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> <dependentAssembly> <assemblyIdentity name="MySql.Data" publicKeyToken="c5687fc88969c44d" culture="neutral" /> <bindingRedirect oldVersion="6.6.5.0" newVersion="6.7.4.0" /> </dependentAssembly> </assemblyBinding> </runtime> 

Please note that publicKeyToken, culture information can be found in exeception (where the exception is found in your code, as it is based on your exception information above).

PS Keep in mind, if there are any actual differences in the interface between these versions, you may end up with exceptions due to a mismatch in what we expect, so keep an eye on this, but most vendors usually don’t break things outside major versions, usually see such problems :)

+6
source

Including a response from another post here. The problem was that machine.config contained links to earlier dlls for MySql (e.g. V6.6.5.0). These links were created during the installation of MySQL Visual Studio add on (uhg). They must be reset for the correct version of the DLL.

  • Add the nuget links to the correct MySql.Data and MySql.Data.Entity libraries for the project. Click MySQL links and determine their version number (e.g. 6.7.4.0).
  • Edit machine.config * s * when your editor starts as an administrator and replace all occurrences of MySQL version 6.6.5.0 with 6.7.4.0.

Note that there are several machine.config files, make sure that you touch them all for your configuration.

C: \ Windows \ Microsoft.NET \ Framework \\ Config Also: C: \ Windows \ Microsoft.NET \ Framework64 \\ Config

+3
source

MySQL.Data is an external dll. This is not part of the .net framework. Therefore, you must add it to your cart or output folder. if the dll is present in the GAC, add it to your project links.

+1
source

Check your app.config, I think you specified the strong name mysql.data.dll.

0
source

I would not call it a real solution, but it seems that there were problems with other versions of MySQL and migration from the legacy installer of the .NET connector and the installer of MySQL for Windows. In the end, when I did the reinstallation of Windows, everything behaved. In fact, this is not an option for many, but if you are tired of headaches, but on TODO sooner rather than later, think about this to get out of the free card without a prison.

0
source

Source: https://habr.com/ru/post/1492851/


All Articles