Problem Context
I have written an application in C# which uses a MySqlConnector. I've added MySql.Data.dll (Version 6.9.3.0) to the References - this all works as expected on my PC (running Windows 7). However, starting with recent builds, when I try to run the application on another PC (running Windows XP), it throws an Exception on startup.
I added an UnhandledExceptionEventHandler which shows the error Could not load file or assembly 'MySql.Data, Version 6.8.3.0. (...etc...)' or one of its dependencies. The located assembly's manifest description does not match the assembly reference. File name: 'MySql.Data, Version=6.8.3.0, (...etc...).
Obviously it is looking for Version 6.8.3.0 but only finding Version 6.9.3.0 in the References - but what I want to know is why it is looking for this version when it worked correctly with earlier builds, and how I can specify which version of MySql to look for.
I know I could just add another reference to the earlier version of the .dll, but I want to understand why this is happening.
Steps taken to attempt to diagnose the problem
Checked the project's
Referencesafter seeing this question on Stack Overflow and confirming that a reference toMySql.Data.dllhas been added to the project, along with its version (6.9.3.0).Searched for results relating to the Exception error message and found this article on Stack Overflow describing its cause (which I was aware of, but it confirms it)
A colleague asked me to confirm that the
SpecificVersionproperty of theMySql.DataReference is set toFalse(it is).Tried adding an assembly binding to the config as suggested in an answer below - it does not help, the same error is thrown.
Replaced the
MySqlData.dllon the other PC with version6.8.3.0as a 'dirty fix' to see what happened. It now throws the same error as before, but for missing6.9.3.0.Asked a colleague to run the application on his (Windows 7) PC - no error was generated and it worked as expected.
I tried using the
Dependency Walkerutility on the.exeas a commenter suggested but it only showed the following .dlls missing -IESHIMS.DLL(on both PCs),WER.DLL(on the XP PC), andGPSVC.DLL(on my PC). There was nothing aboutMySql.Data.dll. (Though I have since learned this is not a useful tool in this case - see this question.)On a whim, I decided to change the
SpecificVersionproperty ofMySql.DataReference toTrue- this fixes the problem.
Additional Information
My app.config file -
<?xml version="1.0"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0,Profile=Client"/>
</startup>
</configuration>