-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 
Author Message
 Post subject: NHibernate and trust mode
PostPosted: Tue Feb 27, 2007 6:48 am 
Newbie

Joined: Tue Feb 27, 2007 6:40 am
Posts: 2
Hibernate version: 1.0.2

I have just uploaded my application to my hosting provider and got the following error.

"System.Security.SecurityException: That assembly does not allow partially trusted callers."

After investigation it appears the problem lies with NHibernate and that it will only work in "Full Trust" mode.

Has anybody else experienced this problem and gotten around it?

btw: my hosting provider only allow medium trust


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 27, 2007 7:33 am 
Contributor
Contributor

Joined: Wed May 11, 2005 4:59 pm
Posts: 1766
Location: Prague, Czech Republic
You can recompile NH to add AllowPartiallyTrustedCallersAttribute to it. The soon-to-be-stable version of NHibernate (1.2.0.CR1) has the attribute set and includes an example that works under medium trust.

Note that proxies (lazy loading) do not work under medium trust in either version because DynamicProxy doesn't support it.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 27, 2007 10:25 am 
Regular
Regular

Joined: Tue Mar 15, 2005 12:38 pm
Posts: 73
Location: Bucharest
Sergey,

I know it's a rather long shot, but a solution may be to generate the proxy assembly at design time using a custom tool and then instruct NH to use the proxies from a given dll using a custom naming policy.

Eg. when a proxy is needed for
Code:
MyNamespace.MyEntity, MyNamespace
automatically search for proxy
Code:
NHProxy.MyNamespace.MyEntity_NHProxy from NHProxy.MyNamespace assembly


Another idea would be to create a tool that takes as input a set of DLLs and that creates the proxies automatically, and this tool can than be use with setups.

What do you think, does this deserve any attention ?

_________________
Dragos


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 27, 2007 10:29 am 
Contributor
Contributor

Joined: Wed May 11, 2005 4:59 pm
Posts: 1766
Location: Prague, Czech Republic
Yes, this could be a solution.


Top
 Profile  
 
 Post subject: NHibernate and Medium trust
PostPosted: Sat Mar 21, 2009 9:48 pm 
Newbie

Joined: Sat Mar 21, 2009 6:21 pm
Posts: 2
Hi,

I also had the problem making NHibernate work with medium trust and this is what I did:

First..you need some sort of hosting that allows reflection in your server...There are some like crystaltech.com which will allow you to use reflection (in shared hosting) as long as it is used for assemblies within your designated app folder.

Second...

Download the Castle.DynamicProxy-vs2005 project. NHibernate ships with the dll, but you will need to modify the assembly to allow lazy loading under medium trust. Once you have the assembly, make sure nhibernate references this assembly and not the old dll.

Open the Castle.DynamicProxy-vs2005 project and look for the ModuleScope.cs file (it is right in the main directory). There look for the method:
private AssemblyName GetAssemblyName (bool signStrongName)
In there comment out the following code:

if (signStrongName)
{
byte[] keyPairStream = GetKeyPair();

if (keyPairStream != null)
{
assemblyName.KeyPair = new StrongNameKeyPair(keyPairStream);
}
}




Now give it a shot.

Mario


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.