Many shared hosting providers (in this case Mosso) run your ASP.NET applications in a medium trust or modified medium trust environment to reduce security risks. This causes issues with certain techniques and components that require permissions removed by medium trust.

One of the biggest issues other than the actual restriction of permissions is the restriction of partially trusted assemblies calling fully trusted code. By default, if an assembly is strong named, partially trusted assemblies (i.e. the application assemblies in your app running under medium/partial trust) can't call it. This hits many open source components such as iBatis and NHibernate. The workaround to this is to add the AllowPartiallyTrustedCallers assembly level attribute. This will mark the assembly as safe for calling by partially trusted assemblies.

Here is an example of how to modify iBatis to support this:

  1. Download the iBatis source from the iBatis website:
  2. Extract the source .zip to a folder
  3. Open the IBatisNet.2005.sln solution in VS.NET
  4. For each project in the solution, open it's AssemblyInfo.cs file
    1. Add this using statement at the top of the file: "using System.Security;"
    2. Add this attribute at the bottom of the file: "[assembly: AllowPartiallyTrustedCallers]"
  5. Right click on the solution and select "Configuration Manager..."
  6. In the "Active solution configuration" dropdown, select Release
  7. Uncheck all of the Test projects
  8. Click OK
  9. Build the solution

Or you can download the compiled assemblies:

Enabling NHibernate for medium/partial trust is a similar procedure. If there is enough demand I will present steps and compiled assemblies for it as well.

As for the permission restrictions, most shared hosting providers don't actually run in medium trust as this restricts many useful things such as Reflection etc. One example I've run into recently is Mosso's modified medium trust. They take medium trust, which consists of the following denied permission restrictions:

  • Call unmanaged code.
  • Call serviced components.
  • Write to the event log.
  • Access Microsoft Message Queuing queues.
  • Access ODBC, OleDb, or Oracle data sources.
  • Access files outside the application directory.
  • Access the registry.
  • Make network or Web service calls (using the System.Net.HttpWebRequest class, for example).

And then Mosso adds back in the following allowed permission to come up with "modified medium trust":

  • WebPermission Unrestricted="true"
  • OleDbPermission Unrestricted="true"
  • OdbcPermission Unrestricted="true"
  • SocketPermission Unrestricted="true"
  • ConfigurationPermission Unrestricted="true"
  • ReflectionPermission Unrestricted="true"

This is still rather limiting, but at least you can get most things done as long as you can call into the necessary assemblies without getting exceptions as discussed in the workaround section above.

I was working on one of my old laptops the other day, and realized it seemed just as fast as my newer laptop. The newer box is substantially higher specced - dual core proc, 4GB RAM, nVidia graphics etc. For awhile, I couldn't put my finger on just what the difference was, and then it hit me: the old laptop had Aero turned off. I turned off Aero on the new box and bam, it was noticably more snappy. Windows popped in instantly, menus snapped up with no hesitation. Not just a little improvement, but a drastic improvement in speed. You don't get the glitzy glass interface, but it's definitely worth the graphical loss to have a much faster experience.

I haven't tested this on beefier desktop systems, but it gives a great improvement on laptops.

Here are the steps:

  • Open the computer settings window (quickest way to do this is to right click on "My Computer" and select "Properties").
  • Click "Advanced system settings" on the left under Tasks
  • Go to the Advanced tab
  • Click the Settings button under the Performance item
  • On the Visual Effects tab, Select "Adjust for best performance"

This will optimize the visual effects for the best performance, but some important visual effects will be missing - especially font smoothing. To get to the optimal settings, check the following items in the list:

  • Show preview and filters in folder
  • Show thumbnails instead of icons
  • Show window contents while dragging
  • Smooth edges of screen fonts
  • Smooth-scroll list boxes

The resulting selection will look like this:

Click the OK button, and Windows will recalibrate itself for the new settings.

Enjoy the new snappier performance!

This was originally going to be a comment on Tynan's post Just Doing It, but it developed into something longer so I decided to do a full blown post here.

I totally agree about the doing without thinking and emotion concept. Just do it. It's a matter of focus and drive. Its not something you're born with, its a skill you develop. Make a goal and outline the steps it takes to get there. Then its simple -- just follow the steps you laid out for yourself.

The key for me is the second step -- making a list of things that need to be done to achieve the goal. Without a list, you can get to nebulous states where you don't really know what to do, don't feel like thinking about what to do, and just end up not doing anything at all. If you keep track of everything that you have to do in detailed lists, you always have something to do. Even if you're not feeling creative, just pick a simple item off the list and do it. Check it off. Once you do one item, more often than not I've found you want to do another. And another. And then you're back in the groove, kicking ass.

I've never been a meticulous kind of person that would keep lists of everything. I'd always prefer to list stuff in my head. I've found that its so valuable, its worth the time to create lists. It keeps you focused on what you're doing, instead of trying to remember stuff you need to do. Everything is all in a list so your brain doesn't have to expend effort subconsciously remembering future tasks.

This is the one recommendation I have: Make a goal and lists the steps to get it done. Then do it. If you've seen me on messenger, you'll know my tagline recently has been (as Yoda said), "Do or do not. There is no try." This is the attitude that breeds success.

UPDATE: Added support for importing tracked forums and topics.

I'm in the process of converting my forums from Community Server to AspNetForum. While CS may support every single feature under the sun, its very big and unwieldly to work with. The more recent 2007 and 2008 versions are better, but still behemoth. I just want to drop in one simple forum with a couple subgroups, not host a million forums and blogs on my site. For this, AspNetForum fits the bill exactly.

There's no official importer for Community Server to AspNetForum, so I wrote my own. It turns out to be fairly simple. Just a SQL script will do it. Here are the steps the script goes through:

  1. Import the ASP.NET application, user, and membership tables
  2. Create the AspNetForum single sign-on linkages in its ForumUsers table
  3. Import the groups, forums, topics, and messages

I packaged all this up into a SQL script that handles the whole process end to end. Just edit it to point to your database and forums and it will do the rest. It assumes the following:

  • You've created and set up an AspNetForum database
  • You've created the ASP.NET user and membership tables in the AspNetForum database
  • The AspNetForum and ASP.NET user and membership tables are new and empty

This script will import everything with the same ID values from Community Server, making mapping or redirecting easy.

To use the script in SQL Management Studio, do the following steps:

  1. Open the script (Import.sql) and connect it to your AspNetForum database
  2. Execute a search and replace operation that replaces "CSDatabaseName" with the name of your Community Server database
  3. Set the @applicationId variable to the ApplicationId matching your Community Server instance in the aspnet_Applications table in your CS database
  4. Set the @groupId variable to the GroupId of the forum group to import from the cs_Groups table
  5. Execute the script

Download the script and get importing! –