简体   繁体   English

Fluent NHibernate 无法在测试的调试模式下从 GAC 加载 MySql.Data

[英]Fluent NHibernate cannot load MySql.Data from GAC in debug mode of a test

I got the following code:我得到以下代码:

    var cfg = new Configuration();
    cfg.Configure();
    FluentConfiguration config = Fluently.Configure(cfg)
        .Mappings(
            m => m.FluentMappings.AddFromAssemblyOf<InputMapping>());
    s_SessionSource = new SessionSource(config);

last line throws exception when I debug my unit test with following error:当我调试单元测试时,最后一行抛出异常并出现以下错误:

Could not load file or assembly 'MySql.Data' or one of its dependencies.无法加载文件或程序集“MySql.Data”或其依赖项之一。 The system cannot find the file specified.该系统找不到指定的文件。

problem is it doesn't say what version it did try to use.问题是它没有说明它尝试使用的版本。 I tried to catch all versions with following configuration:我尝试使用以下配置捕获所有版本:

 <dependentAssembly>
    <assemblyIdentity name="MySql.Data"
                      publicKeyToken="c5687fc88969c44d"
                      culture="neutral" />
    <bindingRedirect oldVersion="1.0.0.0-6.3.6.0"
                     newVersion="6.3.7.0" />
 </dependentAssembly>

but problem persists.但问题仍然存在。 Its pretty odd that exception doesn't say anything about version, it usually does in such cases.很奇怪,异常没有说明版本,通常在这种情况下。

Fluent NHB is latest 1.2 for 3.1 version NHB is 3.2 connector is 6.3.7.0 Fluent NHB 是 3.1 版本的最新 1.2 NHB 是 3.2 连接器是 6.3.7.0

I am using MSTest.我正在使用 MSTest。 When I run test without debug (Run Checked Test) it doesn't throw any exceptions and completes successfully ( it does perform manipluations with MySQL test database so in that case it finds MySql.Data.dll and inserts row for example with no problems).当我在没有调试的情况下运行测试(运行检查测试)时,它不会抛出任何异常并成功完成(它确实使用 MySQL 测试数据库执行操作,因此在这种情况下,它会找到 MySql.Data.Z06416233FE5EC4C4C593Z1222E 的示例) .

UPDATE okay when I took MySql.Data.dll from GAC and referenced it as a file, and setup Copy Local it finally started to work in debug.更新好的,当我从 GAC 获取 MySql.Data.dll 并将其作为文件引用,并设置 Copy Local 时,它终于开始在调试中工作。 What is the case?这是什么情况? Why it cannot load it from GAC in debug, and can in simple run mode?为什么它不能在调试中从 GAC 加载它,并且可以在简单运行模式下?

Perhaps a problem with 32/64 bits execution configuration?也许是 32/64 位执行配置的问题? The DLL is the same for both platforms, but the .exe is not. DLL 对于两个平台是相同的,但.exe不是。 You could check if your test project is configured to AnyCPU.您可以检查您的测试项目是否配置为 AnyCPU。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在GAC中没有MySql.Data的流畅NHibernate连接到MySql - Fluent NHibernate connection to MySql without MySql.Data in GAC 更改全局程序集缓存 (GAC) 中的 MySql.data 版本 - Change MySql.data version in Global Assembly Cache (GAC) MySQL:6.6.5.0版本的MySql.Data无法加载 - MySQL : 6.6.5.0 version of MySql.Data couldn't load 无法加载文件或程序集“ MySql.Data”,参数不正确 - Could not load file or assembly 'MySql.Data' the parameter is incorrect .NET 核心中 MySQL.Data 的“无法加载文件或程序集”问题 - "Could not load file or assembly" problem with MySQL.Data in .NET core 无法加载文件或程序集“ mysql.data”,版本= 6.7.4.0 - Could not load file or assembly 'mysql.data,' version=6.7.4.0 无法加载“MySql.Data”或其中一个依赖项。 - Could not load 'MySql.Data' or one of it's dependencies. 无法加载文件或程序集&#39;MySql.Data,版本= 6.7.4.0 - Could not load file or assembly 'MySql.Data, Version=6.7.4.0 无法加载文件或程序集 &#39;MySql.Data,版本 = 6.2.2.0 - Could not load file or assembly 'MySql.Data, Version=6.2.2.0 ClickOnce应用程序抛出错误“..需要首先在全局程序集缓存(GAC)中安装程序集MySql.Data版本6.5.4.0。” - ClickOnce Application throws error “..requires assembly MySql.Data Version 6.5.4.0 be installed in the Global Assembly Cache (GAC) first.”
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM