7

当我将应用程序上传到服务器进行测试时,我收到了这个奇怪的莫名其妙的错误。从我研究来看,似乎是MySql.Data冲突造成的,我上传的副本属于:6.3.7.0。

我该如何解决这个问题?我认为将它放入垃圾箱会“覆盖” GAC 中的垃圾箱?

NHibernate.Exceptions.GenericADOException: 无法执行查询 [ SELECT this_.Id as Id18_0_, this_.Email as Email18_0_,

(等属性)

FROM Userthis_ WHERE this_.Email = ? 和 this_.Password = ? ] Positional parameters: #0>WvewHQlNRyQNKjBAtPR1AwrWQj0nwfmIflO+r4mCJQWA1jZ9zRvefcGz6ZA69b3v #1>97403BA77F7C26BEC6B4F0A4F8509E02848CCD7DCF61D7DF5D79C3AAB2760E6AE1EB26F5D10D384E069F8C6089C47D3F1F0F17E7EBF30F71A68A39DF8863646F

[SQL: 选择 this_.Id 作为 Id18_0_,this_.Email 作为 Email18_0_,

(等属性)

FROM Userthis_ WHERE this_.Email = ? 而 this_.Password = ?] --->

System.InvalidCastException:[A]MySql.Data.MySqlClient.MySqlConnection 无法转换为 [B]MySql.Data.MySqlClient.MySqlConnection。类型 A 源自 'MySql.Data, Version=6.2.3.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d' 在位置 'C:\Windows\assembly\GAC_MSIL\MySql.Data\6.2.3.0__c5687fc88969c44d\ MySql.Data.dll'。类型 B 源自 'MySql.Data, Version=6.3.7.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d' 在位置 'C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP 的上下文'Default'中。 NET 文件\root\cb584441\17e039bb\assembly\dl3\6b14fe89\804a4095_b2c0cc01\MySql.Data.DLL'。

在 MySql.Data.MySqlClient.MySqlCommand.set_DbConnection(DbConnection 值) 在 NHibernate.AdoNet.AbstractBatcher.Prepare(IDbCommand cmd) 在 NHibernate.AdoNet System.Data.Common.DbCommand.System.Data.IDbCommand.set_Connection(IDbConnection 值) .AbstractBatcher.ExecuteReader(IDbCommand cmd) 在 NHibernate.Loader.Loader.GetResultSet(IDbCommand st, Boolean autoDiscoverTypes, Boolean callable, RowSelection selection, ISessionImplementor session) at NHibernate.Loader.Loader.DoQuery(ISessionImplementor session, QueryParameters queryParameters, Boolean returnProxies)在 NHibernate.Loader.Loader.DoQueryAndInitializeNonLazyCollections(ISessionImplementor session, QueryParameters queryParameters, Boolean returnProxies) 在 NHibernate.Loader.Loader.DoList(ISessionImplementor session,QueryParameters queryParameters) --- 内部异常堆栈跟踪的结束 --- 在 NHibernate.Loader.Loader.ListIgnoreQueryCache(ISessionImplementor session, QueryParameters queryParameters) 在 NHibernate.Loader 的 NHibernate.Loader.Loader.DoList(ISessionImplementor session, QueryParameters queryParameters)。 Loader.List(ISessionImplementor session, QueryParameters queryParameters, ISet1 querySpaces, IType[] resultTypes) at NHibernate.Impl.SessionImpl.List(CriteriaImpl criteria, IList results) at NHibernate.Impl.CriteriaImpl.List(IList results) at NHibernate.Impl.CriteriaImpl.UniqueResult[T]() at NHibernate.Criterion.QueryOverNHibernate.Criterion.QueryOver`1.NHibernate.IQueryOver.SingleOrDefault() 处的 1.SingleOrDefault()

4

3 回答 3

26

我遇到了同样的问题,但几年后!

我的服务器已在 gac 中安装了 MySql Connector 6.4.6 版本,但我正在使用 6.8.3 版本,我收到“无法转换错误”。我通过将以下部分添加到 .config 文件来修复它

<system.data>
    <DbProviderFactories>
      <!-- Removes the dll installed in gac-->
      <remove invariant="MySql.Data.MySqlClient" />

      <!-- Add the dll copied in the bin folder-->
      <add name="MySQL" description="ADO.Net driver for MySQL" invariant="MySql.Data.MySqlClient" type="MySql.Data.MySqlClient.MySqlClientFactory, MySql.Data"/>
    </DbProviderFactories>
</system.data>
于 2014-05-09T23:54:20.870 回答
0

正如预期的那样,您使用的是两个不同版本的 MySql。版本6.2.3.0和版本6.3.7.0。从这一点开始,我只能猜测:也许你正在使用一个用不同版本的 MySql 构建的 dll(它允许并排安装)。

于 2011-12-22T14:21:58.097 回答
0

我有同样的问题,版本 18 和 19 之间的冲突。在 web.config 中执行此操作修复了它。将新版本设置为您机器中的版本。

<dependentAssembly>
        <assemblyIdentity name="MySql.Data" publicKeyToken="c5687fc88969c44d" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-8.0.18.0" newVersion="8.0.19.0" />
      </dependentAssembly>
于 2020-02-22T18:38:58.250 回答