views:

1599

answers:

3

I've build my WinForm app on windows machine and the app is working ok. When I user nhibernate 1.2.1 the app also worked on linux machine using mono, but now when i upgraded app to nhibernate 2.0.1 it works only in windows. I've get error: NHibernate.InvalidProxyTypeException: The following types may not be used as proxies: xxxx.Data.Dao.Credit : method obj_address should be virtual ...... Can anyone help me with this problem?

A: 

This might be of interest:

http://softwaredevscott.spaces.live.com/blog/cns!1A9E939F7373F3B7!251.entry

Kev
A: 

I'm also on mono trying to use NHibernate. Most forums seem to say setting the string to virtual will fix the problem, but this hasn't worked for me. What is curious is that my error is almost identical -

"" method obj_address should be virtual

This makes me think the proxy "address" is reserved for something else. Try changing the name of this column?

+1  A: 

You can try and disable the NHibernate Config proxy validator. it seems to not work with mono.

You can do this by adding: <property name="use_proxy_validator">false</property> in your app/web.config nhibernate section.

For an example config with this property set, see here: http://www.mail-archive.com/[email protected]/msg02109.html

or modify this:

<?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>
jrwren