I have done some further research and work into the medium trust issues for all the users who want to use nhibernate in a hosted environment:
I still haven't got it working but here are the steps I worked through to get to this point:
1. Added <trust level="Medium" originUrl="" /> to my webconfig so I could test what was going wrong on my hosting enviroment.
1. I downloaded the SVN version of Nhibernate from the source forge repository the added the Nhibernate 2.0 project and the Iesi.Collections project to my application solution. I told the Hibernate project to reference the Iesi.Collection project rather than the precompiled version.
2. Added the [assembly: AllowPartiallyTrustedCallers] attriubte to the AssemblyInfo.cs (and added a refrence to using System.Security;) on both the Nhibernate project and the Iesi collection project.
This removed the not allowing partial trust issues.
3. Added the
<add key="hibernate.use_reflection_optimizer" value="false" />
To my HBM config i think this removes some of the need for reflection (which isn't allowed on Medium trust hosts)
The Error I’m stuck at now is:
Request for the permission of type 'System.Security.Permissions.SecurityPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.
From what I can tell this is a generic error making it hard to work out what the issue is.
Stack Trace:
at System.Security.CodeAccessSecurityEngine.ThrowSecurityException(Assembly asm, PermissionSet granted, PermissionSet refused, RuntimeMethodHandle rmh, SecurityAction action, Object demand, IPermission permThatFailed)\r\n at System.Security.CodeAccessSecurityEngine.ThrowSecurityException(Object assemblyOrString, PermissionSet granted, PermissionSet refused, RuntimeMethodHandle rmh, SecurityAction action, Object demand, IPermission permThatFailed)\r\n at System.Security.CodeAccessSecurityEngine.CheckSetHelper(PermissionSet grants, PermissionSet refused, PermissionSet demands, RuntimeMethodHandle rmh, Object assemblyOrString, SecurityAction action, Boolean throwException)\r\n at System.Security.CodeAccessSecurityEngine.CheckSetHelper(CompressedStack cs, PermissionSet grants, PermissionSet refused, PermissionSet demands, RuntimeMethodHandle rmh, Assembly asm, SecurityAction action)\r\n at Linked.Data.NHibernateSessionManager.get_threadTransaction()\r\n at Linked.Data.NHibernateSessionManager.CommitTransaction()\r\n at Linked.Web.NHibernateSessionModule.EndTransaction(Object sender, EventArgs e)\r\n at System.Web.HttpApplication.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()\r\n at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)"
Any idea where I have gone wrong? Would be great to get this working in a medium trust environment i can think of several projects I could use it on :)
Thanks
A
|