Home » Blog

rounded header

Running LightSpeed under medium trust

tag icon Tagged as LightSpeed

We’ve had some feedback recently about LightSpeed not running in medium trust, specifically hosted ASP.NET environments, so I’m pleased to announce some recent improvements in this area.

The main problem with running in medium trust has always been the way we get data into and out of entities. The technique we use is extremely fast, but requires permissions that aren’t allowed in medium trust.

So in future nightly builds we’re providing an option to fall back to a method that requires fewer privileges. You can choose this by setting the new LightSpeedContext.UseMediumTrustCompatibility flag:

LightSpeedContext.UseMediumTrustCompatibility = true;

(Notice that this is a static setting, not on a per-context basis.) The downside of setting this flag is that the “safe” method is a bit slower than the default method, so if your target deployment platform is medium trust then make sure you do your performance testing in medium trust.

Medium trust also imposes a couple of stylistic restrictions on the way you define your entities:

1. All fields must be declared read-write. We usually recommend that special fields such as DeletedOn or LockVersion, and value object fields, be declared readonly to prevent user code changing them, but in a medium trust environment that prevents LightSpeed from initialising them as it needs to. (By default the designer follows the recommended practice. If you want to use the designer, and your entities use Optimistic Concurrency Checking, Soft Delete, Track Create Time or Track Update Time, or your model contains value objects, you must set Medium Trust Compatibility at the model level.)

2. When implementing property setters, you must call the Set overload which takes the property name: that is, call Set(TField, TField, string) instead of Set(TField, TField). (The designer does this automatically for you.)

Finally, at present there are a couple of limitations when running in medium trust:

1. We’ve seen some problems during testing with configuration. You may need to set up your LightSpeedContext in code rather than config.

2. You can only use the core LightSpeed API: we don’t yet have LINQ running in medium trust.

We’ll keep you posted as we make further improvements in these areas. In the meantime, if you’re interested in medium trust, grab the latest nightly and give it a go.

3 Responses to “Running LightSpeed under medium trust”

  1. Have you been able to get LINQ working under partial trust yet?

  2. Hi Robert,

    Yes LINQ does work within a medium trust environment now.

    http://www.mindscape.co.nz/forums/Thread.aspx?PostID=6478

    That thread was the last discussion on it and it appeared everything was working happily in the end.

    I hope that helps.

  3. Excellent, thank you!

Leave a Reply

Data Products Visual Controls Community Store
LightSpeed ORM
NHibernate Designer
SimpleDB Tools
SharePoint Tools
WPF Elements
WPF Diagrams
Silverlight Elements
Forums
Blog
Register
Login
Subscribe to newsletter
Buy Now
My Account
Volume Discounts
Purchase Orders
Contact Us