I seem to have the luck to run into the funniest problems while deploying my software.
Setup:
- Windows 2000 Prof.
- .NET 2.0 Application
- Connection to MySQL 5.0 via ODBCConnection using the MySQL ODBC-Connector 3.51.26
I was deploying my application while I was running into this exception:
at System.Data.Odbc.OdbcConnection.HandleError(OdbcHandle hrHandle, RetCode retcode)
at System.Data.Odbc.OdbcDataReader.GetData(Int32 i, SQL_C sqlctype, Int32 cb, Int32& cbActualOut)
at System.Data.Odbc.OdbcDataReader.internalGetString(Int32 i)
at System.Data.Odbc.OdbcDataReader.GetValue(Int32 i, TypeMap typemap)
at System.Data.Odbc.OdbcDataReader.GetValue(Int32 i)
at System.Data.Odbc.OdbcDataReader.GetValues(Object[] values)
at MyAppl.UninterestingStackTace.StartsHere()
Yes, that’s only the stacktrace…because there is no Exception-Message, there’s also no InnerException (I also log those since my last encounter), this is all I got.
The code looks like this:
// DtRdr is a passed in ODBCDataReader
if (DtRdr != null && !DtRdr.IsClosed)
{
Object[] buffer = new Object[DtRdr.FieldCount];
while (DtRdr.Read())
{
DtRdr.GetValues(buffer); // Here happens the exception
// Modify buffer and use it
}
}
It’s only happening on that machine, the fetched data/database is good (verified it via another machine on the same network and I also tested it locally on my dev-machine) and of course it’s not reproducible on any other machine.
While looking at it in Reflector, I realize that it seems to be a problem with reading the data from the connection. All other operations are working fine, I can access the data directly, only GetValues fails.
I wrote a fast and simple test application which yields the same error, but also outputs the following statement after terminating:
Error in my_thread_global_end(): 1 threads didn't exit
I’m not sure if this is related or not, so sorry for the confusion.
I’m lost once again…has anyone seen something like this before?
Edit: Here’s my test application:
using System;
using System.Data;
using System.Data.Odbc;
namespace ODBCTest
{
class MainClass
{
public static void Main (string[] args)
{
try {
Console.WriteLine ("Creating connection...");
using (OdbcConnection conn = new OdbcConnection ("ConnStringHere")) {
conn.Open ();
Console.WriteLine ("Creating command...");
using (OdbcCommand cmd = conn.CreateCommand ()) {
cmd.CommandText = "SimpleSelectHere;";
Console.WriteLine ("Creating reader...");
using (OdbcDataReader rdr = cmd.ExecuteReader ()) {
if (rdr != null && !rdr.IsClosed) {
while (rdr.Read ()) {
object[] temp = new object[rdr.FieldCount];
rdr.GetValues (temp);
}
Console.WriteLine ("Seems to work fine.");
} else {
Console.WriteLine ("Could not create reader!");
}
}
}
}
} catch (Exception ex) {
Console.WriteLine (ex.Message);
Console.WriteLine (ex.StackTrace);
Console.WriteLine ();
if (ex.InnerException != null)
{
Console.WriteLine (ex.InnerException.Message);
Console.WriteLine (ex.InnerException.StackTrace);
} else {
Console.WriteLine("No InnerException.");
}
}
Console.ReadKey ();
}
}
}
And it’s output:
Creating connection...
Creating command...
Creating reader...
at System.Data.Odbc.OdbcConnection.HandleError(OdbcHandle hrHandle, RetCode retcode)
at System.Data.Odbc.OdbcDataReader.GetData(Int32 i, SQL_C sqlctype, Int32 cb, Int32& cbActualOut)
at System.Data.Odbc.OdbcDataReader.internalGetString(Int32 i)
at System.Data.Odbc.OdbcDataReader.GetValue(Int32 i, TypeMap typemap)
at System.Data.Odbc.OdbcDataReader.GetValue(Int32 i)
at System.Data.Odbc.OdbcDataReader.GetValues(Object[] values)
at ODBCTest.MainClass.Main(String[] args)
No InnerException.
<At this point I hit a key>
Error in my_thread_global_end(): 1 threads didn't exit
I’ll be damned! This is a bug in the MDAC 2.7, installing 2.8 (or the hotfix) fixes this.
And the thread-error message is a bug in the used MySQL ODBC-Connector.