搜索 SO 但找不到有效的解决方案。
在 Visual 我有一个主要项目。它使用编译为 DLL 的另一个项目 (ProjectA)。该项目使用 Servicestack ORMLite 4.5.14。我也安装了Mysql.Data 6.9.12
. ProjectA 是 Project 在主项目中的引用,而不是编译的 DLL。
编译后的应用程序被复制到另一台 PC(只需复制,无需安装)并启动。但是,当它尝试使用 ProjectA 访问数据库时,出现以下错误:
System.IO.FileLoadException: Could not load file or assembly 'MySql.Data, Version=8.0.20.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
File name: 'MySql.Data, Version=8.0.20.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d' ---> System.IO.FileLoadException: Could not load file or assembly 'MySql.Data, Version=6.9.9.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
File name: 'MySql.Data, Version=6.9.9.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d'
WRN: Assembly binding logging is turned OFF.
To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1.
Note: There is some performance penalty associated with assembly bind failure logging.
To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].
at ServiceStack.OrmLite.MySql.MySqlDialectProvider.CreateConnection(String connectionString, Dictionary`2 options)
at ServiceStack.OrmLite.OrmLiteConnection.get_DbConnection()
at ServiceStack.OrmLite.OrmLiteConnection.Open()
at ServiceStack.OrmLite.OrmLiteConnectionFactory.OpenDbConnection()
at ServiceStack.OrmLite.OrmLiteConnectionFactoryExtensions.Open(IDbConnectionFactory connectionFactory)
at ProjectA.Repositories.ARepository.FindById(String id)
at ProjectA.Controllers.AController.FindById(String id)
at ProjectA.Service.DatabaseService.Find(String id)
我试图解决的问题:
- 编译ProjectA并使用DLL作为参考而不是直接在解决方案中的项目
- 卸载所有引用
Mysql.Data
和 ServiceStack ORMlite 并重新安装它 - 更改了 .Net 框架版本(4.5.2 及更高版本)
- 在应用程序应该运行的机器上安装 Mysql 连接器
- 安装
Mysql.Data 8.0
- 删除
mysql.data.dll
目录中的,以便将其复制回来。检查 DLL 的版本,它匹配 6.9.12 - 在 .csproj 文件中搜索
Mysql.data
8.0 和 6.9.9 但找不到参考
由于它使用的是旧的 Mysql 服务器,因此需要旧版本的 Mysql.Data,因此还需要旧版本的 ServiceStack ORM lite。
我之前遇到过这个问题,ProjectA 也用于需要 Mysql 8.0 的不同项目中。由于它被引用为项目(而不是 DLL 文件),因此它来回更改。但是,过去重新安装Mysql.data
并Service Stack ORM lite
确实解决了问题。但现在我无法克服这个错误。我确保解决方案中所有项目的版本都相同。我知道这是不好的做法,但由于我们正在重写完整的应用程序,直到现在才可行。
有什么建议可以解决这个问题吗?