views:

241

answers:

1

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

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
alex