gpt4 book ai didi

c# - ProxyFactoryFactory 未配置

转载 作者:太空狗 更新时间:2023-10-30 01:28:13 26 4
gpt4 key购买 nike

我们最近将我们的 Windows 窗体 C# 项目从 NHibernate 2.0 升级到了 2.1。我们更新了我们的 app.config 以包含“proxyfactory.factory_class”以指向所选代理(在我们的例子中为“NHibernate.ByteCode.CaSTLe”)。升级后,程序按预期构建和运行,没有任何问题。我们的问题是当试图打开任何在 Visual Studio 2008 设计器中加载时引用 NHibernate 的表单时,现在给我们以下错误(好像我们没有配置代理):

The ProxyFactoryFactory was not configured. Initialize 'proxyfactory.factory_class' property of the session-factory configuration section with one of the available NHibernate.ByteCode providers.

堆栈跟踪:

   at NHibernate.Bytecode.AbstractBytecodeProvider.get_ProxyFactoryFactory()
at NHibernate.Cfg.Configuration.Validate()
at NHibernate.Cfg.Configuration.BuildSessionFactory()
at DAL.NHibernateHelper..cctor() in ...\DAL\NHibernateHelper.cs:line 62

来自 NHibernateHelper 的第 62 行:

    static NHibernateHelper()
{
var cfg = new Configuration();
cfg.Configure();
cfg.AddAssembly("DAL");
sessionFactory = cfg.BuildSessionFactory(); // <-- line 62
}

这是 NHibernate 的 app.config 配置:

<configuration>
<configSections>
<section name="hibernate-configuration" type="NHibernate.Cfg.ConfigurationSectionHandler, NHibernate" />
</configSections>
<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">
<session-factory>
<property name="connection.driver_class">NHibernate.Driver.SqlClientDriver</property>
<property name="dialect">NHibernate.Dialect.MsSql2005Dialect</property>
<property name="connection.connection_string">Server=ourserver;initial catalog=ourdb;Integrated Security=SSPI</property>
<property name="proxyfactory.factory_class">NHibernate.ByteCode.Castle.ProxyFactoryFactory, NHibernate.ByteCode.Castle</property>
<property name="show_sql">true</property>
</session-factory>
</hibernate-configuration>
</configuration>

有人知道如何解决这个问题吗?谢谢!

最佳答案

我刚刚解决了同样的错误。

我的数据访问程序集有一个对 Nhibernate.ByteCode.CaSTLe.Dll 的正确引用,它出现在它的 bin/release 文件夹中。数据访问程序集中一切正常。

当我尝试使用测试程序集中的数据访问代码时抛出错误。事实证明,即使我的测试程序集引用了数据访问项目,它也没有获得 Nhibernate.ByteCode.CaSTLe.dll 的副本。在测试程序集中添加对 Nhibernate.ByteCode.CaSTLe.dll 的引用解决了这个问题。

关于c# - ProxyFactoryFactory 未配置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1209106/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com