首页 文章

VS 2010,NUNit和“断点目前不会被击中 . 没有为此文档加载任何符号“

提问于
浏览
29

使用Windows 7 32位,VS 2010,.NET 4 DLL,NUnit(2.5.5)对应用程序进行单元测试 . 我目前收到以下错误;看到很多帖子并尝试了以下内容:

  • 重启机器

  • 重启VS.

  • 删除bin / obj并重新加载

  • 清理/重建

但是我跑步时无法让NUnit达到我的断点 .

我将NUNit测试项目设置为指向nunit.exe,并加载测试.NET 4 DLL,但是当我运行它时没有找到断点,“没有加载符号” . 我尝试了debug> windows> modules,当我运行它时,它甚至没有显示我的单元测试项目 .

我找到了这个,使用nunit代理:http://groups.google.com/group/nunit-discuss/browse_thread/thread/5680d7def5b6982f

但是当我使用nunit代理时我也收到错误 . 我使用的是nunit-agent-x86.exe,但是我收到了一个system.formatexception,它崩溃了......

有人可以帮忙吗?

谢谢 .

9 回答

  • 42

    还有另一个类似的问题here on Stack Overflow,我发布了my answer以及对我有用的东西 . 我可以使用Debug - > Start New Instance(我认为这是你的目标)直接从Visual Studio 2010设置断点并启动NUnit .

    我将nunit.exe设置为项目中的外部程序 - >属性 - >调试并添加:

    <startup>
        <requiredRuntime version="4.0.30319" />
    </startup>
    

    到NUnit安装目录中nunit可执行文件旁边的nunit.exe.config文件 .

  • 0

    解决方案是:启动NUnit独立,然后在VS 2010中,执行debug> attach to process,并附加到nunit-agent.exe进程,而不是nunit进程 . Nunit进程仍然没有为我做 .

  • 0

    对于一个网站项目,我得到“断点不会被击中......没有符号加载......” . 发现我的网站中存在构建错误(其中一个引用的dll由于某种原因而丢失) . 在重建之前,我在VS2010中选择了View => Error list之前,重建没有显示问题 . 替换bin目录中缺少的dll并更新引用解决了我的问题 .

  • 0

    在nunit-x86.exe.config中添加以下部分对我有用:

    <startup>
          <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0,Profile=Client"/>
      </startup>
    

    只有在运行.NET 4的客户端配置文件时才需要'sku'部分 . 请注意,之前的答案显示使用的'requiredRuntime'已过时 .

  • 0

    你在运行NUnit然后加载DLL吗?尝试打开项目属性,调试选项卡,将启动操作切换为'启动外部程序',指向NUnit exe,将您的dll名称放在'命令行参数'中 . 然后启动库项目右键单击它并选择Debug - > start new instance .

  • 16

    如果上述所有操作都没有帮助,请在Visual Studio中打开NUnit项目的属性,打开“Build”选项卡,单击“Advanced”按钮并确保“Debug Info”设置为“full”

  • 1

    附加nunit-agent.exe进程而不是nunit.exe,因为当dotnet版本与nunit it self使用的不同时,nunit由nunit代理执行任务 . 请参阅以下链接 .

    http://www.nunit.org/index.php?p=nunit-agent&r=2.5.10

  • 1

    使用.NET Framework 4.5时,在Visual Studio 2012 Community Edition下发生此问题 . nunit.exe.config应该是这样的(解决方案来自最受欢迎的答案):

    <configuration>
        <!--
       The GUI only runs under .NET 2.0 or higher. The
       useLegacyV2RuntimeActivationPolicy setting only
       applies under .NET 4.0 and permits use of mixed 
       mode assemblies, which would otherwise not load 
       correctly.
      -->
        <startup useLegacyV2RuntimeActivationPolicy="true">
            <!-- Comment out the next line to force use of .NET 4.0 -->
             <requiredRuntime version="4.0.30319" />
        </startup>
    
  • 0

    我需要打开NUnit GUI

    工具 - >设置 - > IDE支持[单击Visual Studio]

    然后在 nunit-x86.exe.config (NOT nunit-exe.config, NOT nunit.agent.exe.config, NOT nunit-console.exe.config)

    我需要

    <startup useLegacyV2RuntimeActivationPolicy="true">
        <supportedRuntime version="v4.0.30319" />
      </startup>
    

    <configuration>

相关问题