Recently
Archives
Links
Reading
Listening
Fixing GoDaddy
Wednesday, February 21, 2007
OK, another boring post.

GoDaddy is who we use for our hosting, and for the most part they've been cheap AND reliable.

For some reason, however, on February 20th, 2007 the bottom fell out of the custom applications I had written in ASP.NET 2.0, each of which used ODBC to connect to the MySQL databases provided by GoDaddy. I kept getting the following nasty error every 5 queries or so:

ERROR [HYT00] [MySQL][ODBC 3.51 Driver][mysqld-4.0.27-max-log]MySQL server has gone away

After scouring the internet and wasting three seperate tech calls with GoDaddy, I finally figured out what the deal was.

Apparently something changed (I suspect via Windows Updates on their servers) which broke ODBC's ability to maintain connections with MySQL. I finally tried the MySQL Connector for .NET and it completely fixed the problem with very minimal changed to my code. The MySQL connector has to be recompiled in order to get it to work with GoDaddy's server. Here's instructions I found from here:


Well, I tested it and sure enough, it works now. So thanks again to Alek and the Godaddy Hosting Team for taking the time to add support for the MySql Connector/Net provider under .NET 2.0.

As mentioned, I did have to place the recompiled assembly in the /bin folder to get it to work, but that is easy to do. For those who haven't already done so or haven't read about it elsewhere, this is how I recompiled the MySql.Data.Dll assembly.

I first downloaded the Connector/NET 1.0 provider from the MySql site: http://dev.mysql.com/downloads/connector/net/1.0.html

The Connector/NET provider (binaries and source code) were installed to the following location on my hard drive: C:\Program Files\MySQL\MySQL Connector Net 1.0.7

I then went into the \src folder and noticed they provide you with solution (.sln) and project (.csproj) files for Visual Studio, so I downloaded the free version of MS Visual C# 2005 Express Edition at: http://msdn.microsoft.com/vstudio/express/visualcsharp/default.aspx

I opened the solution file with Visual Studio C# 2005 Express (I think VS did some conversion to the solution to open it in the new version, no biggy) and simply added the following to the AssemblyInfo.cs file:

using System.Security; // I added this after at the end of the 'using' section

[assembly: AllowPartiallyTrustedCallers()] // I added this at the end of the 'assembly' section

Clicked 'Build'->'Build Solution' and voila, it built the new assembly.

I located the new .dll file in the C:\Program Files\MySQL\MySQL Connector Net 1.0.7\src\bin\net-1.1\Release folder. I know it recompiled it to the 'net-1.1' under \bin, but I don't think that matters - it seems to work for .NET 2.0 as well. If somebody knows differently, please let me know - I didn't see anywhere within VS Studio to change the compile for 2.0 specifically...

Anyway, I placed this recompiled MySql.Data.Dll in the /bin folder on my website and everything seems to be working now. I didn't have to change anything in my web.config file, just used the connection string Godaddy provided to me and tested a few queries, everything is working as it should now.


Once I referenced this freshly compiled .dll in my project, I simply replaced any references to System.Data.Odbc.Odbc with MySql.Data.MySqlclient.MySql, and compiled my project. Problem solved.

Again, not very interesting reading material, but I spent some good time on this and decided to share with the world.

2 Comments:

Messianic Gentile said...

Thanks. I was so bored I gave up at the first sentence.

Missing your posts...

Many blessings...

2/21/2007 8:27 PM  
Anonymous said...

I just downloaded the newest version of .net/connector 5.1. Copyed it to my bin folder and it works fine both on my local computer and on godaddy. I was having problems with odbc on godaddy, hopefully this will fix the problem!

7/31/2007 5:16 PM  

Post a Comment

<< Home