Page view counter

Godaddy.com and MySql.Data.dll problems.

Last post 06-15-2009 7:56 AM by andyste1. 53 replies.

Sort Posts:

  • Godaddy.com and MySql.Data.dll problems.

    06-14-2006, 10:36 AM
    • Loading...
    • whebert
    • Joined on 05-27-2004, 1:33 PM
    • Posts 25
    • Points 125

    I posted this on the 'Hosting Open Forums', but didn't get any answer so I'll try again here...

     

    I have a .NET 2.0 application that is hosted on Godaddy.com.  When you setup your MySQL database, Godaddy supplies you with several connection strings, depending on the connector you wish to use (ODBC, OLEDB, and MySQL Connector .NET).

    Since they provide a connection string for Connector .NET, I assume this means I could use this connector to access MySQL, and from what I read, doing so would be preferable to using ODBC or OLEDB.

    I setup my page and plopped the MySql.Data.dll into my bin directory as suggested.  Since Godaddy sets the trust level to medium on shared hosts, I got the following error (I've seen many people bring up this problem due to running under a medium trust level in .NET 2.0):

     System.Security.SecurityException: That assembly does not allow partially trusted callers.

    So, I did some research and it was suggested that if you add [assembly:AllowPartiallyTrustedCallers] to AssemblyInfo.cs in the MySql Connector .NET source, recompile, then use the new .dll, the trust issue will be resolved.

    I did this and placed the new .dll in my /bin folder and although the original error went away, I now get the following error:

     MySql.Data.MySqlClient.MySqlException: Unable to connect to any of the specified MySQL hosts ---> System.Security.SecurityException: Request for the permission of type 'System.Net.SocketPermission, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed

    For what it's worth, I am able to get the ODBC connector working (but intermittently 'lose connection during query' somewhat rarely, but enough to be a problem), but would prefer using the Connector .NET to access MySQL database.  Anybody experience this and know what is going on, or how to fix this?  Is using the MySQL Connector .NET just not possible with Godaddy.com?  Thanks for any info.

    Wyck

     

  • Re: Godaddy.com and MySql.Data.dll problems.

    06-14-2006, 2:20 PM
    • Loading...
    • aspcode.net
    • Joined on 06-19-2002, 1:38 AM
    • Posts 153
    • Points 647

    I might not have every detail correct here, but basically:

    reason for failure: your ASP.NET 2.0 application is running under "medium trust" - a context not allowing calls to unsigned assemblies. You need to either

    a) ask GoDaddy to put your app to run under full trust (which they might not want to - but you should tell them that it's false advertising to let you think you can run MySQL from .NET 2.0 and then not allow it)

    or

    b) ask GoDaddy to put MySQL.Data.dll in gac and then change a file called web_mediumtrust.config to allow the calling of MySQL.Data despite the "security"problem. Not sure about the change needed - google might help you

    or maybe

    c) ask MySQL.com or whoever has created the MySQL.Data.Dll driver to sign the assembly correctly. Not sure about this however, havn't read up on it but I do think it is a simple signing of the assembly missing...

    Alternative b) should be best from all perspectives and I really think webhosts running websites under medium trust (which btw should be ok and recommended) should implement the change

    Articles and news on ASP/ASP.NET
    ASPCode.net
  • Re: Godaddy.com and MySql.Data.dll problems.

    06-16-2006, 4:01 PM
    • Loading...
    • aspcode.net
    • Joined on 06-19-2002, 1:38 AM
    • Posts 153
    • Points 647

    MAYBE A SOLUTION?

    Just found out more about it. Please read more here

    http://forums.mysql.com/read.php?38,95478,96748#msg-96748

     

    Seems like some heroic guy has recompiled the MySql.Data.Dll with correct permissions requested

     

     

    Articles and news on ASP/ASP.NET
    ASPCode.net
  • Re: Godaddy.com and MySql.Data.dll problems.

    06-16-2006, 9:55 PM
    • Loading...
    • whebert
    • Joined on 05-27-2004, 1:33 PM
    • Posts 25
    • Points 125

    Ah yes, I was able to recompile the MySql.Data.Dll to allow partially trusted callers and I placed the new .dll in my /bin folder (see my first post).

    Although this did get rid of the "That assembly does not allow partially trusted callers" problem, a new problem arose.

    It appears that MySql.Data.Dll uses sockets and under the default permissions of the medium trust settings(web_mediumtrust.config), sockets aren't allowed.  When I try to use open a connection using MySql.Data.Dll, I get the following error:

     MySql.Data.MySqlClient.MySqlException: Unable to connect to any of the specified MySQL hosts ---> System.Security.SecurityException: Request for the permission of type 'System.Net.SocketPermission, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed

    When I spoke to technical support, they eventually sent me a link which described how to use medium trust under .NET 2.0. 

    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnpag2/html/paght000020.asp

    In this link, one of the things it describes is how to create a custom medium trust config file that will enable what you need, like System.Net.SocketPermission.  However, the big problem with that is since this is their host, and they want things to run under medium trust since it is a shared host, they have naturally locked the trust level. And, of course, I cannot override the trust level to any custom settings that would enable sockets, or anything else for that matter.

    So, if the MySql Connector .NET uses sockets (which it appears it does), and sockets aren't allowed by default in medium trust (which it appears it isn't), and they have the trust config locked down (which they do), the only way for me to use MySql.Data.Dll with a shared hosting plan with Godaddy.com is for Godaddy.com to enable this themselves.  Unless someone somewhere knows of a trick to work around this??

    I'm not sure I have a lot of confidence that Godaddy will enable this.  I can fall back to using ODBC, which I've gotten to work, but I just preferred to use MySql Connector .NET...  Thanks for the replies.

  • Re: Godaddy.com and MySql.Data.dll problems.

    06-17-2006, 2:32 PM
    • Loading...
    • aspcode.net
    • Joined on 06-19-2002, 1:38 AM
    • Posts 153
    • Points 647

    whebert,

    Ah yes, I was able to recompile the MySql.Data.Dll to allow partially trusted callers

    really sorry for not reading your question correctly. Or I think I first did but then mixed it up with a clients problem -  cause this question was presented to me by a client with a similar problem and therefore I might have jumped to conclusions in your particular case... 

    While my link might be of help for some people I'm sorry it didn't help you out with GoDaddy...

    As I have said before I really think it is low not to change the medium trust config file to make MySQL would work - false advertising I'd say - but me sympatizing for you doesn't help you much, does it?

    Let me know if you find out something cause this is big deal for many software developers as well.

    Articles and news on ASP/ASP.NET
    ASPCode.net
  • Re: Godaddy.com and MySql.Data.dll problems.

    06-19-2006, 11:30 PM
    • Loading...
    • whebert
    • Joined on 05-27-2004, 1:33 PM
    • Posts 25
    • Points 125

    Update:

    My problem was eventually sent up as a trouble ticket to the "Advanced Hosting Support" on Godaddy.com.  This is the response I received:

    Dear Sir/Madam,

    Thank you for contacting hosting support.

    The MySql.Data.MySqlClient is not installed on the hosting server. You may upload it to your bin directory and use it from there. However, the provider doesn't work in medium trust, so because you are using .NET 2.0 you will be unable to use it. We recommend switching to the ODBC .NET providers.

    Thank you for your understanding in this matter.

    So, it would appear that as of this writing, Godaddy.com does not support the MySql Connector/NET provider for .NET 2.0 on their shared hosts which run under medium trust.  I assume it works with .NET 1.1, since everything runs under full trust (or so I've heard), but I have not tested that out.

    This is unfortunate.  All other things aside, I really do like Godaddy.com hosting - especially the price.  Like I've mentioned before, I was able to get the ODBC provider working, so I can continue with that for the time being;  they give you one MS SQL database so the default .NET 2.0 Membership and Roles is trivial to setup and use;  and with a little tweaking I was able to get the SMTP email relay server working (had to figure out how to pass it credentials).

    It would be nice to see Godaddy.com fully support .NET 2.0 development with the MySql Connector/NET provider.  From the forums I read, it seems to be a rather large problem for many developers.  From what I gather, all they'd have to do is add the System.Net.SocketPermission namespace to their web_mediumtrust.config file and we'd all be set (assuming you have a recompiled MySql.Data.Dll assembly that allows partially trusted callers, of course). :)

     

  • Re: Godaddy.com and MySql.Data.dll problems.

    06-25-2006, 12:17 PM
    • Loading...
    • GDHosting
    • Joined on 06-23-2006, 8:59 PM
    • Posts 13
    • Points 29
    whebert,
     
    Thank you for your comments and opinions in regards to this issue.
    GoDaddy.com is always looking for ways to improve
    the customers experience and satisfaction with any of our hosting
    products.
    I would like to report that as of June 22, 2006, GoDaddy.com has updated
    the custom medium trust configuration to allow the
    MySql.Data.Dll to work in a medium trust environment for the .Net 2.0
    development environment.

    Please note that customers who wish to use .NET 2.0 must recompile the
    MySql.Data.Dll to allow for partially trusted callers.
    This can be done by adding the following to the AssemblyInfo.cs file.

    [assembly:AllowPartiallyTrustedCallers]

    Alek
    GoDaddy.com Hosting Team
    hosting@godaddy.com
  • Re: Godaddy.com and MySql.Data.dll problems.

    06-25-2006, 2:07 PM
    • Loading...
    • aspcode.net
    • Joined on 06-19-2002, 1:38 AM
    • Posts 153
    • Points 647

    Alek,

    just wanted to say: great, well done.

    Articles and news on ASP/ASP.NET
    ASPCode.net
  • Re: Godaddy.com and MySql.Data.dll problems.

    07-03-2006, 11:18 PM
    • Loading...
    • FrancisFoo
    • Joined on 08-30-2005, 7:59 AM
    • Moon
    • Posts 54
    • Points 270

    hi whebert,

    i have the same problems also, currently trying to solve it.

    i have the error

    {"Request for the permission of type 'System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed."}

    but i had set it in the mediumtrust web config, don't know why it show this out.

    whebert can you show how you set the web config and how you set the connection to mysql using mysql connector and also how to recompiled MySql.Data.Dll assembly that allows partially trusted callers. cause i just put in the trust = medium in to my web application.... to used it in web hosting company server.

    thanks

     

     

    ‘til that day, for that day.
  • Re: Godaddy.com and MySql.Data.dll problems.

    07-06-2006, 1:01 PM
    • Loading...
    • whebert
    • Joined on 05-27-2004, 1:33 PM
    • Posts 25
    • Points 125

    Great news!   Thanks Alek and the Godaddy Hosting Team.

    I just got back from vacation and haven't had time to test this yet.

    As soon as I do I'll post my results - I'm sure it all works fine now.

     

    FrancisFoo, as soon as I get a chance to test this I'll post how I setup everything and how I recompiled the MySql.Data.Dll.

  • Re: Godaddy.com and MySql.Data.dll problems.

    07-06-2006, 11:28 PM
    • Loading...
    • whebert
    • Joined on 05-27-2004, 1:33 PM
    • Posts 25
    • Points 125

    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.

  • Re: Godaddy.com and MySql.Data.dll problems.

    07-07-2006, 1:29 AM
    • Loading...
    • FrancisFoo
    • Joined on 08-30-2005, 7:59 AM
    • Moon
    • Posts 54
    • Points 270

    Hi whebert,

    thanks for reply, and thanks for the recompile part.

    i am using MS VB 2005 Express Edition ...... look like i had to... uninstall VB and install C#

    i had give it a "try" to compile it on Ms VS .Net 2003, it able to compile but show error when i used it in MS VB  2005 Express Edition.

    well post the result when it done.

    Francis

     

     

     

    ‘til that day, for that day.
  • Re: Godaddy.com and MySql.Data.dll problems.

    07-10-2006, 10:07 AM
    • Loading...
    • FrancisFoo
    • Joined on 08-30-2005, 7:59 AM
    • Moon
    • Posts 54
    • Points 270

    whebert,

    can you send me a copy of the recompile Mysql?

    cause i have VWD install in my PC already.

    thanks

    ‘til that day, for that day.
  • Re: Godaddy.com and MySql.Data.dll problems.

    07-11-2006, 9:08 AM
    • Loading...
    • FrancisFoo
    • Joined on 08-30-2005, 7:59 AM
    • Moon
    • Posts 54
    • Points 270

    whebert ,

    I install the C# and recompile the MySql and it works.  ^^

    I will try other query later.

    Finally I can continue develop my website.

    Thank you.

     

    ‘til that day, for that day.
  • Re: Godaddy.com and MySql.Data.dll problems.

    08-03-2006, 10:53 AM
    • Loading...
    • ckanoab
    • Joined on 08-03-2006, 2:40 PM
    • Posts 10
    • Points 35
    I'm kind of an asp.net noob, using visual web dev 2005 how do i actually connect to the database and fill a dataset? I've recompiled the dll, put it in my bin folder, changed my web.config file, but after that i'm kind of loss, on a single page how would i pull out a record and display it with godaddy and mysql?
Page 1 of 4 (54 items) 1 2 3 4 Next >