3

最近、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 の使用によるものですか? アプリケーションを再び機能させるにはどうすればよいですか?

4

1 に答える 1

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()」のコードを実行するために必要なコンテキスト権限がないことを示しているようです。クライアントプロファイルを使用して、または「部分的に信頼できる」Webホスト環境でアプリケーションを実行している可能性があります。

このアプリケーションを実行しているコンテキストに関する詳細情報はありますか?

于 2011-03-24T08:07:38.833 に答える