IIS 7.5上的安全例外,没有共享文件夹

时间:2009-12-29 22:20:51

标签: nhibernate exception iis-7 spring.net

我在Web应用程序中将Spring.NET 1.2升级到1.3后出现异常。这是我的网络应用程序上的设置:

我创建了一个应用程序池,其标识设置为ApplicationPoolIdentity。我使用NHibernate 2.1,我的SQL Server 2008是本地的,我正在使用SQL服务器身份验证。没有网络或共享文件夹。一切都是本地的。

现在奇怪的是,如果我将IIS中的应用程序池的标识更改为NetworkService,它就会正常运行。我想知道将我的应用程序池的标识设置为ApplicationPoolIdentity有什么问题。

以下是例外:

System.Configuration.ConfigurationErrorsException: Error creating context '/project1': That assembly does not allow partially trusted callers. ---> Spring.Objects.Factory.ObjectCreationException: Error thrown by a dependency of object 'MyObj' defined in 'file [D:\Projects\MyProject\Configs\Services.xml] line 37' : Initialization of object failed : Failed to create an instance of 'Spring.Data.NHibernate.Bytecode.ProxyFactoryFactory'!
     while resolving 'Sleepers[0]' to 'CustomerManager' defined in 'file [D:\Projects\MyProject\Configs\Business.xml] line 64'
     while resolving 'CustomerDAO' to 'CustomerDAO' defined in 'file [D:\Projects\MyProject\Configs\Dao.xml] line 50'
     while resolving 'SessionFactory' to 'SessionFactory' defined in 'file [D:\Projects\MyProject\Configs\Dao.xml] line 21' ---> NHibernate.Bytecode.HibernateByteCodeException: Failed to create an instance of 'Spring.Data.NHibernate.Bytecode.ProxyFactoryFactory'! ---> System.Security.SecurityException: That assembly does not allow partially trusted callers.
       at System.Security.CodeAccessSecurityEngine.ThrowSecurityException(Assembly asm, PermissionSet granted, PermissionSet refused, RuntimeMethodHandle rmh, SecurityAction action, Object demand, IPermission permThatFailed)
       at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandle& ctor, Boolean& bNeedSecurityCheck)
       at System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean fillCache)
       at System.RuntimeType.CreateInstanceImpl(Boolean publicOnly, Boolean skipVisibilityChecks, Boolean fillCache)
       at System.Activator.CreateInstance(Type type, Boolean nonPublic)
       at NHibernate.Bytecode.ActivatorObjectsFactory.CreateInstance(Type type)
       at NHibernate.Bytecode.AbstractBytecodeProvider.get_ProxyFactoryFactory()
    The action that failed was:
    LinkDemand
    The assembly or AppDomain that failed was:
    NHibernate, Version=2.1.2.4000, Culture=neutral, PublicKeyToken=aa95f207798dfdb4
    The Zone of the assembly that failed was:
    Internet
    The Url of the assembly that failed was:
    file:///D:/Projects/MyProject/bin/NHibernate.DLL
       --- End of inner exception stack trace ---

1 个答案:

答案 0 :(得分:1)

IIS正在尝试从地址加载并执行程序集:file:///D:/Projects/MyProject/bin/NHibernate.DLL

执行此操作将解决该计算机中的权限问题:

C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\caspol.exe -addgroup 1.2 -url
"file:///D:/Projects/MyProject/bin/*" FullTrust