Here's what I've tried:
Made a new Console App (.NET Framework) in Visual Studio 2017.
Added the following code:
static void Main(string[] args)
{
new Dictionary<int, int>().TryGetValue(3, out int x); //I want to step into TryGetValue() (this is just an example)
}
Configured the settings listed here:
https://blogs.msdn.microsoft.com/sburke/2008/01/16/configuring-visual-studio-to-debug-net-framework-source-code/
Confirmed symbols are loaded in the Modules window:
mscorlib.dll Symbols loaded. 4.6.1586.0 built by: NETFXREL2
Tried: "Step Into (F11)"
Tried: "Step into Specific" | "System.Collections.Generic.Dictionary.TryGetValue"
Both just step over the line.
I've tried configuring VS using the details here: http://www.symbolsource.org/Public/Home/VisualStudio
Same result, the debugger steps over the line.
I've looked at the answer here: https://stackoverflow.com/a/12432029/297451
But this version doesn't seem to be a security update, and a search for "site:support.microsoft.com/kb 4.6.1586.0" yields nothing.
What am I doing wrong?
Here is the answer, thanks to Hans Passant. Note that this solution raises additional questions.
Ensure https://referencesource.microsoft.com/ contains the exact version you're debugging.
How? Reference source specifies ".NET Framework 4.6.2" but a module version is something like: "4.6.1586.0"
You may need to uninstall security updates as explained here: How do you enable "Enable .NET Framework source stepping"?
Configure Visual Studio as specified here:
https://referencesource.microsoft.com/setup.html
Untick "Enable Just My Code"
Tick "Enable .NET Framework source stepping" (this should have been the only step needed)
Tick "Enable source server support"
Untick "Require source files to exactly match the original version"
Confirm symbols are loaded in the Modules window, with source indexing included.
How can you tell if source indexing is included? The modules window doesn't specify if a PDB has stripped source information.
Microsoft could make this process a lot more robust by giving helpful error messages instead of silently failing.
Use the Symbol Server feature in JetBrains dotPeek. Worked like a charm for me after struggling to get the standard functionality to work:
Run dotPeek and go to Tools > Options... > Symbol Server.
Ensure that "All assemblies" is selected and copy the local symbol server URL to the clipboard. Start the dotPeek symbol server by clicking it in the Tools menu.
In Visual Studio, go to Tools > Options... > Debugging > Symbols and add the dotPeek server URL to the list. Move the dotPeek symbol server as high up the list as possible, and uncheck all other symbol servers in the list (in particular, the "Microsoft Symbol Servers" and "NuGet.org Symbol Server" must not be selected).
Start debugging - when you attempt to step into Framework source code, you will see dotPeek doing some work decompiling the assembly for you, and then you will be into its source.
If this doesn't work, it's probably because Visual Studio has previously downloaded the "wrong" symbols for the assembly in question from Microsoft/NuGet, and is using them instead of asking dotPeek. To check this, start debugging and find the relevant assembly in the modules list (Debug > Windows > Modules) - delete the PDB file at the path displayed under "Symbol File" for that assembly, then restart debugging, and dotPeek should kick into action.
I am using some NuGet packages in my projects which have their source publicly available in GitHub (example OrmLite).
How can I configure their repositories as debugger sources in Visual Studio (the same way I could configure ReferenceSource for the .NET Framework etc... like here)?
ReSharper is able to decompile the DLLs, but I am more interested in seeing the comments which are obviously not available this way.
Update:
I know about the pdb files, but the initial intension was to see the source code when I hit F12. For the .NET Framework that is acheived by simply adding the ReferenceSource as I explained before
What you are looking for is http://symbolsource.org, which is a platform for hosting open source pdb (debugging) files.
To use it, you'll need to update your Visual Studio instance to pull pdb's from there (http://www.symbolsource.org/Public/Home/VisualStudio):
Go to Tools -> Options -> Debugger -> General.
Uncheck “Enable Just My Code (Managed only)”.
Uncheck “Enable .NET Framework source stepping”. Yes, it is misleading, but if you don't, then Visual Studio will ignore your custom server order (see further on).
Check “Enable source server support”.
Uncheck “Require source files to exactly match the original version”
Go to Tools -> Options -> Debugger -> Symbols.
Select a folder for the local symbol/source cache.
Add symbol servers under “Symbol file (.pdb) locations”. Pay attention to the correct order, because some servers may contain symbols for the same binaries: with or without sources. We recommend the following setup:
http://referencesource.microsoft.com/symbols
http://srv.symbolsource.org/pdb/Public or the authenticated variant (see above)
http://srv.symbolsource.org/pdb/MyGet or the authenticated variant (see above)
(other symbol servers with sources)
http://msdl.microsoft.com/download/symbols
(other symbol servers without sources)
Note: Not every nuget package also uploads symbols to SymbolSource (as it requires an additional publishing step). So you might need to contact the developer of the project and ask them to upload it, or if the project is open source, you could do it yourself.
Use the original source-code from GitHub by download the relevant VS code projects and add them to your solution for references instead of using the binaries.
I have installed VS 2015 RTM (nothing else) and I'm unable to debug any solution, not matter if it's an existing one or a brand new one (created with VS 2015 and compiled against .Net Framework 4.6), it only opens a new tab in VS which is called Break Mode with the following text:
The application is in break mode
Your app has entered a break state, but no code is executing that is supported by the selected debug engine (for e.g. only native runtime code is executing).
And if I check the Debug --> Module Window:
VS2015Test.vshost.exe no symbols loaded (even if I click load symbol it does not work)
VS2015Test.exe symbols loaded
And it also doesn't show the output on the console(it's a console application that just has the following lines of code:
class Program
{
static void Main(string[] args)
{
Console.WriteLine("TEST");
Console.ReadKey();
}
}
I tried to reinstall VS 2015, restarted the computer, deleted all files in %temp%/AppData/Microsoft/Visual Studio/14, started VS in Admin Mode but nothing seems to work.
One thing which makes debugging working is this option:
Tools --> Options --> Debugging --> Use Managed Compability Mode
^^But that can't be the solution to use an old/legacy mode.
BTW: Debugging in VS 2013 is working fine.
Any help would be appreciated.
In my case this solution is useful:
Solution: Disable the "Just My Code" option in the Debugging/General settings.
Reference: c-sharpcorner
I was having this same problem with VS2015. I reset the settings, as suggested but still had trouble.
What I had to do to fix it was check "Use Managed Compatibility Mode" and "Use Native Compatibility Mode". Not sure which of those 2 is necessary but checking both and I no longer get the Break Mode issue.
I had a very similar issue recently, related to debugging settings.
Firstly have you tried resetting all your settings? I think it may be related to that as you say it is project independent and you've deleted all application data.
Tools-> Import and Export Settings Wizard -> Reset all settings
Don't worry, it gives you the option to save current settings.
Secondly if this fails, I would suggest looking at the event log.
Entering break mode would suggest that the DE (debug engine) is sending a synchronised stop event to visual studio like IDebugExceptionEvent2. I would take a look at the event log for exceptions like failures in loading referenced assemblies (like .NET runtimes, etc) or environment access restrictions.
Something is telling the debugger to stop your running application, its just a case of finding it.
Thought I would post this in case it helps anyone. I installed a clean Win 10 and Visual Studio 2015, tried to debug an existing solution and had problems. Followed some advice listed here and other places but none worked.
How I got the debugging to work as normal was to change the Solution Configuration just below the menus. I had it set previously to Release mode, changed this to Debug and then cleaned/recompiled and hey presto, debugging started working as normal. See the image for info:
My solution suddenly stopped to work in debug.
I received a message during debug.
[Window Title]
Microsoft Visual Studio
[Main Instruction]
You are debugging a Release build of NettoProWin.exe. Using Just My Code with Release builds using compiler optimizations results in a degraded debugging experience (e.g. breakpoints will not be hit).
[Stop Debugging] [Disable Just My Code and Continue] [Continue Debugging] [Continue Debugging (Don't Ask Again)]
I chose to continue to debug, but it still did not work.
The solution was simple. It is necessary in the project properties -> in the build section -> remote the check "Optimiz code"
Check the "Code Type" before attaching to a Process. For example, I had to switch from CoreCLR to v4.*
In my case,
I have changed Platform from x86 to x64 in Debug Configuration Manager. It worked for me.
I disabled avast file system shield and then all worked normal again.
avast-setting wheel= active protections- top button off.
Same is required to publish projects. A real nightmare
I had a problem similar to this when trying to use Debugger.Launch to debug a web application: the JIT Debugger Selection window never appeared. I knew it wasn't a problem with VS debugging mechanism itself because it fired just fine with a console app.
Eventually a colleague mentioned a "global debugger registry setting" which set off a light bulb.
I was using Microsoft's DebugDiag some months ago to troubleshoot IIS crashing, and I had a rule registered to capture IIS crash dumps, which obviously (in retrospect) registered the Debug Diagnostic Service as the debugger for w3wp (IIS worker process).
Removing the rule in DebugDiag, or stopping the Debug Diagnostic Service ("C:\Program Files\DebugDiag\DbgSvc.exe") re-enabled Visual Studio's JIT debugging.
Hope this helps someone.
Uhg. I hit the bottom of this page so I started ripping apart my project. I found a solution for my particular problem.
My Issue: I couldn't hit the break-point inside a threaded process. Nothing fancy, I'm just starting a new thread in a console app and the debugger wasn't stopping on the break points. I noticed the thread was being created but it was getting hung up in .Net Framework external calls and specifically the ThreadStart_Context. That explains why my breakpoints never got hit because the .Net Framework is getting hung up something.
The Problem: I found that I could solve this by changing my startup code. For whatever reason, I had a program.cs file that contained Main() and was inside the Program class as you would expect for a console app. Inside Main(), I was instantiating another class via this code;
new SecondClass();
This normally works fine and I have a bunch of other projects with Threaded calls where it works fine (well, I haven't debugged them for some time so perhaps a service pack came along and is causing this regression).
The Solution: Move Main() into my SecondClass and instead of invoking the SecondClass constructor via 'new SecondClass()', update the SecondClass constructor to be a standard static method and then call it from Main. After making those changes, I am able to debug the thread once again.
Hope this helps.
After installtion of vs 2017,while debugging the solution,there was an error like "Webkit has stopped functioning correctly; Visual Studio will not be able to debug your app any further.",this makes unable to proceed the debugging.To resolve this issue,Go to Tools->Options->Debugging->General then disable the javascript debugging for asp.net
I have had similar issues on my svc application run on visual studio 2015, the solution was to change solution platform from "Any CPU" to "x86", if you cannot see the x86 option then click on "Configuration Manager" and go to your target project and change the platform, you'll need to select the dropdown and click "New", on the pop up, click the drop down list under "new platform" and select x86, save your changes and rebuild(See attached)
Stop debugging.
Edit csproj.user file
Find section wrote below:
<SilverlightDebugging>True</SilverlightDebugging>
Change Value to "False"
Unload and reload your project in Visual Studio.
Sometimes it needed to close Visual Studio.
A friend had the same problem, he couln't debug in VS2015 but it was ok in VS2013. (our project is in .Net v4.0)
We have found that it was the "Code Type" option in Debug / Attach to Process that was set to "Managed (v3.5, v3.0, v2.0)" instead of "Managed (v4.5, v4.0)"
I had this issue, and none of the (myriad of) posts on here helped. Most people point towards settings, or options, turning on Debug mode, etc. All of this I had in place already (I knew it wasn't that as this was working fine yesterday).
For me it turned out to be a referencing issue, a combination of DLLs that were included were to blame. I can't say exactly what the issue was, but I have a couple of classes that extended base classes from another project, an implemented interface that itself extends from another interface, etc.
The acid test was to create a new class (in my case, a Unit Test) within the same project as the one failing to Debug, then create an empty method and set a breakpoint on it. This worked, which further validated the fact my settings/options/etc were good. I then copied in the body of the method that failed to Debug, and sure enough the new method starts failing too.
In the end I removed all references, and commented out all the lines in my method. Adding them back in one by one, checking Debug at each step, until I found the culprit. I obviously had a rogue reference in there somewhere...
We had this issue, after trying all other options such as deleting .vs folder, Renaming IISExpress folder name, Updating various setting on properties etc it did not work. What worked though, was uninstalling IISExpress 10.0, and Reinstalling it along with turning all IIS related features on from Windows Features. Hope this helps someone.
I changed my Platform Target from "Any CPU" to "x64".
Setting available at : Project Properties -> Build -> General: "Platform Target"
I use VS 2015.
I found I had to go to the project settings -> web, and tick the Enable Edit and Continue checkbox. I cannot say why it was unchecked to begin with, but this solved it for me.
from Solution Explorer -> Web -> Properties
select Build tab -> Configuration combobox:
Just change your Configuration from "Release" to "Active (Debug)"
In my case it was due to the project Target platforms were different.
Consider : ProjectA (Entry) --> ProjectB
ProjectA's platform in properties was set to x64.
And ProjectB's platform was 'AnyCPU'.
So after setting ProjectB's target platform to x64 this issue got fixed.
Note: It's just that Target Platform has to be in sync be it x64 or
'Any CPU'
In my case, I found a hint in the output window that the exception that stopped the debugger was a ContextSwitchDeadlock Exception, which is checked by default in the Exception Settings. This Exception typically occurs after 60 seconds in Console applications. I just unchecked the exception and everything worked fine.
I had this same issue. In my case, the dll I was trying to debug was installed in the GAC. If your debugging breakpoint hits when you aren't referencing any object in the target assembly, but doesn't when you reference the assembly, this may be the case for you.
I had this problem after deinstallation of RemObjects Elements 8.3 Trial version. Reinstall Elements 8.3 is a quick bugfix.
I got in this issue as well. I'm using VS 2015 (Update 3) on Windows 10 and I was trying to debug a Windows Forms Application. None of the suggestion worked for me. In my case I had to disable IntelliTrace:
Tools > Options > IntelliTrace
I dont know the reason why, but it worked. I found out the root of the problem when I opened the Resource Monitor (from Windows Task Manager) and I realized that IntelliTrace process was reading a tons of data. I suspect this was causing locks in vshost process, because this one was consuming 100% of a cpu core.
I hade the same problem. After trying the other solutions here without luck, I had to repair the installation through the installer.
Control Panel > Programs > Programs and Features
Then scroll down to Microsoft Visual Studio, right click it, then "Change". Then at the bottom of the window, click Repair. The repair process will take a decent amount of time, and at the end you will have to restart your computer.
This fixed the problem to me, and I hopes it will help you.
I am trying to configure visual studio to enable me to step into the .net framework source code when I am debugging.
I have tried with both Visual Web-Developer-Express-2010 and Visual-Studio-2011-Express-For-Web as well as Visual-Studio-2011-Express-For-Web on Win8CP and I am getting the same problem with each.
I have read numerous tutorials on how to set it up and the settings I have I believe to be correct.
Debugging General Settings -
also -
Debugging Symbol Settings -
I have tried both of these symbol servers. When I click Load all Symbols this is the output I get saying symbol loads have failed -
Large scale version link
If I run the code to the breakpoint, right click and select the specific method to step into like so -
large scale version link
I get this tab -
Large scale version link
If I look in my SymbolCache folder, there is only a FailedLoads folder with these contents -
Large scale version link
My project is in debug mode. I have also tried running VS as administrator. I have full control over the SymbolCache directory. I am on a home network and have full access to my internet connection.
Why is this not working?
Source stepping is only available for RTM or SP releases.
See http://social.msdn.microsoft.com/Forums/en-US/refsourceserver/thread/1b74f60c-e961-425c-a38e-362406dd4cfe.
Since 4.5 assemblies keep the same version number as 4.0 (stupid idea), then there is no way to get compatible symbols + source right now, so this is impossible with VS11 installed. You must start over with a clean machine and don't install .NET 4.5.
This is really stupid … the whole point of versioning just thrown out the window.
Have you set up the environment to load the symbols (note: by default, the symbols are not set to load - have not checked VS 11, btw (will do so later)).
You can also check out this article for info on symbols. I will have to check if there is a manual download for symbols for .NET.
You can also set up source server manually to http://referencesource.microsoft.com/symbols. You cannot browse the reference source.
I had this problem - no symbols loading - and spent a week trying to solve it. My problem was that I had for the first time started using Master pages in my website project. And I was incorrectly creating the content pages; the error was that i was not indicating the codebehind file in the page directive of the content page so my codebehind file was in essence unconnected to the build of the project. A dumb mistake and simple fix after a week of frustration. Hope this helps some lost programming soul stuck with the same problem.