0

I'm having a issue with a Visual Basic 2013 program I made (in vb.net) and the issue is with MySQL.data.dll, I've tried changing copy local to true in the GAC, I've tried upgrading my MySQL.data.dll to the most recent version but whatever I do it only works if the MySQL.data.dll folder is in the same folder as the executable when running it.

(Do note that this error only occurs on other machines, not my machine)

This is the error exactly:

[Could not load file or assembly 'MySql.data, Version=6.9.5.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d' or one of its dependencies. The system cannot find the file specified.]

Please help, I don't want to have my users have to put MySQL.data.dll in a file with the exe just to be able to run it (for obvious reasons.)

Joel Coehoorn
  • 399,467
  • 113
  • 570
  • 794
Ryan Smith
  • 81
  • 1
  • 1
  • 8
  • 1
    What are the obvious reasons? If you want your app to connect with MySQL you will have to deploy it with the MySQL.data.dll, there is no way around this. – Joe Uhren Jan 28 '15 at 02:56
  • This is a dupe of ...http://stackoverflow.com/questions/4469929/could-not-load-file-or-assembly-or-one-of-its-dependencies – Mick Jan 28 '15 at 02:57
  • @Mick how is it a dupe? He is asking a completely different question. Did you even look at what he asked before trashing my question? :) – Ryan Smith Jan 28 '15 at 03:03
  • @RyanSmith the source of these problems is always the same. This type of problem will have been covered a billion times already – Mick Jan 28 '15 at 03:04
  • @AlexeiLevenkov I've seen other programs before that are linked to MySQL databases not require any sort of DLL's – Ryan Smith Jan 28 '15 at 03:17
  • @RyanSmith I've seen *a lot* of stuff too - the real issue here is it is not clear what kind of help you are looking for on SO - figure out what this error is about, design something for you, read MySQL guides on integration with .Net, something else? – Alexei Levenkov Jan 28 '15 at 03:23
  • @AlexeiLevenkov he's talking about the "Copy Local" option in the properties of the assembly reference... https://msdn.microsoft.com/en-us/library/t1zz5y8c%28v=vs.90%29.aspx – Mick Jan 28 '15 at 03:25
  • @Mick "not require any sort of DLL's " does not feel to me can be solved by "Copy local", but it is just my personal opinion. – Alexei Levenkov Jan 28 '15 at 03:47
  • @RyanSmith do you have the name of or a link to one of these dotnet applications that connect to a mysql database without the mysql.data.dll? – Joe Uhren Jan 28 '15 at 03:57
  • @JoeyJoeJoeJrShabadoo he wants to ship the MySQL DLL with the application, as opposed to his application expecting the assembly to be installed in the GAC, which would require installing MySQL seperately – Mick Jan 28 '15 at 04:01

1 Answers1

2

Check the version of the MySQL assembly against the versions appearing in the compiler output.

Do not use the error list look at the Output window and select Build from the drop down and look for errors.

The most probable cause is your application is linked to specific (possibly multiple) versions of MySQL, and there is a conflict on the specific version of MySQL referenced. You might also want to change the specific version property of the assembly reference...

How exactly does the "Specific Version" property of an assembly reference work in Visual Studio?

asp server error ' Could not load file or assembly ' but the assembly is definitely there.

It's pretty simple. You need to make sure the reference to the assembly is correct. I'd avoid installing MySQL into the GAC. Don't install the MSI, if you have uninstall it, then download the zip archive

mysql-connector-net-6.9.5-noinstall.zip

Extract the files to a folder reference those assemblies in your solution. If you're using source control check the folder containing the MySQL assemblies into source control, with the rest of the solution.

If you have more than one assembly referencing MySQL you should check that they are all referencing the same version, from the same location and/or have the "Specific Version" property set to false and "Copy Local" set to true.

Community
  • 1
  • 1
Mick
  • 6,527
  • 4
  • 52
  • 67
  • OP seem to know where the problem is - clearly if one "don't want to .... put MySQL.data.dll in a file with the exe just to be able to run it" there will be an error... but it is not clear to me what kind of solution OP is seeking. – Alexei Levenkov Jan 28 '15 at 03:12
  • Sorry, I'm a little confused. I'm assuming you're referring to the bottom window that says "Output"... but I don't know what you mean by errors. If you mean what it says when I build it then this is what it outputs: Build: 0 succeeded, 0 failed, 1 up-to-date, 0 skipped ........ I'm relatively new to this whole thing sorry. – Ryan Smith Jan 28 '15 at 03:14
  • Go to Build menu. Select Clean Solution. Then select Reuild Solution. After the build select View -> Output to display the Output window. Then select Build from the combobox to view the output from the build, look for warnings or errors in the build which suggest there are conflicts. – Mick Jan 28 '15 at 03:23
  • @mick No errors, Clean started: Project: databasetest, Configuration: Debug Any CPU and ========== Clean: 1 succeeded, 0 failed, 0 skipped ========== – Ryan Smith Jan 28 '15 at 03:35
  • After the clean select rebuild. If its a runtime issue you'll probably see warnings not errors. – Mick Jan 28 '15 at 03:59
  • @mick I did rebuild after clean select and there are no warnings/errors just did it again. – Ryan Smith Jan 28 '15 at 04:05
  • Have you tried running the application? Do you still get the same runtime error? If so using windows explorer can you see the MySQL assembly in the bin\debug folder ? Right click and select properties which version is the assembly what's the version of the assembly? – Mick Jan 28 '15 at 04:10
  • @mick It says to move the discussion to chat but I don't have enough rep. Anyways, I just ran it on a virtual machine and no luck same runtime error. Would you suggest possibly putting it on a installer and having it just create itself a folder inside program files with the MySQL.data.dll file inside? Or are there any better alternatives? – Ryan Smith Jan 28 '15 at 04:23
  • @RyanSmith if you put the MySQL.data.dll file inside the same folder as your application exe does that not fix the error on the virtual machine? There is no need to put it into program files, in fact it shouldn't be looking for it there so that wouldn't work (Only reason it would is if you actually have mysql installed on that machine). You need your installer to put the dll into the same directory as your app but try it manually first to make sure it works. – Joe Uhren Jan 28 '15 at 04:32
  • @JoeyJoeJoeJrShabadoo That's what I said works, or I might not have explained that I'm not sure. But I'm wondering if there is a workaround for having to have the dll file in the same file as the executable whenever running it, (obviously if a shortcut is created you don't have too) but I'm talking about the core executable. – Ryan Smith Jan 28 '15 at 04:38
  • @RyanSmith applications are typically shipped with multiple assemblies/files, you will need to ship MySQL with your application. There should be no need to manually copy MySQL it should be possible for Visual Studio to compile the application and include the MySQL assemblies in the output folder. – Mick Jan 28 '15 at 04:43
  • There is no workaround for that. If you use a 3rd party dll like the MySQL.data.dll then you have to include it in the same path as the exe. There are tons of commercial applications that do the same thing. The only way around that is to write your own interface between MySQL and your app, but why go through all that trouble when the MySQL team already wrote a dll for you? – Joe Uhren Jan 28 '15 at 04:43
  • I created a installation wizard. Problem solved, thanks guys. – Ryan Smith Jan 28 '15 at 05:00