I've got a website which uses nhibernate, it's located on the shared hosting company.
I already disabled lazy loading trough "NHibernate.Cfg.Atmosphere.UseReflectionOptimizer = false" because reflection is not allow on my small host.
However I've one other issue with nhibernate:
Security Exception Description: The applying tried to perform a surgical procedure not permitted through the security policy. To grant this application the needed permission please speak to your system administrator or alter the application's trust level within the configuration file. Exception Particulars: System.Security.SecurityException: Request unsuccessful. Source Error: An unhandled exception was produced throughout the execution from the current web request. Specifics of the foundation and placement from the exception could be recognized while using exception stack trace below. Stack Trace: [SecurityException: Request unsuccessful.] System.Security.CodeAccessSecurityEngine.ThrowSecurityException(RuntimeAssembly asm, PermissionSet granted, PermissionSet declined, RuntimeMethodHandleInternal rmh, SecurityAction action, Object demand, IPermission permThatFailed) +168 System.Security.CodeAccessSecurityEngine.ThrowSecurityException(Object assemblyOrString, PermissionSet granted, PermissionSet declined, RuntimeMethodHandleInternal rmh, SecurityAction action, Object demand, IPermission permThatFailed) +100 System.Security.CodeAccessSecurityEngine.CheckSetHelper(PermissionSet grants or loans, PermissionSet declined, PermissionSet demands, RuntimeMethodHandleInternal rmh, Object assemblyOrString, SecurityAction action, Boolean throwException) +278 System.Security.PermissionSetTriple.CheckSetDemand(PermissionSet demandSet, PermissionSet&lifier alteredDemandset, RuntimeMethodHandleInternal rmh) +69 System.Security.PermissionListSet.CheckSetDemand(PermissionSet pset, RuntimeMethodHandleInternal rmh) +156 System.Security.PermissionListSet.DemandFlagsOrGrantSet(Int32 flags, PermissionSet grantSet) +33 System.Security.CodeAccessSecurityEngine.ReflectionTargetDemandHelper(Int32 permission, PermissionSet targetGrant, CompressedStack securityContext) +128 System.Security.CodeAccessSecurityEngine.ReflectionTargetDemandHelper(Int32 permission, PermissionSet targetGrant) +54
This error happened each time nhibernate was adopted(for database access). I have downgraded Nhibernate to at least one.2 and today the exception only is tossed for update and remove procedures of objects that have relations declared within the mapping file.
I believe the mistake is triggered by Castle.DynamicProxy.dll. But how do you disable proxies completely? I've set all objects and relations within the mapping on
lazy="false", I have set
within the nhibernate assistant I additionally have set
NHibernate.Cfg.Atmosphere.BytecodeProvider = null but this does not help.
this is a url detailing the trust configurations of my host http://onlinehelp.hostbasket.com/shared-webhosting/scripting/asp-aspnet/1147-why-does-hostbasket-not-support-my-site-in-full-trust.html
If you are trying to setup the atmosphere in medium trust (since you are on the shared provider), read this existing SO answer:
Particularly, the hyperlink to NHibernate's Wiki: http://nhforge.org/wikis/howtonh/run-in-medium-trust.aspx