System.Net.WebPermission 4.0框架问题 [英] System.Net.WebPermission 4.0 framework issue

查看:69
本文介绍了System.Net.WebPermission 4.0框架问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在项目中将.net框架工作从3.5更改为4.0时,System.Net.WebPermission对象现在抛出异常。它似乎发生在Assert()方法上。我粘贴了下面的所有常规。当它在3.5中重新编译时,它像往常一样工作。

我在MSDN上的4.0库中找不到任何文档,如果它移动了,程序在用4.0编译时是否会缺少引用?





WebPermission myWebPermission =

新的WebPermission(System.Security.Permissions.PermissionState.Unrestricted); < br $>


myWebPermission.Demand();

myWebPermission.Assert();



ex message

无法在安全透明方法中执行CAS断言



- 当前

'(myWebPermission.ConnectList )。当前'

抛出了'System.InvalidOperationException'类型的异常

object {System.InvalidOperationException}



枚举尚未开始。调用MoveNext。

While changing the .net frame work from 3.5 to 4.0 on a project the System.Net.WebPermission object is now throwing exceptions. It appears to happen on the Assert() method. I pasted all the usuals below. When it's recompiled in 3.5 it works as usual.
I can not find any documentation in the 4.0 library on MSDN, has it moved, could the program be missing a reference when compiled with 4.0?


WebPermission myWebPermission =
new WebPermission(System.Security.Permissions.PermissionState.Unrestricted);

myWebPermission.Demand();
myWebPermission.Assert();

ex message
Cannot perform CAS Asserts in Security Transparent methods

- Current
'(myWebPermission.ConnectList).Current'
threw an exception of type 'System.InvalidOperationException'
object {System.InvalidOperationException}

"Enumeration has not started. Call MoveNext."

推荐答案

本文:

。NET 4安全 - 透明与关键:如何使用AppDom ain.SetData在一个中等受信任的应用程序上? [ ^ ]

使用.NET& amp; ASP.NET 4安全实现。



您可以在受限安全模式下运行IIS站点,这会阻止您使用 System.Security .Permissions.PermissionState.Unrestricted 你想要的。



希望这有帮助。
This article:
.NET 4 Security - Transparent vs Critical: How to use AppDomain.SetData on a Medium Trusted App?[^]
enlights new security aspects with .NET & ASP.NET 4 security implementation.

You may run your IIS site in a restricted security mode, which prevents you from using the System.Security.Permissions.PermissionState.Unrestricted that you want to.

Hope this helps.


这篇关于System.Net.WebPermission 4.0框架问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆