private static bool IsHighlyTrusted() { try { var permission = new AspNetHostingPermission(AspNetHostingPermissionLevel.High); permission.Demand(); return true; } catch (SecurityException) { return false; } }