Not a subscriber?

Join thousands of others who are building self-directed lives through creativity, grit, and digital strategy—breaking free from the 9–5.
Receive one free message a week

SubSonic on GoDaddy Shared Hosting

subsonic_logo I was trying to get SubSonic to run on a Free Hosting Environment (on GoDaddy) but unfortunately I kept getting a SecurityException when the code would attempt to save an entity. The code looked like this:

faq.Save(); // Saves a faq item to the database. 

This code would save the new FAQ entity to the database. Unfortunately this code would throw an exception. The reason the code threw an exception is because in SubSonic, the Utility.cs file trys to write to the Trace listeners. The Trace listeners have a SecurityAction that demands a security permission. On GoDaddy, they lock down this access. Why? Who knows. They’re hosters, they do what they do. GoDaddy usually has everything locked down to a medium trust environment.

The documentation states that you can turn off the trace by setting a flag called “enableTrace” to false, BUT… because this doesn’t work because the SecurityAction Demand walks the call stack right when its referenced in code at runtime. Since the flag is being checked in the calling code, the security action is being checked in the stack when the class is called.

This has been addressed in the SubSonic forums and it looks like it will be fixed soon. Here’s how to get around it for now.

Open the source for the SubSonic project. Go into the AbstractRecord.cs and comment out any line that has the following call:

Utility.WriteTrace("...");

From my finds, those line numbers are:

  • 901
  • 948
  • 951
  • 957
  • 962
  • 995
  • 1002

Comment all of those lines out, and then recompile the SubSonic project.

Then in your project, delete your SubSonic.dll reference, and now reference the new SubSonic.dll that you just built. This DLL will not have the call that writes to the trace.

This will avoid the Security call that eventually throws the exception.
The .Save() call will now succeed.

Good luck. 🙂