NHibernate 2.0.1与Mono的兼容性问题

4

我已经在Windows机器上构建了我的WinForm应用程序,并且应用程序工作正常。当我使用nhibernate 1.2.1时,该应用程序在使用mono的Linux机器上也可以运行,但是现在当我将应用程序升级到nhibernate 2.0.1时,它只能在Windows上运行。

我收到以下错误:

NHibernate.InvalidProxyTypeException: 下列类型不能用作代理: xxxx.Data.Dao.Credit : 方法obj_address应该是虚拟的 ......

有谁能帮我解决这个问题吗?

3个回答

1

您可以尝试禁用NHibernate Config代理验证器。它似乎与mono不兼容。

您可以通过在应用程序/ 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>

0
我也正在使用Mono尝试使用NHibernate。大多数论坛似乎都说将字符串设置为virtual将解决这个问题,但是对我来说并没有起作用。有趣的是我的错误几乎完全相同 -
""方法obj_address应该是虚拟的
这让我想到代理"address"可能被保留用于其他目的。尝试更改此列的名称?


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接