代码之家  ›  专栏  ›  技术社区  ›  Ian Ringrose

如何调查测试程序集拒绝加载到NUnit的过程?

  •  5
  • Ian Ringrose  · 技术社区  · 14 年前

    (这对我团队中的其他人有效,因此很可能与机器的设置有关。)

    该项目是用Visual Studio 2005构建的,Visual Studio About box将.NET framework版本设置为2.0.50727sp2。

    这是我得到的错误:

    程序集未加载


    不加载文件或程序集的测试, PublicKeyToken=null'或 依赖关系。有人试图 格式。您可能正在尝试加载 用更高版本生成的程序集 CLR的版本低于 哪个修女正在运行 将64位程序集转换为32位进程。


    我刚用过 Assembly Binding Log Viewer (Fuslogvw.exe)要查看fusions日志,这是显示给我的,这没有任何意义,因为我告诉它要查看所有绑定。

    *** Assembly Binder Log Entry  (05/11/2010 @ 11:55:26) ***
    
    The operation was successful.
    Bind result: hr = 0x0. The operation completed successfully.
    
    Assembly manager loaded from:  C:\Windows\Microsoft.NET\Framework64\v2.0.50727\mscorwks.dll
    Running under executable  C:\Program Files (x86)\NUnit 2.5.7\bin\net-2.0\nunit.exe
    --- A detailed error log follows. 
    
    === Pre-bind state information ===
    LOG: User = KSSRETAIL\ian.ringrose
    LOG: DisplayName = System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
     (Fully-specified)
    LOG: Appbase = file:///C:/Program Files (x86)/NUnit 2.5.7/bin/net-2.0/
    LOG: Initial PrivatePath = NULL
    LOG: Dynamic Base = NULL
    LOG: Cache Base = NULL
    LOG: AppName = nunit.exe
    Calling assembly : nunit-gui-runner, Version=2.5.7.10213, Culture=neutral, PublicKeyToken=96d09a1eb7f44a77.
    ===
    LOG: This bind starts in default load context.
    LOG: Using application configuration file: C:\Program Files (x86)\NUnit 2.5.7\bin\net-2.0\nunit.exe.config
    LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework64\v2.0.50727\config\machine.config.
    LOG: Post-policy reference: System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
    LOG: Reusing an assembly instance that was previously loaded (C:\Windows\assembly\GAC_MSIL\System.Windows.Forms\2.0.0.0__b77a5c561934e089\System.Windows.Forms.dll).
    

    但是,我仍然不知道如何获得一组有用的日志,以逻辑方式跟踪这类问题。

    1 回复  |  直到 14 年前
        1
  •  6
  •   Ian Ringrose    14 年前

    有几个原因:

    1) .NET框架的版本。确保加载了正确的版本或在配置(app.config)中定义了它

    2) 版本地狱:您的某些程序集使用其他程序集的不匹配版本,而您的本地文件夹中可以有一个版本。这通常是最可能的原因。

    4) 位32位/64位(如果在任何点都未加载托管代码)

    要了解,请检查以上所有内容。我还建议您通过sysinternals运行流程监视器。在文件加载事件中,您将看到一个“找不到文件”事件。它需要一段时间来适应,但它是一个非常好的工具。