Can't connect to Mysql using .net driver with Fire/Silver

Shows the below message:

!> Exception of type System.ArgumentOutOfRangeException on thread 0001 ()
!> Message: Length cannot be less than zero.
!> Parameter name: length

Tested with 6.9.9 and 6.8.8 versions, downloaded from Mysql site.

I can connect successfully with SQLite, Firebird and PostgreSQL but fail with MySQL.

Sounds like a driver or connection string issue? Hard to tell without more information.

Connection string is ok, but internally MySQL launch a System.ArgumentOutOfRangeException with message

Length cannot be less than zero.
Parameter name: length

An exception occurred in test, thread 0001 ()

Type: System.ArgumentOutOfRangeException

Message:

Length cannot be less than zero.
Parameter name: length

Call Stack:
0000000000000053, mscorlib.dll, string.cs, String.Substring, (null)
000000000000001b, MySql.Data.dll, (null), MySqlConnectAttrs.get_ProgramName, (null)
0000000000000007, mscorlib.dll, MonoProperty.cs, MonoProperty.GetterAdapterFrame, (null)
0000000000000076, mscorlib.dll, MonoProperty.cs, MonoProperty.GetValue, (null)
0000000000000066, MySql.Data.dll, (null), NativeDriver.SetConnectAttrs, (null)
0000000000000086, MySql.Data.dll, (null), MySqlAuthenticationPlugin.Authenticate, (null)
0000000000000031, MySql.Data.dll, (null), NativeDriver.Authenticate, (null)
0000000000000300, MySql.Data.dll, (null), NativeDriver.Open, (null)
0000000000000011, MySql.Data.dll, (null), Driver.Open, (null)
0000000000000040, MySql.Data.dll, (null), Driver.Create, (null)
0000000000000006, MySql.Data.dll, (null), MySqlPool.CreateNewPooledConnection, (null)
000000000000008b, MySql.Data.dll, (null), MySqlPool.GetPooledConnection, (null)
000000000000001e, MySql.Data.dll, (null), MySqlPool.TryToGetDriver, (null)
000000000000001d, MySql.Data.dll, (null), MySqlPool.GetConnection, (null)
0000000000000116, MySql.Data.dll, (null), MySqlConnection.Open, (null)
000000000000010d, dbm.dll, (null), DBMMySQL.Connect, (null)
000000000000003b, test.exe, test_dbm.swift, __Global.main, (null)

In fact, you need try to connect to a Mysql database to debug, because Fire/Silver don’t let us debug inside DLLs yet.

I think that the problem is the DLL generate by Fire that are missing some information used by Mysql driver that are not required by the others drivers. It is the only explanation I could imagine until now.

Looks like a known issue: https://bugs.mysql.com/bug.php?id=70480

and you can just ignore this exception.

If I ignore this exception, all access to the connection will launch exceptions too.
Are something that the compiler can do to help Mysql driver get a valid path?
If not, close this bug and I will remove access to Mysql from my application using .Net driver,
letting access Mysql only in Java and Ruby version, until Oracle decide fix that bug.

How do you mean? Fire supports debugging .dlls just fine.

I’m not sure what you’d wanna see here. The compiler knows nothing about mySQL per se…

I don’t know what Mysql try to recover from Environment and if the compiler can set it or not.
Just asking if there are something that RemObjects can do to bypass this error adjusting the key that Mysql try to read in a way that don’t launch the error.

Nor do i, but the compiler can only do one thing: compile the source code you give it :wink:

At this stage we don’t even now what fails and why. You’re calling a library thats not ours, and its giving you an exception. Chances are you are calling it wrong, but its tough to say from here.

About debug DLLs, it is not working to me.
In Debug mode if I try to Debug a call from the program to a DLL I get a error.
Well, at least using Swift.

Look what appear to me when I try to do it:

From the bug you guys found, I saw it:

[1 Oct 2013 19:59] Sean Nolan
Description:
In the ProgramName attribute get accessor in MySqlConnectAttrs there is code that tries to determine the name of the running program like this
string path = Environment.CommandLine.Substring(0, Environment.CommandLine.IndexOf("" “)).Trim('”');
name = System.IO.Path.GetFileName(path);

In an ASP.NET application the path is typically going to be
c:\windows\system32\inetsrv\w3wp.exe -ap "App pool name

This results in the try/catch falling into the catch.

Given that the code is using a try/catch it does not raise runtime errors but it means that the ProgramName is not correctly determined and if you are debugging then you will see the exception each time a database call is made.

How to repeat:
Use the NET connector in an ASP.NET application. Attach the Visual Studio debugger and make a database call.

Suggested fix:
I’d suggest something like this as an alternative for getting the path

           string path = "";
           if (Environment.CommandLine.StartsWith("\""))
           {
               path = Environment.CommandLine.Substring(0, Environment.CommandLine.IndexOf("\" ")).Trim('"');
           }
           else
           {
               path = Environment.CommandLine.Substring(0, Environment.CommandLine.IndexOf(" "));
           }

Then appear to be something with application path at Environment variable when program is running.
I don’t know if there are something that the compiler can do to adjust it or if there are something that my own program can do to adjust it too. Just asking.

Ok. below the red line of text, there should be a button, “Locate Source”. If you have the source code for the .dll (the source code for Mono, in this case) on your local disk, you can click that to browse for the right file.

Since the .dll was not build on your local machine (and you may or may not have the source for it), Fire cannot automatically show you the source code for it — because the .dll’s debug symbols point to a folder that won’t exist on other disk (the one path shown in red).

Does that make sense?

Yes, but what I tried to go was my own dll.

Look:

To:

I don’t tried to go into Trim function but only inside Connect.

No this is abut the way the MySQL driver is written, apparently it uses the suited code to obtain the name of your the executable of your app — which fails for ASP.NET. Are you building an ASP.NET app, or a regular .executable?

In the latter case, it’s unlikely that this issue is what you are seeing.

what does

string path = Environment.CommandLine.Substring(0, Environment.CommandLine.IndexOf("\" ")).Trim('"');

print when you add the line to your app (or the equivalent, depending on what language you are using). Does it print the path and name of your exe correctly? If not, How are you running the app? in the Fire Debugger? If so, does anything change if you run it with Command-Shift-R, outside of the debugger?

Can you send me a small test project (ideally including may MySQL binaries i need, as i dint have those) that would allow me to reproduce the issue?

thanx,
marc

I am building a regular executable but I am getting the same error of an ASP.Net application.

When I
tried to run it:

print (Environment.CommandLine.Substring(0, Environment.CommandLine.IndexOf("" ")))

I got the same error that Mysql launch.

Nevermind; i have reproduced the issue:

This code mySQL is using fails, if there are to command line arguments (it will also fail differently when there would be a space in the exe name or the path to the .exe name. If this code actually exists in mySQL, this is a bug in their code.

Workaround:

(a) make sure yu don’t have spaces in your path name (doesn’t look like you do(
(b) call your exe with an extra dummy command line parameter. You can set those under in Settings in Fire 8.3 and using the new Command Line Argument Manager (Ctrl+Shift+A) in Fire 8.4. As soon as there are extra command line parameters, there will be a space in Commandline, and this code will no longer crash. (it will still be badly broken, and the mySQL guys need to fix that!)

hth,
marc

Ok, but the screenshot you provided was NOT with your own dll, so that’s all i can comment on!!??

If your own dll is built locally and with MDB Debug Symbols turned on, you should be able to debug it ok.

Yes, the screen shot that I provided was just trying to run that code I posted with that breakpoint.
Form my program to my own DLL.

I’m nit sure what to tell you. i explained why you dint see source for String.Trim in the screenshot — because its not your own code, and you don’t have the source. If that is NOT the actual example you ar shaving problems with, then why give that screenshot as an example? That’s like going to the doctor with leg pain, but only showing him your arm, not your leg?