internal static Exception MakeSecurityException(AssemblyName asmName, Evidence asmEvidence, PermissionSet granted, PermissionSet refused, RuntimeMethodHandleInternal rmh, SecurityAction action, object demand, IPermission permThatFailed)
{
HostProtectionPermission protectionPermission = permThatFailed as HostProtectionPermission;
if (protectionPermission != null)
{
return((Exception) new HostProtectionException(SecurityException.GetResString("HostProtection_HostProtection"), HostProtectionPermission.protectedResources, protectionPermission.Resources));
}
string message = "";
MethodInfo method = (MethodInfo)null;
try
{
message = granted != null || refused != null || demand != null ? (demand == null || !(demand is IPermission) ? (permThatFailed == null ? SecurityException.GetResString("Security_GenericNoType") : string.Format((IFormatProvider)CultureInfo.InvariantCulture, SecurityException.GetResString("Security_Generic"), (object)permThatFailed.GetType().AssemblyQualifiedName)) : string.Format((IFormatProvider)CultureInfo.InvariantCulture, SecurityException.GetResString("Security_Generic"), (object)demand.GetType().AssemblyQualifiedName)) : SecurityException.GetResString("Security_NoAPTCA");
method = SecurityRuntime.GetMethodInfo(rmh);
}
catch (Exception ex)
{
if (ex is ThreadAbortException)
{
throw;
}
}
return((Exception) new SecurityException(message, asmName, granted, refused, method, action, demand, permThatFailed, asmEvidence));
}