简体   繁体   中英

Break Points Only Working When Project Run From Certain Locations

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 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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