Nhibernate升级到2.1.2版本后无法工作
我最近将 NHibernate 实现从版本 2.1.0 更改为 2.1.2。对于延迟加载,我使用了 LinFu 实现:NHibernate.ByteCode.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 吗?我该怎么做才能使应用程序再次运行?
I recently changes my NHibernate implementation from Version 2.1.0 to 2.1.2. For lazy loading I used the LinFu implementation using : NHibernate.ByteCode.Linfu.
Since I changed to the newest version I got the following error:
[SecurityException: That assembly does not allow partially trusted callers.]
NHibernate.ByteCode.LinFu.ProxyFactory..cctor() +0
When debugging I came to the following error:
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
Is this because of the usage of NHibernate.ByteCode.LinFu? What can I do about it to make the application work again?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您有不同版本的引用,即 2.1.0 和 2.1.2,您可以配置 .net 以使用程序集重定向将调用从旧版本重定向到新版本,反之亦然...
但是我认为这不是问题因为错误是完全不同的。即安全异常。 “该程序集不允许部分受信任的调用者”似乎表明无论正在运行的进程都没有必要的上下文权限来执行“NHibernate.ByteCode.LinFu.ProxyFactory..ctor()”方法中的代码。您可能正在使用客户端配置文件或在“部分受信任”的 Web 托管环境中运行应用程序。
您是否有关于运行此应用程序的上下文的更多信息?
In cases where you have different version of references i.e. 2.1.0 and 2.1.2 you can configure .net to redirect calls from the old to the new or vice versa using assembly redirects...
However I don't think this is the problem as the error is quite different. i.e. Security Exception. "That assembly does not allow partially trusted callers" seems to indicate that whatever process is running doesn't have the necessary context permissions to execute the code in the method "NHibernate.ByteCode.LinFu.ProxyFactory..ctor()". Potentially you are running an application using Client Profile or in a "Partially Trusted" web hosted environment.
Do you have more information about the context you are running this application in?