`
wangmengbk
  • 浏览: 288525 次
  • 性别: Icon_minigender_1
  • 来自: 上海
社区版块
存档分类
最新评论

C# 程序执行 报System.Security.SecurityException: 请求失败 方案解决

    博客分类:
  • .net
 
阅读更多
在工作中遇到执行 C# 写的程序 出现以下错误,并解决
其 我的程序是通过 首先映射网络驱动盘 Z,让后有灵一个程序来执行这个 Z 盘程序所出现的错误。
************** 异常文本 **************
System.Security.SecurityException: 请求失败。
   在 System.Security.CodeAccessSecurityEngine.ThrowSecurityException(Assembly asm, PermissionSet granted, PermissionSet refused, RuntimeMethodHandle rmh, SecurityAction action, Object demand, IPermission permThatFailed)
   在 System.Security.CodeAccessSecurityEngine.ThrowSecurityException(Object assemblyOrString, PermissionSet granted, PermissionSet refused, RuntimeMethodHandle rmh, SecurityAction action, Object demand, IPermission permThatFailed)
   在 System.Security.CodeAccessSecurityEngine.CheckSetHelper(PermissionSet grants, PermissionSet refused, PermissionSet demands, RuntimeMethodHandle rmh, Object assemblyOrString, SecurityAction action, Boolean throwException)
   在 System.Security.CodeAccessSecurityEngine.CheckSetHelper(CompressedStack cs, PermissionSet grants, PermissionSet refused, PermissionSet demands, RuntimeMethodHandle rmh, Assembly asm, SecurityAction action)
   在 Iris_2PP.Form1.runBusiness()
   在 Iris_2PP.Form1.connect()
   在 Iris_2PP.Form1.Form1_Load(Object sender, EventArgs e)
   在 System.Windows.Forms.Form.OnLoad(EventArgs e)
   在 System.Windows.Forms.Form.OnCreateControl()
   在 System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
   在 System.Windows.Forms.Control.CreateControl()
   在 System.Windows.Forms.Control.WmShowWindow(Message& m)
   在 System.Windows.Forms.Control.WndProc(Message& m)
   在 System.Windows.Forms.ScrollableControl.WndProc(Message& m)
   在 System.Windows.Forms.ContainerControl.WndProc(Message& m)
   在 System.Windows.Forms.Form.WmShowWindow(Message& m)
   在 System.Windows.Forms.Form.WndProc(Message& m)
   在 System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
   在 System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
   在 System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
失败的操作是:
LinkDemand
失败的第一个权限的类型是:
System.Security.PermissionSet
失败的程序集的区域是:
Intranet

图示效果:




分析: 造成该原因的一种是用户使用 域账号登陆的,起.net framework 没有将权限放开。
解决: 计算机 开始--》运行——> 输入以下命令 即可
cd c:\windows\Microsoft.NET\Framework\v2.0.50727
caspol -polchgprompt off -chggroup 1.2 FullTrust
caspol -polchgprompt off -chggroup 1.3 FullTrust
caspol -polchggrompt off -chggroup 1   FullTrust
通过上面程序就将.net framework 权限放开.具体关于.net framework 安全权限策略问题可以参考 http://wenku.baidu.com/view/6e4cd05abe23482fb4da4c91.html
  • 大小: 12.1 KB
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics