简体   繁体   English

Visual Studio 2015 项目不再在调试模式下运行

[英]Visual Studio 2015 project no longer runs in debug mode

This is what I get even when I run in the Debug configuration:这就是我在调试配置中运行时得到的结果:

The way I got this to show was by enabling "Just My Code" and warn if there isn't any user code on launch.我让这个显示的方式是启用“仅我的代码”并警告启动时是否没有任何用户代码。 This is something that recently happened to our project, and I'm not sure what we did to cause this.这是我们项目最近发生的事情,我不确定我们做了什么导致这种情况。 But I've been unable to fix it.但我一直无法修复它。 Breakpoints won't fire and quick watch gives weird results.断点不会触发,快速观察会给出奇怪的结果。

I've tried googling the issue, but none of the standard "break points won't fire" solutions have worked.我试过在谷歌上搜索这个问题,但没有一个标准的“断点不会触发”解决方案奏效。 I'm all out of ideas.我都没有想法了。

I've checked the configuration manager and every project is also set to Debug there as well.我检查了配置管理器,每个项目也都设置为调试。

在此处输入图片说明

I turned off "Enable Optimaizations", and I no longer get the "you are debugging a Release build" dialog.我关闭了“启用优化”,并且不再出现“您正在调试发布版本”对话框。 It runs and stops on breakpoints again!它再次运行并在断点处停止! However the output window displays this at start up:然而,输出窗口在启动时显示:

Symbols for the module 'Navigo.exe' were not loaded.未加载模块“Navigo.exe”的符号。

  1. Use a debug build configuration or disable the debug option 'Enable Just My Code'.使用调试构建配置或禁用调试选项“启用我的代码”。
  2. Check the 'Symbols' settings under debugging options.检查调试选项下的“符号”设置。

So this solves my primary problem of no longer being able to use breakpoints and the popup.所以这解决了我不再能够使用断点和弹出窗口的主要问题。 Which is odd since I thought you needed symbols to be loaded for breakpoints to work.这很奇怪,因为我认为您需要加载符号才能使断点工作。 So how can the breakpoints work if the symbols aren't loaded?那么如果没有加载符号,断点如何工作? Maybe it's just a bad message?也许这只是一个坏消息?

Use the Configuration Manager to check what the actual settings are for the Debug configuration - it's at menu BuildConfiguration Manager... - in case they are set to use Release :使用配置管理器检查调试配置的实际设置 - 它位于菜单BuildConfiguration Manager... - 如果它们被设置为使用Release

配置管理器

Also, make sure the project is defining DEBUG correctly, and that "Optimize Code" is not checked:另外,请确保项目正确定义了DEBUG ,并且未选中“优化代码”:

特性

This has happened to me on a couple of projects too.这也发生在我身上的几个项目中。 I reviewed my build settings, as suggested by stuartd .按照 stuartd 的建议检查了我的构建设置。 However, 'Optimize code' was not enabled in my build settings.但是,我的构建设置中启用“优化代码”。 So I enabled it and saved the project.所以我启用了它并保存了项目。 Then I unchecked it and saved again.然后我取消选中它并再次保存。 Problem solved.问题解决了。

There's some kind of bug that causes the --optimize+ flag to be passed to the debugger.有某种错误导致--optimize+标志被传递给调试器。 Enabling it and then disabling it is an easy workaround until the bug is fixed.启用它然后禁用它是一个简单的解决方法,直到错误得到修复。

This started happening to me after applying Update 1. Existing projects started showing this, and I can replicate it with a brand new project.在应用更新 1 后,这开始发生在我身上。现有项目开始显示这一点,我可以用一个全新的项目复制它。 All configuration is set to DEBUG, and Optimize is not checked.所有配置都设置为DEBUG,勾选Optimize

The kicker is, running the project the first time (or after a Clean) runs just fine, without any message.关键是,第一次(或在 Clean 之后)运行项目运行得很好,没有任何消息。 Stopping, then re-running the project (note - the project is not rebuiblt ) will display the dialog.停止,然后重新运行项目(注意 - 该项目不是 rebuiblt )将显示该对话框。

The only solution is to turn off the Just My Code option - which seems a hack, as it was on previous to Update 1 without any problems.唯一的解决方案是关闭“仅我的代码”选项 - 这似乎是一个黑客,因为它在更新 1 之前没有任何问题。

If none of mentioned solutions has helped, check your project's AssemblyInfo.cs for explicit DebuggableAttribute application.如果上述解决方案都没有帮助,请检查项目的 AssemblyInfo.cs 以获取显式 DebuggableAttribute 应用程序。 It seems like it overrides compiler's debug/release options.它似乎覆盖了编译器的调试/发布选项。

I had this line in the file in my case (legacy project, no idea how it got there).在我的案例中,我的文件中有这一行(遗留项目,不知道它是如何到达那里的)。 Deleting it solved the problem:删除它解决了问题:

[assembly: System.Diagnostics.Debuggable(System.Diagnostics.DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]

I encountered this issue as well.我也遇到了这个问题。 The fix that worked for was to simply clean ( Build > Clean Solution ) and rebuild ( Build > Rebuild Solution ) my projects.有效的修复方法是简单地清理( Build > Clean Solution )和重建( Build > Rebuild Solution )我的项目。

None of the previous answers worked for me.以前的答案都不适合我。 Restarting IIS fixed it.重新启动IIS修复了它。

Just adding a side note to stuartd's answer :只需在stuartd 的回答中添加一个旁注

Be sure you check any dependent projects for the same build settings.确保您检查任何依赖项目的相同构建设置。 You will get the same message prompt if your main project has the proper settings, but your dependent projects do not.如果您的主项目具有正确的设置,但您的从属项目没有,您将收到相同的消息提示。 It makes obvious sense in hindsight, but it wasn't the first thing to come to mind.事后看来,这显然是有道理的,但这并不是第一个想到的事情。

In my case the problem was that the IIS Project URL in my ASP.NET project properties web tab was set to the wrong URL.就我而言,问题是我的 ASP.NET 项目属性 Web 选项卡中的 IIS项目 URL设置为错误的 URL。

It was pointing to http://localhost which I was using with a different copy of the project.它指向http://localhost ,我正在使用该项目的不同副本。 The address for the solution I had open was actually configured on my local IIS as http://localhost:90 .我打开的解决方案的地址实际上在我的本地 IIS 上配置为http://localhost:90

Changing to the correct address fixed the problem.更改为正确的地址解决了问题。

在此处输入图片说明

I had the same issue... No matter what I did - nothing worked.我有同样的问题......无论我做什么 - 都没有效果。

It was an new empty project that was the problem.这是一个新的空项目,这是问题所在。 I ended up removing the project and adding a new project - the new project had to have another name ;我最终删除了该项目并添加了一个新项目- 新项目必须有另一个名称 if I used the same name the error just reappeared - even after a reboot, clean and rebuild... It must be a bug in Visual Studio 2015.如果我使用相同的名称,错误就会再次出现 - 即使在重新启动、清理和重建之后......它一定是 Visual Studio 2015 中的错误。

For me, it was a NuGet reference from a private NuGet server.对我来说,它是来自私有 NuGet 服务器的NuGet引用。 I don't know how it was compiled, but changing the reference to a project reference got me past the problem.我不知道它是如何编译的,但是更改对项目引用的引用让我解决了这个问题。

I tried pretty much everything in this list, but in the end I fixed this by opening the solution properties and switching from "Multiple startup projects" to "Single startup project" and back again.我尝试了此列表中的几乎所有内容,但最后我通过打开解决方案属性并从“多个启动项目”切换到“单个启动项目”并再次返回来解决此问题。

  1. Right-click on the solution and choose "Properties"右键单击解决方案并选择“属性”
  2. Under "Common properties" change the selection "Multiple startup projects" to "Single startup project"在“通用属性”下,将选择“多个启动项目”更改为“单个启动项目”
  3. Click OK单击确定
  4. Run debugging运行调试
  5. End debugging and repeat steps 1-3, but switch back to "Multiple startup projects"结束调试并重复步骤 1-3,但切换回“多个启动项目”
  6. Run debugging again with multiple projects使用多个项目再次运行调试

I've opened my Visual Studio 2012 Pro project in Visual Studio 2015 Express and had the same issue.我在Visual Studio 2015 Express 中打开了我的 Visual Studio 2012 Pro 项目并遇到了同样的问题。

I checked my Solution properties → Configuration Properties , and discovered a project was set to Release & x86.我检查了我的解决方案属性 →配置属性,发现一个项目被设置为 Release & x86。

I changed it back to Debug and Any CPU , and the prompt has gone.我把它改回DebugAny CPU ,提示消失了。

In my case, I was developing a VSTO plugin for Outlook , and Outlook was accidentally loading the Release version of the DLL file that I recently installed while testing my installer.就我而言,我正在为Outlook开发VSTO插件,而 Outlook 在测试安装程序时意外加载了我最近安装的 DLL 文件的发行版。

It looks like Visual Studio was trying to use that DLL instead of the Debug one I expected.看起来 Visual Studio 正在尝试使用该 DLL 而不是我期望的 Debug 。 Fixing which DLL file is being loaded by Outlook fixed this for me.修复 Outlook 正在加载哪个 DLL 文件为我解决了这个问题。

I met the same problem, and finally I solved it by choosing "Disable Just My Code and Continue" .我遇到了同样的问题,最后我通过选择“禁用仅我的代码并继续”来解决它。

Just My Code Setting只是我的代码设置

Resolution steps:解决步骤:

  • Go to the Build settings of the offending project's Properties page.转到违规项目的“属性”页面的“构建”设置。

  • Scroll right down to the “Advanced...” button.向下滚动到“高级...”按钮。

  • Make sure “Debug Info:” is not set to “none” .确保“调试信息:”设置为“无”

    I recommend you to use the full option.我建议您使用完整选项。

After viewing the link by Patrick as a comment to the question , someone noted a workaround which was to stop the site in IIS Express .在查看Patrick链接作为对该问题的评论后,有人注意到了一种解决方法,即在IIS Express 中停止该站点。 I was able to prevent this same problem from arising by doing just that after stopping the debugger in Visual Studio.在 Visual Studio 中停止调试器后,我能够通过这样做来防止出现同样的问题。

However, I was looking into it more, and I believe it could also be related to the 'Edit and Continue' setting for the debugger.但是,我对它进行了更多研究,我相信它也可能与调试器的“编辑并继续”设置有关。 When I disabled that in the menu ToolsOptions... of Visual Studio, I no longer had the problem.当我在 Visual Studio 的菜单工具选项...中禁用它时,我不再遇到问题。 But then that would prevent you from using the Edit and Continue feature, so I am not sure if that's worth it to you.但这会阻止您使用“编辑并继续”功能,因此我不确定这对您是否值得。

Menu ToolsOptionsDebuggerEdit and Continue (scroll to the bottom of the General list) → uncheck the Edit and Continue checkbox.菜单工具选项调试器编辑并继续(滚动到常规列表的底部)→ 取消选中编辑并继续复选框。

I also experienced this suddenly after installing Update 1, but it could just be that I had this setting off in the first place...I am not sure though.安装更新 1 后,我也突然遇到了这种情况,但可能只是我一开始就关闭了此设置……不过我不确定。

Copying my other answer from here .这里复制我的其他答案。

As mentioned by @romanoza, Microsoft has updated the bug report with the following information:正如@romanoza 所提到的,Microsoft 已使用以下信息更新了错误报告:

Uncheck the setting Debug -> Options -> Suppress JIT optimization on module load (Managed only)取消选中设置 Debug -> Options -> Suppress JIT optimization on module load (Managed only)

This is the workaround.这是解决方法。 They go on to say later:他们后来继续说:

We recommend folks leaving it unchecked as having it unchecked will improve both performance and the behavior of just my code in specific scenarios.我们建议人们不选中它,因为不选中它会提高性能和在特定场景中仅我的代码的行为。

Lastly, the acknowledgement:最后,致谢:

It is a bug that it doesn't work with that setting enabled and we're working on a fix for that situation in case some customers still want to debug with that setting turned on.这是一个错误,它在启用该设置的情况下不起作用,我们正在针对这种情况进行修复,以防某些客户仍然希望在启用该设置的情况下进行调试。

In case you just need to keep going without any further delays, select the last option from the popup and all will run the same as before.如果您只需要继续前进而不会有任何进一步的延迟,请从弹出窗口中选择最后一个选项,所有选项都将像以前一样运行。

在此处输入图片说明

This was a weird alert.这是一个奇怪的警报。

Rebuilding the Solution won't necessarily clear all the DLL files (especially ones copied from dependent projects).重建解决方案不一定会清除所有 DLL 文件(尤其是从依赖项目复制的文件)。

However, rebuilding the dependency project made this alert go away.但是,重建依赖项目使此警报消失。

I faced this with Visual Studio 2015 Update 3.我在 Visual Studio 2015 Update 3 中遇到了这个问题。

My solution was a little different from all the others and is a bit unique.我的解决方案与所有其他解决方案略有不同,而且有点独特。

I'm working with a website that contains a mix of managed code and ASP Classic , both referencing the same assembly.我正在使用一个包含托管代码和ASP Classic混合的网站,两者都引用相同的程序集。 Visual Studio was complaining that my managed DLL file was a release build. Visual Studio 抱怨我的托管 DLL 文件是发布版本。

The issue was an uncaught exception in my assembly, but it was being thrown by a ASP Classic page via interop.问题是我的程序集中一个未捕获的异常,但它是由 ASP Classic 页面通过互操作抛出的。 Visual Studio wasn't able to handle debugging this and displayed the error message. Visual Studio 无法处理调试此问题并显示错误消息。 The same exception thrown from managed code would have brought up the debugger as expected.从托管代码抛出的相同异常会按预期启动调试器。

Correcting the issue in my managed assembly's constructor fixed everything.更正我的托管程序集构造函数中的问题修复了一切。

It all makes sense now that I look back at the big picture, but at the time, the error message led me down a very deep path, and I tried everything in the answer here until I had that "Ah-ha!"现在我回顾大局,这一切都说得通,但当时,错误消息使我走上了一条非常深的道路,我在这里尝试了所有答案,直到我听到“啊哈!” moment.片刻。

我花了两天时间,看起来重置 Visual Studio 2017 实验实例对我有帮助。

I'm using VS 2019 v16.10.4 and just ran into this.我正在使用 VS 2019 v16.10.4 并且刚刚遇到了这个问题。 The "Check Optimize Code option -- Save -- Uncheck Optimize Code option -- Save" in the project options Build screen routine worked but ONLY after restarting VS.项目选项构建屏幕例程中的“检查优化代码选项 - 保存 - 取消选中优化代码选项 - 保存”有效,但仅在重新启动 VS 后。

Side-note: Amazing - this was asked 5 years, 11 months ago but it is still not fixed ...旁注:太神奇了 - 这是 5 年零 11 个月前问过的,但它仍然没有修复......

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 更新到Visual Studio 2015后,应用程序不再以发布模式运行 - Application no longer runs in release mode after updating to Visual Studio 2015 WPF:应用程序在Visual Studio调试模式下运行的速度比可执行文件慢得多 - WPF: App runs much slower in Visual Studio Debug Mode than executable Xamarin项目在Visual Studio 2015中不可用 - Xamarin project unavailable in Visual Studio 2015 Visual Studio 2017-工作项目不再编译 - Visual Studio 2017 - A working project no longer compiles 在Visual Studio 2015中引用另一个项目 - Referencing another project in Visual Studio 2015 将Visual Studio 2015项目转换为Visual Studio 2017? - Convert Visual Studio 2015 project to Visual Studio 2017? Visual Studio 在调试与发布模式下发布 - Visual Studio publish in debug Vs Release mode Visual Studio 2012不会在调试模式下异常停止 - Visual Studio 2012 not stopping at exception in debug mode 当我在设计模式下调试某个表单时,Visual Studio崩溃了......“灾难性的失败” - Visual Studio crashes when I debug a project with a certain form open in design mode…“Catastrophic failure” 在Visual Studio调试模式下的WebForm项目仅显示IIS默认页面 - WebForm project in Visual Studio Debug mode only show IIS default page
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM