代码之家  ›  专栏  ›  技术社区  ›  stiank81

升级到vs2010和re_5之后,与sqlite相关的nunit测试出现问题

  •  4
  • stiank81  · 技术社区  · 15 年前

    在使用Resharper5转换为Visual Studio 2010之后,我的一些单元测试开始失败。更具体地说,这适用于所有使用nhibernate和sqlite的单元测试。这个问题似乎与sqlite有关。不涉及nhibernate和sqlite的单元测试仍然运行良好。

    例外情况如下:

    NHibernate.HibernateException : Could not create the driver from NHibernate.Driver.SQLite20Driver, NHibernate, Version=2.1.2.4000, Culture=neutral, PublicKeyToken=aa95f207798dfdb4.
      ----> System.Reflection.TargetInvocationException : Exception has been thrown by the 
            target of an invocation.
      ----> NHibernate.HibernateException : The IDbCommand and IDbConnection implementation 
            in the assembly System.Data.SQLite could not be found. Ensure that the assembly
            System.Data.SQLite is located in the application directory or in the Global 
            Assembly Cache. If the assembly is in the GAC, use <qualifyAssembly/> element 
           in the application configuration file to specify the full name of the assembly.
    TearDown : System.NullReferenceException : Object reference not set to an instance of an object.
    

    当清理未成功创建的nhibernate对象时,异常是TearDown上的NullReferenceException,但该问题似乎与sqlite有关。

    我通过Resharper运行我的单元测试,但是当直接通过nunit.exe应用程序运行它们时,我会得到相同的异常。但是,通过x86变体(nunit-x86.exe)运行它们,所有测试都可以正常运行。它是否与64位和32位DLL的某些混合有关?通过VS2008+Resharper4.5,它仍然运行良好。

    请注意,我的项目的目标框架仍然是.net3.5。

    以前有人见过这个问题吗?

    4 回复  |  直到 15 年前
        1
  •  6
  •   stiank81    15 年前

    64位和32位DLL之间似乎有某种混合。切换到使用sqlite.dll的x64变量可以解决此问题。我不知道为什么VS2008没有给出这个问题。

        2
  •  3
  •   Charles Ouellet    15 年前

    我得到了同样的错误,我确信这是由于.NET 4.0和vs 2010,但是当我在工作中升级到resharper 5时(vs 2008),我得到了同样的错误。

    我认为这是由Resharper 5测试运行程序造成的。当我使用testdriven.net时,它们都运行成功。

    我希望JetBrains能尽快发布修复程序。根据我在论坛上看到的情况,他们知道这个问题,所以不应该花太长时间来解决。

    当这个问题得到解决时,我将使用testdriven.net来运行我的测试。但我会怀念伟大的雷沙普UI;)

        3
  •  2
  •   Foxfire    15 年前

    您在Visual Studio 2010中查看过编译设置吗?

    为了隐藏他们无法让最新的调试器在64位运行,微软决定将.NET应用程序的默认编译从任何CPU切换到32位x86。

    这会给你带来麻烦。

        4
  •  0
  •   sweetest surprise    15 年前

    无法从nhibernate.driver.sqlite20driver,nhibernate,version=2.1.2.4000,culture=neutral,publickeytoken=aa95f207798dfdb4创建驱动程序

    解决方案:

    测试设置: 选择主机 选择在64位计算机上的64位进程中运行测试

    希望我能帮忙。

    梅里编码