SecurityException: Request failed in LoadControl -
12-14-2006
, 05:52 AM
Hi,
I have a web part which dynamicaly loads an ascx control. If I
configure my sharepoint for full trust, everything works fine. Using
other security settings, I get the following exception:
[SecurityException: Request failed.]
System.Reflection.MethodBase.PerformSecurityCheck( Object obj,
RuntimeMethodHandle method, IntPtr parent, UInt32 invocationFlags) +0
System.RuntimeType.CreateInstanceImpl(Boolean publicOnly, Boolean
skipVisibilityChecks, Boolean fillCache) +189
System.Activator.CreateInstance(Type type, Boolean nonPublic) +66
System.RuntimeType.CreateInstanceImpl(BindingFlags bindingAttr,
Binder binder, Object[] args, CultureInfo culture, Object[]
activationAttributes) +1036
System.Activator.CreateInstance(Type type, BindingFlags bindingAttr,
Binder binder, Object[] args, CultureInfo culture, Object[]
activationAttributes) +114
System.Web.HttpRuntime.CreateNonPublicInstance(Typ e type, Object[]
args) +40
System.Web.Configuration.PagesSection.CreateContro lTypeFilter()
+3368024
System.Web.UI.TemplateParser.ProcessConfigSettings () +179
System.Web.UI.TemplateControlParser.ProcessConfigS ettings() +15
System.Web.UI.UserControlParser.ProcessConfigSetti ngs() +9
System.Web.UI.TemplateParser.PrepareParse() +415
System.Web.UI.TemplateParser.Parse() +155
System.Web.Compilation.BaseTemplateBuildProvider.g et_CodeCompilerType()
+105
System.Web.Compilation.BuildProvider.GetCompilerTy peFromBuildProvider(BuildProvider
buildProvider) +54
System.Web.Compilation.BuildProvidersCompiler.Proc essBuildProviders()
+256
System.Web.Compilation.BuildProvidersCompiler.Perf ormBuild() +29
System.Web.Compilation.BuildManager.CompileWebFile (VirtualPath
virtualPath) +279
System.Web.Compilation.BuildManager.GetVPathBuildR esultInternal(VirtualPath
virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean
allowBuildInPrecompile) +580
System.Web.Compilation.BuildManager.GetVPathBuildR esultWithNoAssert(HttpContext
context, VirtualPath virtualPath, Boolean noBuild, Boolean
allowCrossApp, Boolean allowBuildInPrecompile) +93
System.Web.UI.TemplateControl.LoadControl(VirtualP ath virtualPath)
+76
System.Web.UI.TemplateControl.LoadControl(String virtualPath) +23
Using Reflector for .Net, I can look into CreateInstanceImpl and see a
check like this:
if (entry1.m_ctor != null)
{
if (!skipVisibilityChecks && entry1.m_bNeedSecurityCheck)
{
MethodBase.PerformSecurityCheck(obj1, entry1.m_hCtorMethodHandle,
this.TypeHandle.Value, 0x10000000);
}
}
Any hint why this check could fail or how to figure out what's the
reason is? I'm working on a custom trust file but have no idea what
permission my code might be missing.
regards,
Achim |