You’ve got your website running beautifully on your development / staging server. Then you upload your site to your GoDaddy Shared Hosting environment and are met with the ugly yellow screen of death and this message:
Here, I present the workarounds that I used to get my site up and running. These solutions apply to my use of MySQL and iTextSharp PDF library.
I hope you find this useful.
MySQL
Problem:
By default, the MySQL .NET Connector downloaded from the MySQL site requires full trust in order to work properly.
Solution:
Compile the connector so that Partially-Trusted callers can use the DLL.
Details:
- Download the source code for the connector.
- Modify the DLL attributes in the AssemblyInfo.cs file.
- add a using: using System.Security;
- Add the following line to the file:[assembly: AllowPartiallyTrustedCallers]
- Compile the DLL.
- Upload to site and test.
Resources:
MySQL Connector Source Code
Problem:
The MySQL .NET required Admin level rights in order to execute stored procedures.
Solution:
Use ad-hoc queries to execute the stored procedure.
Details:
- Create the stored procedures in your database. You can do this via the phpMyAdmin in the GoDaddy DB console. Or, you can do as I do: create the stored procedure locally. Then send to a backup that contains only the new stored procs. Upload the backup to GoDaddy and start a restore. The proc will be created/updated on the GoDaddy server.
- Modify your .NET code. Create MySQLCommand objects with “Type=CommandType.Text”. The text will then be something along the lines of: “exec MyStoredProcName(‘Param1Value’, ‘Param2Value’)”
- Test your changes. Upload when you are ready.
Resources:
iTextSharp
Problem:
Ny default, the iTextSharp DLL only works in a Full-Trust environment.
Solution:
Recompile the connector so that it can be called by PartiallyTrusted Callers.
Details:
- Download the source code.
- Modify the DLL attributes in the AssemblyInfo.cs file (see above)
- Compile the DLL.
- Upload to site and test.
Resources:
iTextSharp source code (v4.1.2)
iTextSharp source code (v5.0.0)
I hope you have found this useful. If you have any questions or comments, please contact me.
Thanks for visiting my site!
Thank-you Tomas! Of course I had to first reference System.Security in the AssemblyInfo.cs before [assembly: AllowPartiallyTrustedCallers] would work for iTextSharp.
(Sorry for the delay in acknowledging your observation)
You are correct! The System.Security namespace is now required in Framework 4 in order to use the “AllowPartiallyTrustedCallers” assembly attribute.
Thanks for pointing that out!
I am trying to use openXML SDK provided by microsoft on GoDaddy with no luck.
I have no idea how to set the settings to run this thing on GoDaddy.
How to use the pdfsharp.dll like itextsharp.dll?
I am not familiar with PDFSharp. But their website has a support section. You can get your questions answered there FORUM.