A Programmer’s Cheat-Sheet for GoDaddy.com

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:

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

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:

  1. Download the source code for the connector.
  2. Modify the DLL attributes in the AssemblyInfo.cs file.
  3. add a using:  using System.Security;
  4. Add the following line to the file:[assembly: AllowPartiallyTrustedCallers]
  5. Compile the DLL.
  6. 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:

  1. 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.
  2. 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’)”
  3. 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:

  1. Download the source code.
  2. Modify the DLL attributes in the AssemblyInfo.cs file (see above)
  3. Compile the DLL.
  4. 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!


If you found this useful, consider helping me maintain this site.





8 Comments

  1. Rajesh

    How to use the pdfsharp.dll like itextsharp.dll?

    Reply
    1. -tomas (Post author)

      I am not familiar with PDFSharp. But their website has a support section. You can get your questions answered there FORUM.

      Reply
  2. Ahmad

    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.

    Reply
    1. eepltn

      6CXILZ gsoyzafjrnlu

      Reply
  3. Jeff Meyer

    Thank-you Tomas! Of course I had to first reference System.Security in the AssemblyInfo.cs before [assembly: AllowPartiallyTrustedCallers] would work for iTextSharp.

    Reply
    1. -tomas (Post author)

      (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!

      Reply
  4. Grant

    Thanks for the “fix” for iTextSharp, it worked like a charm and saved me hours of searching for an alternative.

    Reply
  5. Genaro Meiser

    GoDaddy was founded in 1997 as Jomax Technologies by Bob Parsons, a veteran of the United States Marine Corps. Prior to GoDaddy, Parsons sold his financial software services company, “Parsons Technology, Inc.” to Intuit. The sale provided him with several millions of dollars in the mid-1990s. As a result, Parsons decided to retire. In 1997, Bob Parsons came out of his retirement to launch a new company, Jomax Technologies which later became GoDaddy Group Inc.*,

    Best wishes
    http://www.homeimprovementstuffs.com

    Reply

Leave a Comment

Your email address will not be published. Required fields are marked *