在项目中将框架工作从3.5更改为4.0时,System.Net.WebPermission对象现在抛出异常。它似乎发生在Assert()方法上。我粘贴了下面的所有常规。当它在3.5中重新编译时,它像往常一样工作。 我在MSDN上的4.0库中找不到任何文档,如果它移动了,程序在用4.0编译时是否会缺少引用? WebPermission myWebPermission = 新的WebPermission(System.Security.Permissions.PermissionState.Unrestricted); myWebPermission.Demand(); myWebPermission.Assert(); ex message 无法在安全透明方法中执行CAS断言 - 当前 '(myWebPermission.ConnectList )。当前' 抛出了'System.InvalidOperationException'类型的异常 object {System.InvalidOperationException} 枚举尚未开始。调用MoveNext。
While changing the 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框架问题
发布评论