Tag: code access security

System.MethodAccessException,CAS和Visual Studio调试器

我正在调用ModelMetadataProviders.Current.GetMetadataForProperties来使用Visual Studio 2010获取WPF应用程序中的ModelMetadata列表。此调用执行正常,我得到IEnumerable 作为回报。 在代码行,我尝试迭代这个,我得到System.MethodAccessException。 有趣的是,只有在我使用F5进行调试时才会发生这种情况。 如果我用Ctrl + F5运行代码,那么我不会得到这个exception,代码工作正常。 如果我从Windows资源管理器运行exe,它运行正常。 当然,我错过了一些东西。 可能是,System.Web.Mvc无法从WPF应用程序中使用? (为什么)有关visual studio调试器的东西吗? 任何帮助将不胜感激。 这是完整的例外: 尝试通过安全透明方法’System.Web.Mvc.TypeDescriptorHelper.Get(System.Type)’来访问安全关键方法’System.ComponentModel.DataAnnotations.AssociatedMetadataTypeTypeDescriptionProvider..ctor(System.Type)’失败。 程序集’System.ComponentModel.DataAnnotations,Version = 4.0.0.0,Culture = neutral,PublicKeyToken = 31bf3856ad364e35’是有条件的APTCA程序集,在当前的AppDomain中未启用。 为了使该组件由部分信任或安全性的透明的代码中使用,请在创建应用程序域时添加组件名称“System.ComponentModel.DataAnnotations,公钥= 0024000004800000940000000602000000240000525341310004000001000100B5FC90E7027F67871E773A8FDE8938C81DD402BA65B9201D60593E96C492651E889CC13F1415EBB53FAC1131AE0BD333C5EE6021672D9718EA31A8AEBD0DA0072F25D87DBA6FC90FFD598ED4DA35E44C398C454307E8E33B8426143DAEC9F596836F97C8F74750E5975C64E2189F45DEF46B2A2B1247ADC3652BF5C308055DA9”到的PartialTrustVisibleAssemblies列表。

自定义CodeAccessSecurityAttribute

我创建了以下属性: [Serializable] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, AllowMultiple = true, Inherited = true)] public class OperationPermissionAttribute : CodeAccessSecurityAttribute { private static PrincipalPermission _revoke = new PrincipalPermission(PermissionState.None); private static PrincipalPermission _allow = new PrincipalPermission(PermissionState.Unrestricted); private string _role; private string _task; private string _operation; public OperationPermissionAttribute(SecurityAction action, string role, string task, string operation) : base(action) { _role = role; […]

SecurityAttribute.Unrestricted问题

我对此属性感到困惑,如此处所述, http://msdn.microsoft.com/en-us/library/system.security.permissions.securityattribute.unrestricted.aspx我们可以将其全部或非完整。 我的困惑是直接理解的许可,应该只有两个状态 – 授予和不授予,完整和非完整意味着什么?