代码之家  ›  专栏  ›  技术社区  ›  Vijay

在中等信任环境中加载用户控件

  •  2
  • Vijay  · 技术社区  · 16 年前

    我正在尝试使用以下代码动态加载用户控件:

    UserControl homePageContent = Page.LoadControl(userControlPath) as UserControl;
    

    中等

     System.Security.SecurityException: Request failed. 
     at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandle& ctor, Boolean& bNeedSecurityCheck)
     at System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean fillCache)...
    

    在中等信任环境中,是否真的不可能动态加载用户控件?

    也不允许将DLL放入GAC中。

    提前谢谢!

    2 回复  |  直到 16 年前
        1
  •  0
  •   Shiraz Bhaiji    16 年前

    如果对DLL进行签名并将其放在GAC中,它可能会工作。

        2
  •  0
  •   Priyan R    16 年前

    它肯定得到了中等信任度的支持。我想还有别的问题。我用过很多次了

    UserControl ctl=Page.LoadControl(“~/COntrols/Control.ascx”)作为UserControl;

    推荐文章