[A] MySql.Data.MySqlClient.MySqlConnection不能转换为[B] MySql.Data.MySqlClient.MySqlConnection [英] [A]MySql.Data.MySqlClient.MySqlConnection cannot be cast to [B]MySql.Data.MySqlClient.MySqlConnection
问题描述
我该如何解决这个问题?我认为只要把它放在bin中,会覆盖GAC中的一个。
NHibernate.Exceptions.GenericADOException:无法执行查询[SELECT this_.Id as Id18_0_, this_.Email as Email18_0 _,
(etc properties)
FROM code> this_ WHERE this_.Email =?和this_.Password =? ]位置参数:#0> WvewHQlNRyQNKjBAtPR1AwrWQj0nwfmIflO + r4mCJQWA1jZ9zRvefcGz6ZA69b3v#1> 97403BA77F7C26BEC6B4F0A4F8509E02848CCD7DCF61D7DF5D79C3AAB2760E6AE1EB26F5D10D384E069F8C6089C47D3F1F0F17E7EBF30F71A68A39DF8863646F
[SQL:SELECT this_.Id如Id18_0_,this_.Email如Email18_0_,
(etc properties)
FROM 用户
this_ WHERE this_.Email = ?而且__Password =?] .MySqlClient.MySqlConnection。类型A源自'C:\Windows\assembly\GAC_MSIL\MySql.Data\'的上下文默认中的'MySql.Data,Version = 6.2.3.0,Culture = neutral,PublicKeyToken = c5687fc88969c44d' 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.NET Files\root\cb584441\17e039bb\assembly\dl3\6b14fe89\804a4095_b2c0cc01\MySql.Data.DLL'。
在MySql.Data.MySqlClient.MySqlCommand.set_DbConnection(DbConnection值)在System.Data.Common.DbCommand.System.Data.IDbCommand.set_Connection(IDbConnection值)在NHibernate中的NHibernate.AdoNet.AbstractBatcher.Prepare(IDbCommand cmd)在NHibernate.AdoNet.AbstractBatcher.ExecuteReader(IDbCommand cmd)在NHibernate.Loader.Loader.GetResultSet(IDbCommand st,Boolean autoDiscoverTypes,Boolean callable,RowSelection选择,ISessionImplementor会话)。在NHibernate.Loader.Loader.DoList(ISessionImplementor session,QueryParameters queryParameters)的NHibernate.Loader.Loader.DoQueryAndInitializeNonLazyCollections(ISessionImplementor session,QueryParameters queryParameters,Boolean returnProxies)中的Loader.Loader.DoQuery(ISessionImplementor session,QueryParameters queryParameters,Boolean returnProxies) - - 内部异常堆栈跟踪结束 - 在NHibernate.Loader.L中的NHibernate.Loader.Loader.DoList(ISessionImplementor session,QueryParameters queryParameters)在NHibernate.Impl.SessionImpl.List(CriteriaImpl)中的NHibernate.Loader.Loader.List(ISessionImplementor session,QueryParameters queryParameters,ISet 1 querySpaces,IType [] resultTypes))中的oader.ListIgnoreQueryCache(ISessionImplementor session,QueryParameters queryParameters) NHibernate.Impl.CriteriaImpl.List(IList结果),NHibernate.Impl.CriteriaImpl.UniqueResult [T]()在NHibernate.Criterion.QueryOver
1. NHibernate中的SingleOrDefault()标准,IList结果) .Criterion.QueryOver`1.NHibernate.IQueryOver.SingleOrDefault()
我有同样的问题,但多年以后!
我的服务器已经安装在gac MySql Connector 6.4.6版本中,但是我正在使用6.8.3版本,我得到了不能被抛出的错误,我修改了以下部分.config文件
< system.data>
< DbProviderFactories>
<! - 删除安装在gac中的dll - >
< remove invariant =MySql.Data.MySqlClient/>
<! - 添加复制在bin文件夹中的dll - >
< add name =MySQLdescription =用于MySQL的ADO.Net驱动程序invariant =MySql.Data.MySqlClienttype =MySql.Data.MySqlClient.MySqlClientFactory,MySql.Data/>
< / DbProviderFactories>
< /system.data>
I am getting this strange inexplicable error when I uploaded my application to a server for testing. From what I studied, it seems to be caused by conflicting MySql.Data, the copy I uploaded belongs to: 6.3.7.0.
How could I solve this issue? I thought just putting it in the bin would 'override' the one in GAC?
NHibernate.Exceptions.GenericADOException: could not execute query [ SELECT this_.Id as Id18_0_, this_.Email as Email18_0_,
(etc properties)
FROM User
this_ WHERE this_.Email = ? and this_.Password = ? ] Positional parameters: #0>WvewHQlNRyQNKjBAtPR1AwrWQj0nwfmIflO+r4mCJQWA1jZ9zRvefcGz6ZA69b3v #1>97403BA77F7C26BEC6B4F0A4F8509E02848CCD7DCF61D7DF5D79C3AAB2760E6AE1EB26F5D10D384E069F8C6089C47D3F1F0F17E7EBF30F71A68A39DF8863646F
[SQL: SELECT this_.Id as Id18_0_, this_.Email as Email18_0_,
(etc properties)
FROM User
this_ WHERE this_.Email = ? and this_.Password = ?] --->
System.InvalidCastException: [A]MySql.Data.MySqlClient.MySqlConnection cannot be cast to [B]MySql.Data.MySqlClient.MySqlConnection. Type A originates from 'MySql.Data, Version=6.2.3.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d' in the context 'Default' at location 'C:\Windows\assembly\GAC_MSIL\MySql.Data\6.2.3.0__c5687fc88969c44d\MySql.Data.dll'. Type B originates from 'MySql.Data, Version=6.3.7.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d' in the context 'Default' at location 'C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\cb584441\17e039bb\assembly\dl3\6b14fe89\804a4095_b2c0cc01\MySql.Data.DLL'.
at MySql.Data.MySqlClient.MySqlCommand.set_DbConnection(DbConnection value) at System.Data.Common.DbCommand.System.Data.IDbCommand.set_Connection(IDbConnection value) at NHibernate.AdoNet.AbstractBatcher.Prepare(IDbCommand cmd) at NHibernate.AdoNet.AbstractBatcher.ExecuteReader(IDbCommand cmd) at 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) at NHibernate.Loader.Loader.DoQueryAndInitializeNonLazyCollections(ISessionImplementor session, QueryParameters queryParameters, Boolean returnProxies) at NHibernate.Loader.Loader.DoList(ISessionImplementor session, QueryParameters queryParameters) --- End of inner exception stack trace --- at NHibernate.Loader.Loader.DoList(ISessionImplementor session, QueryParameters queryParameters) at NHibernate.Loader.Loader.ListIgnoreQueryCache(ISessionImplementor session, QueryParameters queryParameters) at NHibernate.Loader.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.QueryOver
1.SingleOrDefault() at NHibernate.Criterion.QueryOver`1.NHibernate.IQueryOver.SingleOrDefault()
I got the same problem but years later!
My server has installed in gac the MySql Connector 6.4.6 version, but I'm working with the 6.8.3 version, I was getting the "cannot be cast error", I fixed adding the following section to the .config file
<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>
这篇关于[A] MySql.Data.MySqlClient.MySqlConnection不能转换为[B] MySql.Data.MySqlClient.MySqlConnection的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!