简体   繁体   English

JetBrains Rider 中没有击中断点?

[英]Breakpoints not being hit in JetBrains Rider?

I am trying to set a breakpoint in JetBrains Rider, but the debugger isn't breaking.我试图在 JetBrains Rider 中设置断点,但调试器没有中断。

I know for sure the application should reach the code I'm trying to break on, as changing string literals appears in the program.我确定应用程序应该到达我试图中断的代码,因为更改字符串文字出现在程序中。

I have completely reinstalled all my JetBrains programs (wiping settings).我已经完全重新安装了我所有的 JetBrains 程序(擦除设置)。 I've also tried every answer in this thread: break point is not hitting while debugging , with no luck.我也试过这个线程中的每一个答案: 断点在调试时没有命中,没有运气。

This bug doesn't occur in Visual Studio, but does occur with any project in Rider.此错误不会出现在 Visual Studio 中,但会出现在 Rider 中的任何项目中。

It also doesn't happen on my other copy of Rider that I use on my other PC.我在其他 PC 上使用的其他 Rider 副本也不会发生这种情况。

I appreciate any help, thanks!我很感激任何帮助,谢谢!

One more caveat: I started using Rider again after an absence, I was pressing the "play" (triangle) button rather than the button with a picture of a bug.还有一个警告:我在缺席后再次开始使用 Rider,我按下的是“播放”(三角形)按钮,而不是带有错误图片的按钮。

(D'oh!) (哦!)

For .Net Framework projects:对于 .Net Framework 项目:

This can happen if Rider attached the debugger to a different process than the process that IIS is using.如果 Rider 将调试器附加到与 IIS 正在使用的进程不同的进程,则可能会发生这种情况。

  • Open Run on Rider menu and click on "Attach to process" or ctrl+alt+F5打开 Run on Rider 菜单并单击“附加到进程”或 ctrl+alt+F5
  • Type w3wp, this will find all the processes IIS is running on.键入 w3wp,这将找到 IIS 正在运行的所有进程。 If you found multiple processes you can hover on them to see which AppPool is related to that process.如果您发现多个进程,您可以将鼠标悬停在它们上以查看哪个 AppPool 与该进程相关。
  • Click on the process to attach debugger to it.单击进程以将调试器附加到它。
  • The breakpoint should be hit now.现在应该命中断点。

And make sure you are using the URL that Rider provides you when you run your project (http://localhost:XXXX), because the URL that Rider uses might be different than the Host Name you set for your IIS.并确保您使用的是 Rider 在运行项目时为您提供的 URL (http://localhost:XXXX),因为 Rider 使用的 URL 可能与您为 IIS 设置的主机名不同。

I've found what was causing it.我找到了造成它的原因。

As of Rider 2018.1.3, the solution you're running must be on the same disk as the copy of Rider you're using.从 Rider 2018.1.3 开始,您正在运行的解决方案必须与您正在使用的 Rider 副本位于同一磁盘上。

This issue is referenced on JetBrains support here .此问题在此处的 JetBrains 支持中被引用。

You can temporarily solve this by either moving your solution to the same drive, or by reinstalling Rider.您可以通过将解决方案移至同一驱动器或重新安装 Rider 来临时解决此问题。

What I did before was :我之前做的是:

  1. Open the solution打开解决方案
  2. Set some breakpoints设置一些断点
  3. Click the 'bug' button in Rider (next to the play button)单击 Rider 中的“错误”按钮(播放按钮旁边)
  4. Chrome would open up automatically with an URL pointing to my services Chrome 会自动打开一个指向我的服务的 URL
  5. The service would work as expected, but breakpoints would not work该服务将按预期工作,但断点不起作用
  6. Stop the service停止服务
  7. Modify some code修改一些代码
  8. Start the service启动服务
  9. Refresh the Chrome Windows from step 4从第 4 步刷新 Chrome Windows
  10. I would see the modifications in Chrome.我会在 Chrome 中看到修改。 But no breakpoints would get hit.但是没有断点会被击中。

Now the only thing I changed is that in after step 2 I now do a现在我唯一改变的是在第 2 步之后我现在做一个

Run --> Attach to a local process... --> w3wp运行 --> 附加到本地进程... --> w3wp

After this, I just do the same steps as before, but now the breakpoints do get hit...在此之后,我只是执行与以前相同的步骤,但现在断点确实被击中......

Refrence 参考

In relation to Jessica's answer above, it appears that opening a solution in Rider using the System absolute path (ie /System/Volumes/Data/Users/... ) appears to act as though it's on a separate drive.关于上面 Jessica 的回答,使用 System 绝对路径(即/System/Volumes/Data/Users/... )在 Rider 中打开解决方案似乎就像它在单独的驱动器上一样。

After driving myself crazy for about four hours, I created a new solution and changed the solution directory from the system path to /Users/... then copied my project to this new solution which fixed the breakpoints, and opening the project from the Rider welcome screen now shows the solution directory as a relative path ( ~/Users/... )在把自己逼疯了大约四个小时后,我创建了一个新的解决方案并将解决方案目录从系统路径更改为/Users/...然后将我的项目复制到这个修复断点的新解决方案中,并从 Rider 打开项目欢迎屏幕现在将解决方案目录显示为相对路径 ( ~/Users/... )

Another solution for you (or other people who come across this):您(或遇到此问题的其他人)的另一个解决方案:

When you have "COMPlus_EnableDiagnostics": "0" in your configuration or launchSettings you won't be able to hit breakpoints either.当您的配置或启动设置中有"COMPlus_EnableDiagnostics": "0"时,您也将无法命中断点。

清理和重建解决方案,然后删除和读取断点对我有用!

None of these solutions worked.这些解决方案都没有奏效。 Solutions of clearing caches through the Rider interface and stuff like that, none of them worked.通过 Rider 界面和类似的东西清除缓存的解决方案,它们都没有奏效。 None of them.他们都没有。

The problem: a previously working referenced project of custom code (not some external library or nuget package) broke the breakpoints.问题:以前工作的自定义代码引用项目(不是一些外部库或 nuget 包)打破了断点。 Breakpoints outside the package worked, but not in the referenced project.包外的断点有效,但在引用的项目中无效。 I was getting that "stop sign" symbol in which it couldn't resolve a method.我得到了无法解析方法的“停止标志”符号。

The only thing that worked was to completely erase all instances, and previous instances, of Rider from Application Support and Caches on my mac.唯一有效的方法是从我的 Mac 上的应用程序支持和缓存中彻底清除 Rider 的所有实例和以前的实例。 After following the instructions to completely erase Rider on their website, and then reinstalled it, I was able to get the breakpoints working again.按照说明在他们的网站上完全删除 Rider,然后重新安装它后,我能够让断点再次工作。 Sorry, but for some of you this may be the only thing you can do.对不起,但对于你们中的一些人来说,这可能是你唯一能做的事情。

If you're using .NET core and IIS, make sure the Application pool has 'No Managed Code' under '.NET CLR Version' in the Basic Settings:如果您使用的是 .NET core 和 IIS,请确保应用程序池在基本设置中的“.NET CLR 版本”下具有“无托管代码”:

在此处输入图像描述

For anybody who has the same problem in Xamarin Android project.对于在 Xamarin Android 项目中遇到相同问题的任何人。 For me the breakpoints in the android project where working, like in the main activity but not in the shared project.对我来说,android项目中的断点工作,比如在主要活动中,而不是在共享项目中。

How i fixed it: Go to your android.csproj file and edit it.我如何修复它:转到您的 android.csproj 文件并进行编辑。 Search your build target and check for <EmbedAssembliesIntoApk>true</EmbedAssembliesIntoApk> If this is true , breakpoints in additional modules are not working.搜索您的构建目标并检查<EmbedAssembliesIntoApk>true</EmbedAssembliesIntoApk>如果这是true ,则其他模块中的断点不起作用。 Set it to false, or even better, remove this line completely.将其设置为 false,或者更好的是,完全删除此行

I had this problem too and the cause was a spurious <ContinuousIntegrationBuild>true</ContinuousIntegrationBuild> in the csproj.我也有这个问题,原因是 csproj 中的虚假<ContinuousIntegrationBuild>true</ContinuousIntegrationBuild> Removing this setting restored debugging capabilities.删除此设置可恢复调试功能。

9 times out of 10, this happens because one of these reasons: 10 次中有 9 次发生这种情况是因为以下原因之一:

 1) You did not attach to the correct process 2) The code is not executing on the breakpoint

If you're running into this issue when trying to hit an API endpoint如果您在尝试访问 API 端点时遇到此问题

Make sure you have WebDAV disabled in your "Enable Programs and Feature" section of Windows.确保在 Windows 的“启用程序和功能”部分中禁用了 WebDAV。

For some reason this seems to block API requests, which in turn will make you be unable to hit a breakpoint.出于某种原因,这似乎会阻止 API 请求,从而使您无法命中断点。 Personally, I had to spend several hours recreating the call in Postman to actually see that something in IIS was blocking the request (even though the authorization was correct).就我个人而言,我不得不花几个小时在 Postman 中重新创建调用,才能真正看到 IIS 中的某些内容阻止了请求(即使授权是正确的)。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM