【问题标题】:(Fluent) NHibernate Security Exception - ReflectionPermission(Fluent) NHibernate 安全异常 - ReflectionPermission
【发布时间】:2011-02-06 16:38:27
【问题描述】:

我已将 ASP.Net Web 应用程序升级到 Fluent NHibernate (1.0.0.636) 的最新版本和 NHibernate 的最新版本 (v2.1.2.4000)。我已经检查了几次该应用程序以完全信任的方式运行。但我不断收到以下错误:

Security Exception
Description: The application attempted to perform an operation not allowed by the security policy.  To grant this application the required permission please contact your system administrator or change the application's trust level in the configuration file.

Exception Details: System.Security.SecurityException: Request for the permission of type 'System.Security.Permissions.ReflectionPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:

[SecurityException: Request for the permission of type 'System.Security.Permissions.ReflectionPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.]
   System.Security.CodeAccessSecurityEngine.Check(Object demand, StackCrawlMark& stackMark, Boolean isPermSet) +0
   System.Security.CodeAccessPermission.Demand() +54
   System.Reflection.Emit.DynamicMethod.PerformSecurityCheck(Type owner, StackCrawlMark& stackMark, Boolean skipVisibility) +269
   System.Reflection.Emit.DynamicMethod..ctor(String name, Type returnType, Type[] parameterTypes, Type owner, Boolean skipVisibility) +81
   NHibernate.Bytecode.Lightweight.ReflectionOptimizer.CreateDynamicMethod(Type returnType, Type[] argumentTypes) +165
   NHibernate.Bytecode.Lightweight.ReflectionOptimizer.GenerateGetPropertyValuesMethod(IGetter[] getters) +383
   NHibernate.Bytecode.Lightweight.ReflectionOptimizer..ctor(Type mappedType, IGetter[] getters, ISetter[] setters) +108
   NHibernate.Bytecode.Lightweight.BytecodeProviderImpl.GetReflectionOptimizer(Type mappedClass, IGetter[] getters, ISetter[] setters) +52
   NHibernate.Tuple.Component.PocoComponentTuplizer..ctor(Component component) +231
   NHibernate.Tuple.Component.ComponentEntityModeToTuplizerMapping..ctor(Component component) +420
   NHibernate.Tuple.Component.ComponentMetamodel..ctor(Component component) +402
   NHibernate.Mapping.Component.BuildType() +38
   NHibernate.Mapping.Component.get_Type() +32
   NHibernate.Mapping.SimpleValue.IsValid(IMapping mapping) +39
   NHibernate.Mapping.RootClass.Validate(IMapping mapping) +61
   NHibernate.Cfg.Configuration.ValidateEntities() +220
   NHibernate.Cfg.Configuration.Validate() +16
   NHibernate.Cfg.Configuration.BuildSessionFactory() +39
   FluentNHibernate.Cfg.FluentConfiguration.BuildSessionFactory() in d:\Builds\FluentNH\src\FluentNHibernate\Cfg\FluentConfiguration.cs:93

有人遇到过类似的错误吗?我搜索了 web / stackoverflow / NHibernate 论坛,但只发现在中等信任模式下运行时出现问题的人,而不是完全信任。 我已经在这台机器上使用以前版本的 Fluent NHibernate 和 NHibernate 开发这个应用程序几个月了。

我运行它的机器是 64 位的,你永远不知道这是相关的。

【问题讨论】:

    标签: c# asp.net nhibernate securityexception


    【解决方案1】:

    当您第一次下载新的 DLL 时,您可能会遇到此问题,这可能与您的问题不同(任何使其不受信任的东西都会导致相同的错误),但它不止一次地导致了确切的错误。以下是如何让它再次像您的应用程序的其余部分一样在完全信任的情况下运行:

    • 右键单击新的 nHibernate DLL(可能必须一次执行 1 个,不确定)
    • 属性
    • 常规标签的最底部,您可能会看到一条消息:“此文件来自另一台计算机,可能会被阻止以帮助保护这台计算机”。
    • 点击旁边的Unblock

    【讨论】:

    • 那是正确的,非常感谢!我以前从未见过“取消阻止”选项。
    猜你喜欢
    • 2011-02-10
    • 1970-01-01
    • 2011-02-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-07-11
    • 2013-11-22
    相关资源
    最近更新 更多