In my project which is a hybrid project (in previous it was a web forms project that then we modified to use mvc pattern).
Now I want that in debug mode, I want to change something in my cs file, and
then I want the changed code to run.
I've tried enabling and disabling tools -> options -> debug -> edit and continue checkbox part.
When it is enabled I can't change code in my project while debugging.
When it is disabled I can change code but it does not affect on running part.
for example.
int i = 0;
if(i == 1)
return 1;
else
return 2;
In debug mode I changed i to 1 but it stil returned 2, in the following code, only when I stop and re-run the debugger it takes affects.
int i = 1;
if(i == 1)
return 1;
else
return 2;
BTW I am using Visual Studio 2010 version.
This wasn't my problem; running VS2017 RC2, I found that under Tools -> Options -> Debugging -> Just-In-Time - my "Managed Code" was deselected.
There was a warning "Another debugger has registered itself as the Just-In-Time debugger. Fix by enabling Just-In-Time debugging or running Visual Studio repair".
I had not registered any other debugging tools! So no idea why it unticked...
So the fix was simply to tick the "Managed" box....
None of the given answers worked. Here's what I did.
I repaired the VS installation. I had 2017 version.
I unticked the Native code checkbox.
None of the above worked for me on their own, but once I unchecked "Enable Native Edit and Continue" then it worked: under Tools -> Options -> Debugging -> General.
Under Tools -> Options -> Debugging -> General: Check the box for 'Enable Edit and Continue'.
Under Tools -> Options -> Debugging -> Just-In-Time: Check the box for 'Managed Code' Image Checking Managed Code
Save and restart Visual Studio. If you get a warning about elevated permissions, accept the dialog. Your changes are not saved yet. After restart, go again to Tools -> Options -> Debugging -> Just-In-Time: Check the box for 'Managed Code' if not showing checked. Save and restart Visual Studio.
The solution of this problem is on the Microsoft Documentation... After you enable tools-> options -> debud -> edit and continue.... There is more to do..
If IntelliTrace is enabled and you collect both IntelliTrace events and call information, Edit and Continue is disabled.
On Visual studios' menu go on Tools>>options - Select "IntelliTrace" tab and let IntelliTrace events only checked.. Save, restart the visual studio and.......
Your Edit and Continue will work again!
I discovered that my
VS2019: Project (context menu) =>
Properties =>
Debug =>
Debugger engines =>
Enable native code debugging
was turned on. After unchecking this my "Edit and Continue" issues disappeared!
Note: I had tried suggested fixes (here) prior to this discovery.
Edit & Continue doesn't work - this has fixed it for me - it's for VS2017 and started happening recently (March 2019).
It seems like NCover sets the system variable COR_ENABLE_PROFILING=1. Uninstalling it gets rid of it for me.
Repairing the VS installation, and upgrading to the current latest VS2017 version: 15.9.19 fixed the issue for me.
h-rai's answer gave me the clues I needed: unchecking the Native checkbox made a warning appear stating that another JIT debugger was registered.
Then, I found more clues in this article here
Perhaps, my issues were caused by having installed the new .NET core 3.1, but not having upgraded VS2017 to VS2019 yet.
Now, when I uncheck the "Native" checkbox, I do not get the warning about another JIT debugger, and I can modify code while debugging once again.
Before that, the Runtime Compilation was enabled by-default. For projects targeting .NET Core 3.0+ users need to explicitly enable that behavior by following the instructions https://learn.microsoft.com/en-us/aspnet/core/mvc/views/view-compilation?view=aspnetcore-3.0
install from Nuget package manager Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation
Run the below command:
Install-Package Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation -Version 5.0.7
and add below line in Startup file
services.AddRazorPages().AddRazorRuntimeCompilation();
If you've already updated Debug options but Edit&Continue still doesn't work, try cleaning and rebuilding the project. (worked for me in VS 2022)
Just press the Break All button, then edit your code, then press Continue.
It is work for me like a charm
Related
I am getting this message in the Diagnostic Tools window in Visual Studio 2015 when debugging a C# MVC web application.
I've checked solutions to a similar problem: Visual Studio 2015 diagnostics tool does not support current debugging configuration but using administrator mode and disabling "Use Managed Compatibility Mode" do not help. I've also tried disabling Options -> Debugging -> Just-In-Time -> Script, which still has no effect. It's the only reference I can find to 'Script' and I don't know how to change my debug engine.
I've also tried this solution from the web about setting the Visual Studio locale to the same as the OS, but they're both using US English. https://blogs.msdn.microsoft.com/devops/2015/05/06/known-issue-for-diagnostics-tool-window-in-visual-studio-2015-rc-the-diagnostic-tools-failed-unexpectedly/
Can anyone tell me what I'm doing wrong?
My error message is
The diagnostic tools failed unexpectedly. The Diagnostic Hub output in the Output window may contain additional information.
Try to modify the Environment Variable TEMP as following rules and reopen Visual Studio. That works for me, maybe it also works for you. My IDE is Visual Studio Enterprise 2015 Update 3.
It must only one path in TEMP. For example,
Fail:%USERPROFILE%\AppData\Local\Temp;C:\OTHER_PATH
Fail: %USERPROFILE%\AppData\Local\Temp\;C:\OTHER_PATH
Pass: %USERPROFILE%\AppData\Local\Temp
If you create a default MVC web app, and then debug your app, could you use the Diagnostics tool in your side? I test it in my side, it works well using the default settings, my OS and VS all are the English version. So you use the same language version, am I right?
If possible, you could check the following steps:
Reset your VS settings:
Open VS, TOOLS->Import and Export Settings Wizard->Reset all settings->select “No, just reset settings, overwriting my current settings”->Choose a Default Collection of settings(I often use the General or C#).
Please use the latest VS2015 with update 3.
Maybe you could download and install the match VS version as your windows directly, debug it again.
When I debug my solution, vs 2017 is very laggy and slow it's like it has to operate something heavy in the background.
So it stops "responding" every 5 seconds for 2 seconds, which is very annoying.
Any suggestions?
EDIT (tried suggestions):
Browser Link is turned off
Stopped customer feedback
After some additional investigation I found this thread
Unchecking Enable Diagnostic Tools while debugging in Tools → Options → Debugging → General did the trick!
Unchecking Enable JavaScript debugging for ASP.NET in
Tools → Options → Debugging → General
makes a huge difference in performance.
If disable Diagnostic Tools don't fix the problem try to disable IntelliTrace,
Unchecking Enable IntelliTrace, in Tools -> Options -> IntelliTrace.
Work for me.
I have tried disabling few things myself just to see what is causing it. The only thing that did work for me is Tools > Options > Debugging > General > "Enable JavaScript debugging for ASP.NET (Chrome and IE)".
I'm using VS2017 Enterprise v15.2 for Asp.net WebForms.
Hiding the Threads window did the trick for me.
I also experience the lag when "Enable Javascript debugging for ASP.NET (Chrome and IE)" is checked. And Turning off the "Enable Diagnostic Tools while debugging" did not help.
However, I also noticed that when I F12 for Chrome Developer Tools, then lag time goes away and the app performs.
Hope this helps.
Only one thing that helped me was disabling Debugger option of Resharper.
If you use Resharper, try to UNCHECK "Show local variables values in editor" in menu: Resharper -> Options -> Tools -> Debugger.
It helped for me.
What worked for me was removing all the following folders in the solution's directory:
.vs
x64
Debug
Release
I experienced same problem. In debug mode, my webforms project ran very slowly. When using Ctrl+ F5, it ran quickly (as it does when deployed). I found a try/catch block that was executing 45 times. It wasn't doing anything, it was just trapping an error that I had made. I fixed the error and, when removing the try-catch block - voila! -- back to full speed.
So if you're experiencing this problem and you've tried all the solutions above (I did), look for a try catch block that is firing often. [ Fix your error :) ] and then remove the try-catch block. I can't believe the difference it has made. Shouldn't have made any difference at all, of course, since the try-catch block wasn't doing anything, but it did.
I also had this problem, for me helped disabling Enable Edit and Continue options in Tools → Options → Debugging → General.
I gave up getting Debug=>Attach To Process working... even tried ALL the solutions on this SO post (2-pages worth).
Solution
Use ReAttach VS IDE Extension. This bypasses the need to ever use the Attach to Process dialog again if it's a process you've recently attached to.
If you are using VS 2017 Enterprise edition, try disable IntelliTrace feature
(Tools -> Options -> IntelliTrace)
with this feature turned off, the laggy behavior went away even keeping the Diagnostic tools turned on (Tools -> Options -> Debugging -> Enable Diagnostic Tools while debugging)
Sometimes it is because of a Realtime scan in Antivirus.
"Add exceptions" Visual Studio files/folders for your Antivirus
C: \ Program Files (x86) \ Microsoft Visual Studio \ 2017 \ Professional \ Common7 \ IDE \ devenv.exe
C: \ Program Files (x86) \ Microsoft Visual Studio \ 201
I had this problem where the program was running slower if started from visual studio, turned out to be too many threads, like alot of new System.Threading.Thread() in a loop etc. I switched the code to use the ThreadPool instead with Task etc and the slowness went away.
choosing "Load only specified modules" did the trick (Tools=>Options=>Debugging=>Symbols)
In my case I had a break point with a condition that was never met. I had forgotten about about this break point altogether. Sometimes adding a simple condition to a break point can slow down the debugging speed a lot.
Just adding this in case it might help someone.
workaround that I used was to run msvcmon.exe locally with admin mode before starting the debugger. Then start the attach window and providing the remote debugging port.
I've searched for the forum and I have not found how can I edit my code in Visual Studio 2010 when I am debuging.
I mean, in Tools, Edit and Continue is enabled. Also IntelliTrace is disabled, but when I try to change a simple ',' in a SQL command (for example), I can not it and I have to restart de program.
The project is in Framework 4.0.
Try this : Tools -> Options -> Intellitrace-> General -> Open Intellitrace settings and disable the Collect Call Information setting.
Another solution is to put the Project's Platform target = x86 and not x64.
If there are any DLL Interop embed, does not work.
I have to set to False Embed Interop Types and set to true a copy a local
Thanks,
Check that:
The configuration is Debug and not Release;
Enable Optimizations in Advance Compile Options (in Project Properties) is unchecked;
Unmanaged code debugging is false for all referenced projects in the solution;
Embed Interop Types is false and Copy Local is true.
If it is an ASP.NET project:
Right-click the project and select Properties
Select the Web tab
Check the Enable Edit and Continue checkbox
Go to Build-->Configuration Manager and check that Platform is set to x86 (32-bit). If you use x64 (64-bit) compile, you can't debug/change code on the fly during run-time.
Try This :
While you are debugging the code, Pause it and press F8 on your keyboard to go step by step
And here's some PICs :
I Hope My Answer Was Useful To You :)
Please... Replay If Unclear
I've written small VSIX plugin which is able to attach debugger to particular process. This process is written using c# and c++ code, so I need to attach to it using both managed and native engines. From Visual Studio it can be achieved simply by selecting these engines from window opened by DEBUG -> Attach to process... -> Select...:
Below, I've shown the code sample which basically does the same thing, using Process2.Attach2 (MSDN):
EnvDTE80.DTE2 dte = GetService(typeof(SDTE)) as EnvDTE80.DTE2;
EnvDTE80.Debugger2 dteDebugger = dte.Debugger as EnvDTE80.Debugger2;
EnvDTE80.Transport transport = dteDebugger.Transports.Item("default");
EnvDTE80.Engine[] engines = new[] { transport.Engines.Item("managed/native") };
process.Attach2(engines);
Unfortunately, the very same code which works for VS2012, doesn't work for VS2013 (Update 1).
What I've noticed is keyboard problems. Visual Studio doesn't react for pressing key shortcuts. For example, if I press F10, debugger does nothing. If I want to step over any breakpoint, I need to use mouse instead and access context menu: DEBUG -> Step Over, etc.
It's annoying, I need the keyboard to control debugger. Has anyone noticed this problem and solved it already?
BTW: If I use managed engine only (transport.Engines.Item("managed")), the keyboard starts to work correctly. But because I need to debug through unmanaged code also, I need additional engine - the native one.
EDIT: I've reported it also to Microsoft Connect network.
I've found temporary workaround. To fix that issue I opened TOOLS -> Options... -> Debugging -> General and checked Use Managed Compatibility Mode option:
What's more, this change paradoxically fixes another, seemingly unrelated issue, namely evaluation of expressions in Watch or Immediate windows for some particular cases (which I also noticed few days ago).
UPDATE:
I've detected this issue using Microsoft Visual Studio Premium 2013, Version 12.0.30110.00 Update 1
After installation of Version 12.0.30219.00 Update 2 CTP, this problem is no longer reproducible for me.
As Jarek mentioned above, this issue shouldn't repro in Update 2 CTP 2. If you are still encountering it, please reactivate the Connect bug
When I try to inspect DataSet by standard DataSet visualizer I see this error "could not load this custom viewer".
I wrote simple dataset visualizer, but error throws anyway too.
On other computers with the same configuration visualizer show without any errors.
OS: Windows 7 x86 (Release)
VS: Visual Studio 2010 RC
has somebody any ideas?
I reinstall VS with no effect.
Try the following.
-Go to Tools->options->Debugging->Plz Uncheck "Use Managed Compatibility Mode"
I had the same issue in VS 2015 and none of the answers here helped me but I found an issue on github that described my problem.
The solution, or workaround might be more accurate, for me was to turn off the option "Use the legacy C# and VB evaluators" that I (apparently) had turned on in Tools -> Options -> Debugging -> General.
The best way to diagnose this is to debug Visual Studio itself. Try the following
Get Visual Studio into the state where you want to use your Visualizer
Attach another version of Visual Studio to the original one (managed only)
Disable Just My Code (Tools -> Options -> Debugger -> uncheck "Just my Code")
Go to Debug -> Exceptions
Check the Throw box for "CLR Exceptions"
Switch back to the first VS and Attempt to show your Visualizer
This should throw an exception which will then show up in the second instance of Visual Studio. Please post back with this information if it's not enough to solve your problem.
For me. Visual Studio 2010 restart helped.
I had the same issue in VS2017, I tried a lot but nothing was worked and finally, I reset all the VS settings which I made and the error was gone.
https://blogs.msdn.microsoft.com/zainnab/2010/07/16/reset-all-your-development-settings/
I found workaround!
I changed source code of DevExpress module and recompile it. After that I undo parameter to NetFx40_LegacySecurityPolicy enabled="false", and enjoy. :)
File is "%DeveloperExpress.NET%\Sources\DevExpress.Data\Utils\Security.cs"
using System;
using System.Security;
using System.Security.Permissions;
namespace DevExpress.Data.Helpers {
public static class SecurityHelper {
public static bool IsPartialTrust {
get {
return !IsPermissionGranted(new ReflectionPermission(ReflectionPermissionFlag.MemberAccess));
}
}
public static bool IsPermissionGranted(IPermission permission) {
bool result = true;
/* (changed by Lion)
try {
PermissionSet ps = SecurityManager.ResolvePolicy((System.Security.Policy.Evidence)null);
ps = ps.Copy();
ps.AddPermission(permission);
ps.Demand();
}
catch (SecurityException) {
result = false;
}
*/
return result;
}
}
}
For me, I had written my own visualizer for a type that I had created. Apparently, this was interfering with VS 2017's ability to display the built-in visualizer for datasets. Once I removed my own visualizer and the Microsoft Debugger Visualizer reference, I could use the built-in ones.
I have written other visualizers in earlier versions of VS that didn't cause any problems.
I found the cause of this error.
According this advice http://go.microsoft.com/fwlink/?LinkID=155570 I add to devenv.exe.config this parameter
NetFx40_LegacySecurityPolicy enabled="true"
and with this parameter in .config file I have the error when try to open DataSet visualizer.
When I remove this parameter all became ok. Execption "The security state of an AppDomain was modified by an AppDomainManager configured with the NoSecurityChanges flag" fixed too.
But I NEED NetFx40_LegacySecurityPolicy enabled="true" parameter to work with old projects.
Clearing Visual Studio Cache fixed it for me.
Just follow these basic steps:
Step 1: clear the Component Cache
Close Visual Studio (ensure devenv.exe is not present in the Task Manager)
Delete the directory:
%USERPROFILE%\AppData\Local\Microsoft\VisualStudio\14.0\ComponentModelCache
If step 1 doesn't work then
Step 2: cleanup your user’s temp folder. Delete this directory:
%USERPROFILE%\AppData\Local\Temp
If step 2 doesn't work then
Step 3: Delete all these directories:
%USERPROFILE%\AppData\Local\Microsoft\Team Foundation
%USERPROFILE%\AppData\Local\Microsoft\VisualStudio
%USERPROFILE%\AppData\Local\Microsoft\VSCommon
Credit : https://errorhandlinginskills.wordpress.com/2018/07/28/how-to-clear-visual-studio-cache/
visual studio -> Tools-> options-> Debugging-> "Use Managed Compatibility Mode" - uncheck this and maybe it works fine then.
in visual studio 2019 community after an update between 16.4.x - 16.7.5 mine was broken all I had to do was uncheck "Warn when using custom debugger visualizers against potentially unsafe processes (Managed only)" and it allowed me to see a visual of the datatable. Under the tools>options>Debugging>general menu.
Just Restart your system. Your problem will be resolved.