开发者

Loading user control in Medium Trust environment

I 开发者_开发问答am trying to load a user control dynamically using this code:

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

I get the following error on the above line when the trust level is Medium:

 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)...

Is it really not possible to load a user control dynamically in a Medium Trust environment?

Edit: Putting DLL in GAC is also not allowed.

Thanks in advance!


If you sign the DLL and place it in the GAC, it may work.

Although there is probably a better way to do it.


Its surely supported in medium trust. I think there is some other problem. i have used it many times

eg:

UserControl ctl = Page.LoadControl("~/COntrols/Control.ascx") as UserControl;

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜