Nhibernate 2.0.1带单声道

时间:2008-10-06 06:52:14

标签: nhibernate mono

我在Windows机器上构建了我的WinForm应用程序,该应用程序正在运行 好。当我用户nhibernate 1.2.1时,该应用程序也适用于linux机器 使用单声道,但现在当我将应用程序升级到nhibernate 2.0.1时,它的工作原理 只在窗口。 我收到错误:  NHibernate.InvalidProxyTypeException:以下类型可能不是 用作代理: xxxx.Data.Dao.Credit:方法obj_address应该是虚拟的 ...... 任何人都可以帮我解决这个问题吗?

3 个答案:

答案 0 :(得分:1)

您可以尝试并禁用NHibernate Config代理验证程序。它似乎不适用于单声道。

您可以添加以下内容: 您的app / web.config nhibernate部分中的<property name="use_proxy_validator">false</property>

有关设置此属性的示例配置,请参阅此处: http://www.mail-archive.com/nhusers@googlegroups.com/msg02109.html

或修改:

<?xml version="1.0"?>
<configuration>
  <configSections>
    <section name="hibernate-configuration"
             type="NHibernate.Cfg.ConfigurationSectionHandler, NHibernate" />
  </configSections>

  <hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">
    <session-factory>
        <!--
      <property name="dialect">NHibernate.Dialect.MsSql2005Dialect</property>
      <property name="connection.provider">NHibernate.Connection.DriverConnectionProvider</property>
      <property name="connection.driver_class">NHibernate.Driver.SqlClientDriver</property>
      <property name="connection.connection_string">Data Source=YOUR_DB_SERVER;Database=Northwind;User ID=YOUR_USERNAME;Password=YOUR_PASSWORD;</property>
      <property name="connection.isolation">ReadCommitted</property>
      <property name="default_schema">Northwind.dbo</property>
          -->
        <!--
      <property name="dialect">NHibernate.Dialect.SQLiteDialect</property>
      <property name="connection.provider">NHibernate.Connection.DriverConnectionProvider</property>
      <property name="connection.driver_class">NHibernate.Driver.SQLiteDriver</property>
      <property name="connection.connection_string">Data Source=nhibernate.db;Version=3</property>
      <property name="query.substitutions">true=1;false=0</property>
          -->
          <!-- mysql
      <property name="dialect">NHibernate.Dialect.MySQLDialect</property>
      <property name="connection.provider">NHibernate.Connection.DriverConnectionProvider</property>
      <property name="connection.driver_class">NHibernate.Driver.MySqlDataDriver</property>
      <property name="connection.connection_string">Database=test</property>
          -->
          <property name="connection.provider">NHibernate.Connection.DriverConnectionProvider</property>
          <property name="connection.driver_class">NHibernate.Driver.NpgsqlDriver</property>
          <property name="connection.connection_string">Server=localhost;database=test;User id=jrwren;password=yourpasswordhere.</property>
          <property name="dialect">NHibernate.Dialect.PostgreSQLDialect</property>
          <property name="use_proxy_validator">false</property>
      <!-- HBM Mapping Files -->
      <mapping assembly="Test.exe" />
    </session-factory>
  </hibernate-configuration>

</configuration>

答案 1 :(得分:0)

答案 2 :(得分:0)

我也在尝试使用NHibernate。大多数论坛似乎都说将字符串设置为虚拟将解决问题,但这对我没有用。令人好奇的是我的错误几乎相同 -

“”方法obj_address应该是虚拟的

这让我觉得代理“地址”是为其他东西保留的。尝试更改此列的名称?