visual-studio VS 2010、NUUnit 和“当前不会命中断点。没有为此文档加载符号”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3076807/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
VS 2010, NUNit, and "The breakpoint will not currently be hit. No symbols have been loaded for this document"
提问by Brian Mains
Using Windows 7 32 bit, VS 2010, .NET 4 DLL, NUnit (2.5.5) to unit test the application. I'm currently getting the following error; seen plenty of posts and tried the following:
使用 Windows 7 32 位、VS 2010、.NET 4 DLL、NUnit (2.5.5) 对应用程序进行单元测试。我目前收到以下错误;看了很多帖子,尝试了以下方法:
- restart machine
- restart VS
- delete bin/obj and reload
- clean/rebuild
- 重启机器
- 重启VS
- 删除 bin/obj 并重新加载
- 清理/重建
But I cannot get NUnit to hit my breakpoints when running;
但是我无法让 NUnit 在运行时达到我的断点;
I set the NUNit test project to point to the nunit.exe, and to load the testing .NET 4 DLL, but when I run it doesn't find the breakpoint, "no symbols have been loaded". I tried debug >windows > modules, it doesn't even show my unit testing project when I run it.
我将 NUNit 测试项目设置为指向 nunit.exe,并加载测试 .NET 4 DLL,但是当我运行它时没有找到断点,“没有加载任何符号”。我试过 debug >windows > modules,当我运行它时它甚至不显示我的单元测试项目。
I found this, to use the nunit agent: http://groups.google.com/group/nunit-discuss/browse_thread/thread/5680d7def5b6982f
我发现这个,使用 nunit 代理:http://groups.google.com/group/nunit-discuss/browse_thread/thread/5680d7def5b6982f
But I get an error when I use the nunit agent too. I was using nunit-agent-x86.exe, but I get a system.formatexception and it crashes...
但是当我使用 nunit 代理时也出现错误。我正在使用 nunit-agent-x86.exe,但我得到一个 system.formatexception 并且它崩溃了......
Can anybody help?
有人可以帮忙吗?
Thanks.
谢谢。
采纳答案by Brian Mains
The resolution was: start NUnit stand alone, then in VS 2010, do debug > attach to process, and attach to the nunit-agent.exe process, not the nunit process. Nunit process still didn't do it for me.
解决方案是:单独启动 NUnit,然后在 VS 2010 中,执行调试 > 附加到进程,并附加到 nunit-agent.exe 进程,而不是 nunit 进程。Nunit 进程仍然没有为我做这件事。
回答by Dave Bacher
There's another similar question here on Stack Overflow, where I posted my answerwith what worked for me. I can set breakpoints and start NUnit directly from Visual Studio 2010 with Debug -> Start New Instance (which I think is your goal).
Stack Overflow 上还有另一个类似的问题,我在那里发布了对我有用的答案。我可以通过 Debug -> Start New Instance(我认为这是您的目标)直接从 Visual Studio 2010 设置断点并启动 NUnit。
I set nunit.exe as the external program in project -> Properties -> Debugging and added:
我在项目 -> 属性 -> 调试中将 nunit.exe 设置为外部程序并添加:
<startup>
<requiredRuntime version="4.0.30319" />
</startup>
to the nunit.exe.config file found next to the nunit executable in the NUnit install directory.
到 NUnit 安装目录中 nunit 可执行文件旁边的 nunit.exe.config 文件。
回答by JimBayne
I was getting "break point will not be hit ... no symbols loaded ..." for a website project. Found that there were build errors in my website (one of the referenced dll's went missing for some reason). Rebuilds didn't show the problem until I selected View=>Error list in VS2010, prior to the rebuild. Replacing the missing dll in the bin dir & updating the reference solved my problem.
对于一个网站项目,我收到了“不会命中断点......没有加载符号......”。发现我的网站中存在构建错误(引用的 dll 之一由于某种原因丢失了)。直到我在重建之前在 VS2010 中选择 View=>Error list 后,重建才显示问题。替换 bin 目录中丢失的 dll 并更新参考解决了我的问题。
回答by Daniel
Adding the following section in the nunit-x86.exe.config worked for me:
在 nunit-x86.exe.config 中添加以下部分对我有用:
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0,Profile=Client"/>
</startup>
The 'sku' section is only needed when running with .NET 4's Client Profile. Note that a previous answer showed using 'requiredRuntime' which is obsolete.
只有在使用 .NET 4 的客户端配置文件运行时才需要“sku”部分。请注意,先前的答案显示使用已过时的“requiredRuntime”。
回答by user2195750
If all of the above did not help, open the Properties of your NUnit project in Visual Studio, open "Build" tab, click the "Advanced" button and make sure "Debug Info" is set to "full"
如果以上所有方法都没有帮助,请在 Visual Studio 中打开 NUnit 项目的属性,打开“构建”选项卡,单击“高级”按钮并确保“调试信息”设置为“完整”
回答by Manasvi Sareen
Attach nunit-agent.exe process instead of nunit.exe because when dotnet version is different form what is used by nunit it self, nunit execute the task by nunit agent. See the link below.
附加 nunit-agent.exe 进程而不是 nunit.exe 因为当 dotnet 版本与 nunit 它自己使用的版本不同时,nunit 由 nunit 代理执行任务。请参阅下面的链接。
回答by Alexei
This problem occurred to me under Visual Studio 2012 Community Edition, when working with .NET Framework 4.5. nunit.exe.config should like this (solution from the most appreciated answer):
在使用 .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>
回答by patrick
I needed to open the NUnit GUI
我需要打开 NUnit GUI
Tools->Settings->IDE Support [click Visual Studio]
工具->设置->IDE支持【点击Visual Studio】
Then in the nunit-x86.exe.config(NOT nunit-exe.config, NOT nunit.agent.exe.config, NOT nunit-console.exe.config),
然后在nunit-x86.exe.config (NOT nunit-exe.config, NOT nunit.agent.exe.config, NOT nunit-console.exe.config) 中,
I needed
我需要
<startup useLegacyV2RuntimeActivationPolicy="true">
<supportedRuntime version="v4.0.30319" />
</startup>
under <configuration>
在下面 <configuration>
回答by Mau
Are you running NUnit and then loading the DLL? Try instead opening the project properties, Debug tab, switch the start action to 'Start external program', point to the NUnit exe, put your dll name in 'command line arguments'. Then start the library project right-clicking it and choosing Debug -> start new instance.
您是否正在运行 NUnit 然后加载 DLL?尝试打开项目属性,调试选项卡,将启动操作切换到“启动外部程序”,指向 NUnit exe,将您的 dll 名称放在“命令行参数”中。然后启动库项目,右键单击它并选择 Debug -> start new instance。

