2010-01-25 46 views
3

我最近将我的NHibernate实现从版本2.1.0更改为2.1.2。对于延迟加载,我使用了LinFu实现:NHibernate.ByteCode.Linfu。Nhibernate在升级到版本2.1.2后不起作用

因为我改变到最新的版本,我得到了以下错误:

[SecurityException: That assembly does not allow partially trusted callers.] 
    NHibernate.ByteCode.LinFu.ProxyFactory..cctor() +0 

调试时我来到了以下错误:

at NHibernate.ByteCode.LinFu.ProxyFactory..ctor() 
    at NHibernate.ByteCode.LinFu.ProxyFactoryFactory.BuildProxyFactory() 
    at NHibernate.Tuple.Entity.PocoEntityTuplizer.BuildProxyFactoryInternal(PersistentClass class, IGetter getter, ISetter setter) 
    at NHibernate.Tuple.Entity.PocoEntityTuplizer.BuildProxyFactory(PersistentClass persistentClass, IGetter idGetter, ISetter idSetter) 
    at NHibernate.Tuple.Entity.AbstractEntityTuplizer..ctor(EntityMetamodel entityMetamodel, PersistentClass mappingInfo) 
    at NHibernate.Tuple.Entity.PocoEntityTuplizer..ctor(EntityMetamodel entityMetamodel, PersistentClass mappedEntity) 
    at NHibernate.Tuple.Entity.EntityEntityModeToTuplizerMapping..ctor(PersistentClass mappedEntity, EntityMetamodel em) 
    at NHibernate.Tuple.Entity.EntityMetamodel..ctor(PersistentClass persistentClass, ISessionFactoryImplementor sessionFactory) 
    at NHibernate.Persister.Entity.AbstractEntityPersister..ctor(PersistentClass persistentClass, ICacheConcurrencyStrategy cache, ISessionFactoryImplementor factory) 
    at NHibernate.Persister.Entity.SingleTableEntityPersister..ctor(PersistentClass persistentClass, ICacheConcurrencyStrategy cache, ISessionFactoryImplementor factory, IMapping mapping) 
    at NHibernate.Persister.PersisterFactory.CreateClassPersister(PersistentClass model, ICacheConcurrencyStrategy cache, ISessionFactoryImplementor factory, IMapping cfg) 
    at NHibernate.Impl.SessionFactoryImpl..ctor(Configuration cfg, IMapping mapping, Settings settings, EventListeners listeners) 
    at NHibernate.Cfg.Configuration.BuildSessionFactory() 
    at MyApplication.SessionManager..ctor() in C:\Projects\MyApps\MyApplication\SessionManager.cs:line 75 

这是因为NHibernate.ByteCode的用法.LinFu?我能做些什么来使应用程序再次工作?

+0

你是否也更新了依赖库? (LinFu就是其中之一) – hackerhasid 2010-01-25 16:31:32

+1

http://stackoverflow.com/questions/1848342/allowing-partially-trusted-callers-security-exception-is-been-thrown-althought-ru – 2010-01-25 17:15:34

+0

我更新了Nhibernate.ByteCode.Linfu,不需要更新Linfu.DynamicProxy。 看着引用的帖子,我也尝试使用ByteCode.Castle,但这也行不通。 – Jan 2010-01-26 08:40:31

回答

0

在你有不同的版本的引用,即2.1.0和2.1.2,您可以配置.NET重定向从旧到新,反之亦然使用汇编将电话转接的情况下...

<?xml version="1.0" encoding="utf-8"?> 
<configuration> 
    <runtime> 
     <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> 
      <dependentAssembly> 
       <assemblyIdentity name="Linfu.DynamicProxy" 
            publicKeyToken="32cd8f1a53a4c744" 
            culture="neutral" /> 
       <bindingRedirect oldVersion="1.0.0.0" 
           newVersion="1.1.0.0"/> 
      </dependentAssembly> 
     </assemblyBinding> 
    </runtime> 
</configuration> 

但是我不认为这是问题,因为错误是完全不同的。即安全例外。 “该程序集不允许部分受信任的调用者”似乎表明无论正在运行的进程都没有必要的上下文权限来执行方法“NHibernate.ByteCode.LinFu.ProxyFactory..ctor()”中的代码。您可能正在使用客户端配置文件运行应用程序,或者在“部分可信”网络托管环境中运行应用程序。

您是否有关于您正在运行此应用程序的上下文的更多信息?

相关问题