views:

232

answers:

2

I'm getting the following error after a migration to shared hosting on godaddy.com


[SecurityException: Request failed.] System.Security.CodeAccessSecurityEngine.ThrowSecurityException(Assembly asm, PermissionSet granted, PermissionSet refused, RuntimeMethodHandle rmh, SecurityAction action, Object demand, IPermission permThatFailed) +150 System.Security.CodeAccessSecurityEngine.ThrowSecurityException(Object assemblyOrString, PermissionSet granted, PermissionSet refused, RuntimeMethodHandle rmh, SecurityAction action, Object demand, IPermission permThatFailed) +100 System.Security.CodeAccessSecurityEngine.CheckSetHelper(PermissionSet grants, PermissionSet refused, PermissionSet demands, RuntimeMethodHandle rmh, Object assemblyOrString, SecurityAction action, Boolean throwException) +284 System.Security.PermissionSetTriple.CheckSetDemand(PermissionSet demandSet, PermissionSet& alteredDemandset, RuntimeMethodHandle rmh) +69 System.Security.PermissionListSet.CheckSetDemand(Permiss


The application was built using NHibernate and MVC 1.0 (I assume GoDaddy has support for MVC if I have a copy of System.Web.Mvc in the bin directory ...

To get NHibernate working in med trust I have done the following:

Added "requirePermission = false like so

<section name="hibernate-configuration" requirePermission="false" type="NHibernate.Cfg.Config

Added the reflection opt = false like so

<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">
     <reflection-optimizer use="false"/>
     <session-factory>
      <property name="conne

And finally - altered each *.hbm.xml file to kill lazy loading like so

<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" default-lazy="false">
  <class name="Entit

Anything I'm missing here? For some reason I can't seem to find something I missing ...

Edit

I also added the following to both the MVC project and the class libraries I included (that I compiled - not including NHibernate/etc)

[assembly:AllowPartiallyTrustedCallers]

Update **

After learning this I decided to switch to a host that allowed full trust and so far I'm having good luck with this one.

http://www.hostingfest.com/

The only complaint I have currently is that they are running IIS 6

A: 

This means that if your assembly is not fully trusted, it will be unable to kick off new Processes or get information about running processes.

One instance that you would want to be running without SkipVerification is the case where you're dynamically generating code. Applications which emit code via Reflection.Emit should run without SkipVerification to help to ensure that they're emitting correct code.

original link for more info : http://blogs.msdn.com/shawnfa/archive/2005/12/14/502826.aspx

ali62b
+1  A: 

Toran, Those are pretty much the steps, yes. What method is throwing this security exception ? Also, I suggest not using those steps, but using pre generated proxies, as detailed here http://nhforge.org/wikis/howtonh/pre-generate-lazy-loading-proxies.aspx

Ayende Rahien
Correct - because with the steps above I'm giving up lazy-loading altogether :(
Toran Billups