Running LightSpeed under medium trust
Tagged as LightSpeedWe’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”
Leave a Reply
Categories
BrainDump (1)
Community Code (4)
Events (16)
F# (14)
General (53)
Lab Samples (2)
LightSpeed (268)
MegaPack (8)
News (71)
NHibernate Designer (26)
Nightly news (52)
Phone Elements (24)
Products (87)
Projects (5)
Screencast (6)
SharePoint (3)
Silverlight (14)
Silverlight Elements (66)
SimpleDB Management Tools (20)
Visual Studio (9)
VS File Explorer (7)
Web Workbench (39)
WPF (44)
WPF Diagrams (57)
WPF Elements (110)
WPF Property Grid (32)



Posted by Ivan Towlson on 15 February 2009 



Have you been able to get LINQ working under partial trust yet?
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.
Excellent, thank you!