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.
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
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.
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.
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.
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). :)
<div>whebert,</div> <div> </div> <div>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.
</div> <div>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]
</div> <div>
Alek</div> <div>GoDaddy.com Hosting Team hosting@godaddy.com
</div>
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.
whebert
Member
125 Points
25 Posts
Godaddy.com and MySql.Data.dll problems.
Jun 14, 2006 02:36 PM|LINK
I posted this on the 'Hosting Open Forums', but didn't get any answer so I'll try again here...
<div class=ForumPostContentText id=_ctl0__ctl1_bcr__ctl0___PostRepeater__ctl1_PostViewWrapper>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
</div>aspcode.net
Member
647 Points
153 Posts
Re: Godaddy.com and MySql.Data.dll problems.
Jun 14, 2006 06:20 PM|LINK
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
ASPCode.net
aspcode.net
Member
647 Points
153 Posts
Re: Godaddy.com and MySql.Data.dll problems.
Jun 16, 2006 08:01 PM|LINK
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
ASPCode.net
whebert
Member
125 Points
25 Posts
Re: Godaddy.com and MySql.Data.dll problems.
Jun 17, 2006 01:55 AM|LINK
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.
aspcode.net
Member
647 Points
153 Posts
Re: Godaddy.com and MySql.Data.dll problems.
Jun 17, 2006 06:32 PM|LINK
whebert,
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.
ASPCode.net
whebert
Member
125 Points
25 Posts
Re: Godaddy.com and MySql.Data.dll problems.
Jun 20, 2006 03:30 AM|LINK
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). :)
GDHosting
Member
45 Points
17 Posts
Re: Godaddy.com and MySql.Data.dll problems.
Jun 25, 2006 04:17 PM|LINK
GoDaddy.com is always looking for ways to improve
the customers experience and satisfaction with any of our hosting
products.
</div> <div>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]
</div> <div>
Alek</div> <div>GoDaddy.com Hosting Team
hosting@godaddy.com
</div>
aspcode.net
Member
647 Points
153 Posts
Re: Godaddy.com and MySql.Data.dll problems.
Jun 25, 2006 06:07 PM|LINK
Alek,
just wanted to say: great, well done.
ASPCode.net
FrancisFoo
Member
270 Points
54 Posts
Re: Godaddy.com and MySql.Data.dll problems.
Jul 04, 2006 03:18 AM|LINK
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
whebert
Member
125 Points
25 Posts
Re: Godaddy.com and MySql.Data.dll problems.
Jul 06, 2006 05:01 PM|LINK
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.