没有共享文件夹的 IIS 7.5 上的安全异常

发布于 2024-08-15 21:08:34 字数 2656 浏览 4 评论 0原文

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

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

现在奇怪的是,如果我将 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 ---

I get an exception after upgrading Spring.NET 1.2 to 1.3 in my web application. Here's the setup on my web app:

I created an application pool with its identity set to ApplicationPoolIdentity. I use NHibernate 2.1, my SQL Server 2008 is local and I'm using SQL server authentication. There's no network or shared folder. Everything is local.

Now the weird thing is that if I change identity of my application pool in IIS to NetworkService, it starts working fine. I wonder what is the problem with setting the identity of my application pool to ApplicationPoolIdentity.

Here's the exception:

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 ---

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

风为裳 2024-08-22 21:08:34

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

IIS is trying to load and execute the assembly from the address: file:///D:/Projects/MyProject/bin/NHibernate.DLL.

Executing this will solve those permission issues within that machine:

C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\caspol.exe -addgroup 1.2 -url
"file:///D:/Projects/MyProject/bin/*" FullTrust
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文