Исключение безопасности с Nhibernate на виртуальном хостинге - PullRequest
1 голос
/ 30 мая 2011

У меня есть веб-сайт, который использует 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 я также установил NHibernate.Cfg.Environment.BytecodeProvider = null;, но это не помогает.

вот URL с подробными настройками доверия моего хоста http://onlinehelp.hostbasket.com/shared-webhosting/scripting/asp-aspnet/1147-why-does-hostbasket-not-support-my-site-in-full-trust.html

1 Ответ

1 голос
/ 30 мая 2011

Если вы пытаетесь настроить среду со средним доверием (поскольку вы используете общего провайдера), проверьте этот существующий ответ SO:

Проблема безопасности с NHibernate в развернутом веб-приложении

В частности, ссылка на вики NHibernate: http://nhforge.org/wikis/howtonh/run-in-medium-trust.aspx

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...