2010-04-11 57 views
2

我已经升级了一个ASP.Net Web应用程序到最新版本的Fluent NHibernate(1.0.0.636)和最新版本的NHibernate(v2.1.2.4000)。我检查了几次,应用程序运行在完全信任状态。但我不断收到以下错误:(流利)NHibernate安全例外 - ReflectionPermission

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论坛,但只发现在中等信任模式下运行时遇到问题的人员,而不是完全信任的人员。 我一直在这个应用程序上开发几个月的这个应用程序与以前版本的流利NHibernate和NHibernate。

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

回答

7

当你第一次下载一个新的DLL时,你可能会遇到这个问题,它可能不是你的同一个问题(任何使它不受信任的问题都会导致相同的错误),但是,它不止一次地给我造成了确切的错误。以下是如何得到它在完全信任运行像你的应用程序的其余部分再次:

  • 右键单击新NHibernate的DLL文件(可能在同一时间做这个1,不知道)
  • 属性
  • 常规选项卡的最底部,您可能会看到一条消息:“此文件来自另一台计算机,可能被阻止以帮助保护此计算机”。
  • 点击阻止
+0

这是在现场旁边,非常感谢!我以前从未见过'解锁'选项。 – 2010-04-12 06:23:15