【问题标题】:nhibernate Operation could destabilize the runtimenhibernate 操作可能会破坏运行时的稳定性
【发布时间】:2009-12-03 15:56:18
【问题描述】:

我的网站在本地可以正常工作,但在主机上却出现错误:

“操作可能会破坏运行时的稳定性。”

我正在使用休眠。 我正在使用存储库模式。

[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

【问题讨论】:

  • 你在使用 Fluent 吗?

标签: nhibernate proxy medium-trust


【解决方案1】:

使用城堡动态代理

【讨论】:

  • 我运行的是 2.1.2GA,打开 sol'n 显示他们使用的是 dymaicproxy2 版本 2.1.0.0,在这里找不到该分支:svn.castleproject.org/svn/castle/DynamicProxy
  • 您可以在此处获取 Castle DP 2.1 的分支:svn.castleproject.org/svn/castle/tags/dynamicproxy-2.1.0 但是为什么需要代码?获取二进制文件。我还建议获取 2.2 测试版(今天发布!),但目前,您必须针对这个新版本自己构建 NHibernate ProxyFactoryFactory 项目。
  • 那么,Castle DynamicProxy 在中等信任下工作,而 LinFu 不行?
【解决方案2】:

我以前也遇到过这种情况。检查您的代码是否包含较长的 switch 子句。 从这里:http://forums.asp.net/p/981415/1255521.aspx

【讨论】:

  • nhibernate 很大,它确实有很多我不会修改的 switch 语句:)
猜你喜欢
  • 2010-09-27
  • 1970-01-01
  • 2010-12-25
  • 2012-09-15
  • 1970-01-01
  • 2014-12-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多