2009-12-29 113 views
1

在我的web應用程序中將Spring.NET 1.2升級到1.3後出現異常。這是我的網絡應用程序的設置:IIS 7.5上沒有共享文件夾的安全異常

我創建了一個應用程序池,其標識設置爲ApplicationPoolIdentity。我使用NHibernate 2.1,我的SQL Server 2008是本地的,我正在使用SQL Server身份驗證。沒有網絡或共享文件夾。一切都是本地的。

現在奇怪的是,如果我在IIS中將我的應用程序池的身份更改爲NetworkService,它開始正常工作。我想知道將Application Pool的標識設置爲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 --- 
+0

「我用NHibernate的2.1」難道是2.1.2.4000版本? – BennyM 2010-01-13 14:59:14

+0

是的,它是相同的版本。 – 2010-01-13 21:37:59

回答

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