How to run XPO in hosting environment with some CAS restrictions?

Tuesday, January 29th, 2008 | How To, Snippets

Here’s the small code snippet on enabling/disabling some XPO features depending on the hosting environment. Just plug it in your kernel initialization routine and you should be fine.

try
{
   new ReflectionPermission( ReflectionPermissionFlag.ReflectionEmit).Demand();
   new SecurityPermission( SecurityPermissionFlag.ControlEvidence).Demand();
}
catch (SecurityException)
{
   XpoDefault.UseFastAccessors = false;
}

Update: If you use data caching, then you might need to manually set the XPO cache size for your DataCacheNode instances (otherwise XPO will attempt to detect it automatically via the code that cannot run under the Medium Trust). Here’s the sample code snippet:

if (manualCacheSizeMb > 0)
{
   node.TotalMemoryPurgeTreshhold = 0;
   node.TotalMemoryNotPurgeTreshhold = manualCacheSizeMb*1024*1024;
}

So far these are the only CAS-related problems that were encountered while deploying current xLim 2 implementation (Server+WebUI) on the CrystalTech accounts.

Tags:

No comments yet.

Leave a comment

RSS

Search

Archives