2010-03-23 89 views
1

以下是錯誤:NHibernate的WCF休息IIS7與安全異常失敗

System.TypeInitializationException: The type initializer for 'NHibernate.Cfg.Environment' threw an exception. 

---> System.Security.SecurityException: Request for ConfigurationPermission failed while attempting to access configuration section 'hibernate-configuration'. To allow all callers to access the data for this section, set section attribute 'requirePermission' equal 'false' in the configuration file where this section is declared. 

---> System.Security.SecurityException: Request for the permission of type 'System.Configuration.ConfigurationPermission, System.Configuration, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' failed. 
     at System.Security.CodeAccessSecurityEngine.Check(Object demand, StackCrawlMark& stackMark, Boolean isPermSet) 
     at System.Security.CodeAccessPermission.Demand() 
     at System.Configuration.BaseConfigurationRecord.CheckPermissionAllowed(String configKey, Boolean requirePermission, Boolean isTrustedWithoutAptca) 

我們必須設置爲完全信任級別。還要注意,我們也有一個運行相同Nhibernate代碼的網站,並且沒有問題。只有WCF REst Web服務應用程序有此錯誤?

任何有關爲什麼這是一個問題的想法?

+0

這個異常是否告訴解決方案:在hibernate-configuration部分中設置requirePermission爲false? – Paco 2010-03-23 20:26:35

+0

不......這樣做只是將錯誤推送到加載映射文件的另一塊nhibernate上。看到我的答案在下面,它修復了它 – RyanFetz 2010-03-24 16:38:58

回答