SubSonic on GoDaddy Shared Hosting

by Donn Felker 9. September 2007 21:52

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. :)

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

ASP.NET | Code Generation

Comments

Add comment


(Will show your Gravatar icon)  

  Country flag

biuquote
  • Comment
  • Preview
Loading



Powered by BlogEngine.NET 1.4.5.0
Theme by Mads Kristensen

About the author

Donn Felker

Senior Consultant
MCTS
ScrumMaster
Agile Practitioner

About Me | Books I Recommend

Gotta Pay The Bills


Tag cloud

    Popular Posts

    RecentComments

    Comment RSS

    Calendar

    <<  January 2009  >>
    MoTuWeThFrSaSu
    2930311234
    567891011
    12131415161718
    19202122232425
    2627282930311
    2345678

    View posts in large calendar