2010-04-11 35 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