Bug #45589 Exception when I want to connect to my database
Submitted: 18 Jun 2009 14:17 Modified: 30 Jun 2009 22:24
Reporter: jerome coutant Email Updates:
Status: Can't repeat Impact on me:
None 
Category:Connector / NET Severity:S2 (Serious)
Version:6.0.4 OS:Windows
Assigned to: CPU Architecture:Any
Tags: connection open

[18 Jun 2009 14:17] jerome coutant
Description:
I'm developping with MySQL version 5.1.30 and with VS C# 2008 express edition using MySqlData.dll.

I have the exception "NullReferenceEdition" when I want to connect to my database.

How to repeat:
Here is my code sample:
MySqlConnection mycon = new MySqlConnection(connectionString);
mycon.Open();

The exception is raised on Open() method.

Suggested fix:
I fix the problem into MySqlTream.cs file into public MySqlPacket ReadPacket().

Jerome
[20 Jun 2009 9:12] Tonci Grgin
Hi Jerome and thanks for your report.

I can not repeat it using c/NET 6.0.4 and remote MySQL server 5.1.31 on OpenSolaris box... Can you provide any more info on this?
[22 Jun 2009 9:53] jerome coutant
Hi Tonci, 

I rebuild MySqlData with the old code before my change to give you more information and this morning the connection is Ok.
I think I had a problem in my connection string or another thing and in this case, the problem occurs because of reading the error from database server, we need to use the encoding objet into packet.ReadString() call from ReadPacket() method. Here is the code sample from ReadPacket() method into MySqlPacket.cs file :
...
string s = encoding.GetString(bits, 
                (int)buffer.Position, end - (int)buffer.Position);
...

Regards, Jerome
[30 Jun 2009 22:23] Bugs System
A patch for this bug has been committed. After review, it may
be pushed to the relevant source trees for release in the next
version. You can access the patch from:

  http://lists.mysql.com/commits/77592
[30 Jun 2009 22:24] Reggie Burnett
I am marking this as cant' repeat but I added an exception if the default encoding can't be created.  This way if this happens again then the user will be directed to report it as a bug along with the connection string and system details.