Bug #28740 Failure to connect to server, when loading the DLL from remote
Submitted: 29 May 2007 9:13 Modified: 19 Aug 2007 10:11
Reporter: Yaniv Kaul Email Updates:
Status: Can't repeat Impact on me:
None 
Category:Connector / NET Severity:S2 (Serious)
Version:5.0.7 OS:Windows
Assigned to: CPU Architecture:Any

[29 May 2007 9:13] Yaniv Kaul
Description:
I've created a C# DLL that uses the MySQL DLL to connect to the MySQL database.
I'm using the .Net object I've created in powershell scripts. When I'm loading the DLL locally, everything works fine. When I'm loading the DLL remotely (either via http or via SMB \\server\DLLs\...) it fails to connect to the server:
The error I'm getting:
New-Object : Exception calling ".ctor" with "5" argument(s): ".ctor(): failed to initialize DB object - MySQL exception
 [#1042]. Connection String: server=10.0.11.14;uid=admin;pwd=admin1;database=qa Exception message: Unable to connect to
 any of the specified MySQL hosts."

My code:
	$MySQLDB = new-object QADB.DB ($database, $db_table, $user, $password, $dbhost)

The QADB.DB constructor:
MySQLConnectionString = String.Format("Server={0};Uid={1};pwd={2};Database={3}", host, username, password, dbname);

            try
            {
                MySqlConn = new MySql.Data.MySqlClient.MySqlConnection(MySQLConnectionString);
                MySqlConn.Open();
                //MySqlCmd = new MySql.Data.MySqlClient.MySqlCommand();
                MySqlCmd = MySqlConn.CreateCommand();
                //MySqlCmd.Connection = MySqlConn;
                tests_DB = tests_db;
            }
            catch (MySql.Data.MySqlClient.MySqlException mysqlex)
            {
                throw new Exception(MethodBase.GetCurrentMethod().Name + "(): failed to initialize DB object - MySQL exception [#" + mysqlex.Number + "]. Connection String: " + MySQLConnectionString  + " Exception message: " + mysqlex.Message);
            }
            catch (Exception ex)
            {
                throw new Exception(MethodBase.GetCurrentMethod().Name + "(): failed to initialize DB object - general exception: " + ex.Message);
            }

How to repeat:
Load the DLL from remote (see above description)
[12 Jun 2007 11:47] Tonci Grgin
Hi Yaniv and thanks for your report.

Are you loading the assembly manually (using the reflection API) or are you using some other mechanism? Please attach test case that shows the actual loading code.
[12 Jun 2007 12:15] Yaniv Kaul
I'm loading the DLL at startup (in profile.ps1) in the following manner:

[Reflection.Assembly]::LoadFrom($PSScripts + "http://webserver/MySql.Data.dll")
[20 Jun 2007 21:13] Tonci Grgin
Yaniv, looks to me it should work... Analyzing again.
[16 Jul 2007 21:23] Bogdan Degtyariov
Yaniv,

please try to run the C# project attached (see below). It works perfectly for me.
However, the application has to be built with the .NET 2.0 runtime.
[16 Jul 2007 21:23] Bogdan Degtyariov
Test case

Attachment: _bug28740_CS.zip (application/x-zip-compressed, text), 20.66 KiB.

[17 Aug 2007 23:00] Bugs System
No feedback was provided for this bug for over a month, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
[19 Aug 2007 8:48] Tonci Grgin
Yaniv, I though this was serious problem for you but you returned no info to us.
[19 Aug 2007 9:51] Yaniv Kaul
I'm sorry, but once I found a workaround, I had to continue to other work. I really apologize, but I won't have time to re-test this in the next month or so :(
[19 Aug 2007 9:59] Tonci Grgin
Yaniv, I am puzzled about two things:
 1) You didn't post your workaround for others with similar problem to share
 2) You didn't reply to Bogdan's solution? Has it anything to do with your workaround?
[19 Aug 2007 10:04] Yaniv Kaul
My workaround was to load and run the DLLs locally (I copied them manually to all servers).
[19 Aug 2007 10:08] Tonci Grgin
Yaniv, thanks. I presume your app is built with .NET 2.0 runtime as Bogdan suggested?
[19 Aug 2007 10:11] Yaniv Kaul
Yes, my application is built using .NET 2.0 .