我已经在 Windows 机器上构建了我的 WinForm 应用程序,并且该应用程序运行正常。当我使用 nhibernate 1.2.1 时,该应用程序也可以在使用单声道的 linux 机器上运行,但是现在当我将应用程序升级到 nhibernate 2.0.1 时,它只能在 Windows 中运行。我收到错误:NHibernate.InvalidProxyTypeException:以下类型可能不能用作代理:xxxx.Data.Dao.Credit:方法 obj_address 应该是虚拟的......谁能帮我解决这个问题?
Pavel
问问题
3462 次
3 回答
1
您可以尝试禁用 NHibernate Config 代理验证器。它似乎不适用于单声道。
您可以通过
<property name="use_proxy_validator">false</property>
在 app/web.config nhibernate 部分添加:
有关具有此属性集的示例配置,请参见此处: 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>
于 2009-02-10T04:08:25.693 回答
0
于 2008-10-06T08:00:04.300 回答
0
我也在尝试使用 NHibernate。大多数论坛似乎都说将字符串设置为虚拟可以解决问题,但这对我不起作用。奇怪的是我的错误几乎是一样的——
"" 方法 obj_address 应该是虚拟的
这让我觉得代理“地址”是为其他东西保留的。尝试更改此列的名称?
于 2008-12-31T02:56:35.213 回答