views:

178

answers:

2

Locally my site works, but at host I am getting the error:

"Operation could destabilize the runtime."

I am using nhibernate. I am using the repository pattern.

[VerificationException: Operation could destabilize the runtime.]
   CategoryProxy..ctor() +6

[TargetInvocationException: Exception has been thrown by the target of an invocation.]
   System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandle& ctor, Boolean& bNeedSecurityCheck) +0
   System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean fillCache) +86
   System.RuntimeType.CreateInstanceImpl(Boolean publicOnly, Boolean skipVisibilityChecks, Boolean fillCache) +230
   System.Activator.CreateInstance(Type type, Boolean nonPublic) +67
   LinFu.DynamicProxy.ProxyFactory.CreateProxy(Type instanceType, IInterceptor interceptor, Type[] baseInterfaces) +20
   NHibernate.ByteCode.LinFu.ProxyFactory.GetProxy(Object id, ISessionImplementor session) +208

[HibernateException: Creating a proxy instance failed]
   NHibernate.ByteCode.LinFu.ProxyFactory.GetProxy(Object id, ISessionImplementor session) +306
A: 

This has happend to me before. Check if your code contains a long switch clause. from here: http://forums.asp.net/p/981415/1255521.aspx

kurast
nhibernate is huge, and it does have many switch statements which I am not going to modify :)
mrblah
+1  A: 

use Castle Dynamic Proxy

Krzysztof Koźmic
if this works, you won't believe how happy imma gonna be!
mrblah
I am running 2.1.2GA, and opening up the sol'n shows that they are using dymaicproxy2 version 2.1.0.0, can't find that branch for it here: https://svn.castleproject.org/svn/castle/DynamicProxy
mrblah
you can get the branch for Castle DP 2.1 here: https://svn.castleproject.org/svn/castle/tags/dynamicproxy-2.1.0/But why do you need the code? Get the binary.I also suggest getting version 2.2 beta (released today!), but at the moment, you'll have to build NHibernate ProxyFactoryFactory project yourself against this new version.
Krzysztof Koźmic
So, Castle DynamicProxy works in medium trust, and LinFu doesn't?
Venemo