NHibernate 和 iSeries DB2 的问题

发布于 2024-08-31 11:07:06 字数 2010 浏览 8 评论 0原文

好的,我有一台运行 v5r4 的 AS400/iSeries。我有一个使用经典 NHibernate 进行连接并执行一些基本操作的应用程序。现在,我已将该应用程序(已放置了 2 年)从 TFS 下架并转移到新 PC 上,但似乎无法运行它。

这是我的 Hibernate 配置:

<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">
    <session-factory>
      <property name="connection.provider">
        NHibernate.Connection.DriverConnectionProvider
      </property>
      <property name="dialect">
        NHibernate.Dialect.DB2400Dialect
      </property>
      <property name="proxyfactory.factory_class">NHibernate.ByteCode.LinFu.ProxyFactoryFactory, NHibernate.ByteCode.LinFu</property>
      <property name="connection.connection_string">
        DataSource=207.206.106.19;
        Database=AS400;
        userID=XXXXXX;
        Password=XXXXXXX;
        LibraryList=FMSFILTST,BEFFILT,HRDBFT,HRCSTFT,J20##X2DEV,GLCUSTDEV,OSL@@F3DEV;
        Naming=System;
        Initial Catalog=*SYSBAS;
      </property>
      <property name="use_outer_join">true</property>
      <property name="query.substitutions">
        true 1, false 0, yes 'Y', no 'N'
      </property>
      <property name="show_sql">false</property>
      <mapping assembly="BusinessLogic" />
    </session-factory>
  </hibernate-configuration>

我包含所有正确的 DLL(NHibernate、castle、iesi、antlr3、log4 等)。我的 web.config 中也有这一行

<runtime>
    <assemblyBinding>
      <qualifyAssembly partialName="IBM.Data.DB2.iSeries" fullName="IBM.Data.DB2.iSeries,Version=10.0.0.0,PublicKeyToken=9CDB2EBFB1F93A26,Culture=neutral"/>
    </assemblyBinding>
  </runtime>

但是当我调用时我仍然收到以下错误错误

NHibernate.Cfg.Configuration().Configure().BuildSessionFactory().OpenSession();

如下

无法转换类型的对象 'IBM.Data.DB2.iSeries.iDB2Connection' 输入“System.Data.Common.DbCommand”

我很想得到一些帮助。如有任何帮助,我们将不胜感激。谢谢!

Ok So I have an AS400/iSeries running v5r4. I have an application that was using classic NHibernate to connect and do some basic crud. Now I have pulled that app (which sat for 2 years) off the shelf of TFS and onto a new PC and cannot seem to get it running.

Here is my Hibernate Config:

<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">
    <session-factory>
      <property name="connection.provider">
        NHibernate.Connection.DriverConnectionProvider
      </property>
      <property name="dialect">
        NHibernate.Dialect.DB2400Dialect
      </property>
      <property name="proxyfactory.factory_class">NHibernate.ByteCode.LinFu.ProxyFactoryFactory, NHibernate.ByteCode.LinFu</property>
      <property name="connection.connection_string">
        DataSource=207.206.106.19;
        Database=AS400;
        userID=XXXXXX;
        Password=XXXXXXX;
        LibraryList=FMSFILTST,BEFFILT,HRDBFT,HRCSTFT,J20##X2DEV,GLCUSTDEV,OSL@@F3DEV;
        Naming=System;
        Initial Catalog=*SYSBAS;
      </property>
      <property name="use_outer_join">true</property>
      <property name="query.substitutions">
        true 1, false 0, yes 'Y', no 'N'
      </property>
      <property name="show_sql">false</property>
      <mapping assembly="BusinessLogic" />
    </session-factory>
  </hibernate-configuration>

I have all the proper DLL's included (NHibernate, castle, iesi, antlr3 , log4 etc). Also have this line in my web.config

<runtime>
    <assemblyBinding>
      <qualifyAssembly partialName="IBM.Data.DB2.iSeries" fullName="IBM.Data.DB2.iSeries,Version=10.0.0.0,PublicKeyToken=9CDB2EBFB1F93A26,Culture=neutral"/>
    </assemblyBinding>
  </runtime>

Yet I am still getting the following error as soon as I call

NHibernate.Cfg.Configuration().Configure().BuildSessionFactory().OpenSession();

The error is as follows

Unable to cast object of type
'IBM.Data.DB2.iSeries.iDB2Connection'
to type 'System.Data.Common.DbCommand'

I am dying to get some help with this. Any assistance is appreciated. Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

胡大本事 2024-09-07 11:07:06

我在使用iSeries V5r4系统访问时遇到了这个问题。 IBM.Data.DB2.iSeries.dll 是针对 v6r1 之前的 .NET 1.0/1 编译的。因此,它无法将 IDB2Connection 转换为 IDbConnection。如果您使用反射器并查看 IBM dll,请查看引用,然后查看 System.Data 版本。然后查看您在项目中引用的 System.Data 版本,我猜您使用的是 2.0.5****。如果您升级到 v6r1 或更高版本,您应该能够进行投射。

编辑:想要感谢 Steve Bohlen 带领我走上发现这一点的道路。

I had this issue when using V5r4 of the iSeries system access. The IBM.Data.DB2.iSeries.dll is compiled against .NET 1.0/1 before v6r1. Because of this it is unable to cast the IDB2Connection to IDbConnection. If you use reflector and look into the IBM dll, look under references and then look at System.Data version. Then look at the version of System.Data you are referencing in your project, I am guessing you are on 2.0.5****. If you upgrade to v6r1 or higher you should be able to cast.

Edit: Wanted to give Steve Bohlen credit for leading me down the path to discover this.

清风疏影 2024-09-07 11:07:06

尝试添加

<property name="connection.driver_class">
NHibernate.Driver.DB2400Driver
</property>

try to add

<property name="connection.driver_class">
NHibernate.Driver.DB2400Driver
</property>
半窗疏影 2024-09-07 11:07:06

我通过更改对 IBM.Data.DB2.dll 的引用来复制本地解决了这个问题

I've solved this by changing the reference to IBM.Data.DB2.dll to copy local

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文