我有一个使用nhibernate的网站,它托管在一个共享的网络主机上。
我已经通过"NHibernate.Cfg.Environment.UseReflectionOptimizer =false禁用了延迟加载“,因为我的主机上不允许反射。
但是现在我对nhibernate有了另一个问题:
Security Exception
Description: The application attempted to perform an operation not allowed by the security policy. To grant this application the required permission please contact your system administrator or change the application's trust level in the configuration file.
Exception Details: System.Security.SecurityException: Request failed.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace:
[SecurityException: Request failed.]
System.Security.CodeAccessSecurityEngine.ThrowSecurityException(RuntimeAssembly asm, PermissionSet granted, PermissionSet refused, RuntimeMethodHandleInternal rmh, SecurityAction action, Object demand, IPermission permThatFailed) +168
System.Security.CodeAccessSecurityEngine.ThrowSecurityException(Object assemblyOrString, PermissionSet granted, PermissionSet refused, RuntimeMethodHandleInternal rmh, SecurityAction action, Object demand, IPermission permThatFailed) +100
System.Security.CodeAccessSecurityEngine.CheckSetHelper(PermissionSet grants, PermissionSet refused, PermissionSet demands, RuntimeMethodHandleInternal rmh, Object assemblyOrString, SecurityAction action, Boolean throwException) +278
System.Security.PermissionSetTriple.CheckSetDemand(PermissionSet demandSet, PermissionSet& 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每次使用nhibernate (用于数据库访问)时都会发生此错误。我已经将Nhibernate降级到1.2,现在只有在映射文件中声明了关系的对象的更新和删除操作才会抛出异常。
我认为这个错误是由Castle.DynamicProxy.dll引起的。但是如何完全禁用代理呢?我已经在lazy="false"上设置了映射中的所有对象和关系,我已经设置了default-lazy="false"
在nhibernate helper中,我也设置了NHibernate.Cfg.Environment.BytecodeProvider = null;,但这没有帮助。
以下是我的主机http://onlinehelp.hostbasket.com/shared-webhosting/scripting/asp-aspnet/1147-why-does-hostbasket-not-support-my-site-in-full-trust.html的信任设置的详细url
发布于 2011-05-30 22:46:45
如果您尝试在中等信任中设置环境(因为您使用的是共享提供程序),请查看现有的SO答案:
"Security" problem with NHibernate on deployed web application
具体来说,指向NHibernate的维基的链接:http://nhforge.org/wikis/howtonh/run-in-medium-trust.aspx
https://stackoverflow.com/questions/6176621
复制相似问题