断点只能在某些位置运行项目时工作 [英] Break Points Only Working When Project Run From Certain Locations

查看:210
本文介绍了断点只能在某些位置运行项目时工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个问题,Visual Studio不会断开任何我的断点与消息:

 断点将目前没有被击中。没有为此文件加载符号

我已经尝试了几乎所有相关的解决方案能够找到但根本没有成功(包括这里的答案)。



幸运的是,我有 .git 这是在推动它的时候工作,所以我测试克隆的存储库到各种驱动器,看看会发生什么:






C:(本地) - 这是我运行所有其他项目的地方,从未经历过此问题。但是,我不能使用这个项目的任何断点。



Y:(远程) - 这是我的部门驱动,我也做了很多调试过去没有这个问题。



H:(远程) - 这是我的个人网络驱动器 - 断点在这里不起作用。






我也尝试移动项目文件夹驱动器,但每个

相同的结果



我完全迷失了,真的很感谢任何帮助!如果有人能想到,我也很乐意进行更多的测试。

解决方案

事实证明,这是由我的后期制作, ILMerge.bat

  CMD 
ECHO参数=%1
CD%1
COPY WpfFileDeleter.exe temp.exe
ECHO..\..\ILMerge.exe
../\\..\ILMerge.exe/ out:WpfFileDeleter。 exe/ targetPlatform:v4temp.exeMicrosoft.WindowsAPICodePack.dllMicrosoft.WindowsAPICodePack.ExtendedLinguisticServices.dllMicrosoft.WindowsAPICodePack.Sensors.dllMicrosoft.WindowsAPICodePack.Shell.dllMicrosoft。 WindowsAPICodePack.ShellExtensions.dll
DEL temp.exe

此操作很好,但是问题与我如何访问 .sln



本地驱动器 p>

C:上本地构建时,构建操作成功,但一旦二进制文件与所需的.dlls,断点不能正常工作,因为 .exe 不符合现有的 .pdb (不受 ILMerge )。



通过 \\\\\ 访问网络驱动器



如果我浏览(在explorer中)到 \\\\\\\\\\\\\\\\\\\\构建操作不会运行,因为 .bat 文件无法在UNC路径上运行:


CMD不支持UNC路径作为当前目录


当构建后操作失败时,调试将使用断点正常工作。 / p>

从映射的网络驱动器运行



如果我只是通过 Y:\test 然后构建后操作确实可以正常工作,因为它读取 Y:而不是 \\ 。但是,与本地驱动器中的情况类似,这样可以防止我正常调试。



这就解释了为什么它在1(映射)网络驱动器上工作,但不是其他,以及为什么它不在 c:(因为后构建操作不允许调试)。






解决方案是仅在发布程序集上运行后构建操作,而不是 Debug


I have an issue where Visual Studio doesn't break at any of my breakpoints with the message:

The breakpoint will not currently be hit. No symbols have been loaded for this document

I have tried pretty much all the relevant-looking solutions I was able to find but with no success at all (including the answers here).

Luckily, I have version on .git which was working at the time of pushing it, so I tested cloning the repository on to various drives to see what would happen:


C: (local) - This is where I run all my other projects from and have never experienced this issue. However, I can't use any breakpoints for this project.

Y: (remote) - This is my departmental drive, where I have also done a lot of debugging in the past without this issue. The break points worked here!

H: (remote) - This is my personal network drive - the break points did not work here.


I also tried moving the project folder around in the drives, but with the same results for each

I am completely lost with this and would really appreciate any help at all! I am also happy to run more tests if anyone can think of any.

解决方案

It turns out that this was being caused by my Post-Build Action, ILMerge.bat:

CMD
ECHO parameter=%1
CD %1
COPY WpfFileDeleter.exe temp.exe
ECHO "..\..\ILMerge.exe"
"..\..\ILMerge.exe" /out:"WpfFileDeleter.exe" /targetPlatform:"v4" "temp.exe" "Microsoft.WindowsAPICodePack.dll" "Microsoft.WindowsAPICodePack.ExtendedLinguisticServices.dll" "Microsoft.WindowsAPICodePack.Sensors.dll" "Microsoft.WindowsAPICodePack.Shell.dll" "Microsoft.WindowsAPICodePack.ShellExtensions.dll"
DEL temp.exe

This action works fine, but the problem is to do with how I access the .sln

Local drive

When building locally on C:, the build-action is successful, but once the binary has been merged with the required .dlls, break points no longer work properly as the .exe wont coincide with the existing .pdb (which is unaffected by ILMerge).

Network drive accessed via \\\\

If I navigate (in explorer) to \\\file\test\, the build action won't run because .bat files cannot operate on UNC paths:

CMD does not support UNC paths as current directories

When the post-build action fails, debugging will work correctly with break points.

Running from a mapped network drive

If I just navigate to the folder via Y:\test then the post-build action does work, because it reads Y: instead of \\. However, similar to the scenario in the local drive, this prevents me from debugging properly.

This explains why it worked on 1 (mapped) network drive, but not the other, and also why it was not working on c: (because the post-build action wouldn't allow it to be debugged).


The solution to this is to only run the post-build action on Release assemblies and not Debug.

这篇关于断点只能在某些位置运行项目时工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆