在测试的调试模式下,流利的NHibernate无法从GAC中加载MySql.Data [英] Fluent NHibernate cannot load MySql.Data from GAC in debug mode of a test

查看:167
本文介绍了在测试的调试模式下,流利的NHibernate无法从GAC中加载MySql.Data的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我得到了下面的代码:

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

最后一行抛出异常当我调试我的单元测试时出现以下错误:


无法加载文件或程序集MySql.Data或其
依赖项之一。系统无法找到指定的文件。


问题是没有说明它尝试使用的版本。
我尝试使用以下配置来捕获所有版本:

 < 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>

但问题仍然存在。奇怪的是,异常没有提及任何关于版本的问题,通常在这种情况下。

流畅的NHB是3.1版本的最新1.2版本NHB是3.2的连接器是6.3.7.0

我正在使用MSTest 。当我运行测试没有调试(运行检查测试)它不会抛出任何异常,并成功完成(它确实执行MySQL测试数据库的操纵,所以在这种情况下,它找到MySql.Data.dll和插入行例如没有问题) 。

UPDATE 好的,当我从GAC中取出MySql.Data.dll并引用它为一个文件,并设置复制本地终于开始在调试工作。情况如何?为什么在调试时无法从GAC加载它,并且可以在简单的运行模式下运行? 解决方案

也许32/64位执行配置?这两个平台的DLL是一样的,但是 .exe 不是。您可以检查您的测试项目是否配置为AnyCPU。


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. 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

I am using 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).

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. What is the case? Why it cannot load it from GAC in debug, and can in simple run mode?

解决方案

Perhaps a problem with 32/64 bits execution configuration? The DLL is the same for both platforms, but the .exe is not. You could check if your test project is configured to AnyCPU.

这篇关于在测试的调试模式下,流利的NHibernate无法从GAC中加载MySql.Data的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆