我最近将我的NHibernate实现从版本2.1.0更改为2.1.2。对于延迟加载,我使用了使用: NHibernate.ByteCode.Linfu的LinFu实现。
因为我切换到了最新的版本,所以我得到了以下错误:
[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吗?我该怎么做才能让应用程序再次工作呢?
发布于 2011-03-24 16:07:39
如果你有不同版本的引用,比如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()".中的代码您可能正在使用客户端配置文件或在“部分信任”的web托管环境中运行应用程序。
您是否有关于在其中运行此应用程序的上下文的详细信息?
https://stackoverflow.com/questions/2133636
复制相似问题