c# - ProxyFactoryFactory 未配置

标签 c# winforms visual-studio-2008 nhibernate proxyfactory

我们最近将我们的 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/

相关文章:

c# - 单击 form2 上的按钮触发 form 1 中的方法

c# - 带有 DefineConstants 的解决方案文件的 MsBuild

asp.net - 预编译 ASP.NET 解决方案以进行部署

c# - 可以动态接受控制台命令的 Windows 服务应用程序

c# - 如何使 Windows 窗体适合/调整大小以适应任何屏幕分辨率?

c# - 如何在 C# 中解决车辆跟踪 GPS 收集数据的最佳解决方案?

c# - 为什么 Java 不在其语言语法中使用 out 参数,而 c# 使用?

c# - 使用变量序列化表达式

c# - 将 GLcontrol 添加到 visual studio 工具箱

c# - 无法使用 margin "Thickness"值