WCF休息IIS7因安全异常而失败

WCF休息IIS7因安全异常而失败

本文介绍了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)

我们将信任级别设置为Full。另请注意,我们还有一个运行SAME Nhibernate代码的网站,没有任何问题。只有WCF REst Web服务应用程序出现此错误?

We have the trust level set to Full. Note also that we also have a web site that runs the SAME Nhibernate code and has NO issues. Only the WCF REst Web Service Application has this error?

关于为什么这是一个问题的任何想法?

Any Thoughts as to WHY this is a problem?

推荐答案

将应用程序池的标识从ApplicationPoolIdentity更改为NetworkService,并在文件系统文件夹中为NetworkService帐户提供修改权限。

change the Identity of the app pool from "ApplicationPoolIdentity" to "NetworkService" and give "NetworkService" account "modify" permissons on the file system folder.

这篇关于NHibernate WCF休息IIS7因安全异常而失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-04 02:01