Edit code while debuging in visual studio - visual-studio-2010

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

Related

The Diagnostic Tools window does not support debugging using the 'Script' debug engine

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.

visual studio edit and continue does not work

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

How can I build in release in Visual Studio 2010 (C# Express)?

I'm used to VS2008, in which a release build would be built upon pressing F6, or in the menu Build > Build Solution.
The build menu is gone, and although I can build the solution (through F6), it only builds the debug.
I assume there is some kind of configuration manager now, but I can't find it anywhere.
If you have no Build Menu in Visual Studio 2010 Express, go to the menu Tools -> Settings -> select 'Expert Settings'
Right-click solution > Configuration manager.
Sorry for not looking more before asking.
Also see this thread:
How to switch between debug/release in Visual c# 2010 express
Microsoft Visual C# 2010 express:
I hope you are facing a problem to get the build for release(.exe).
I hope the following steps will help you.Anyway i faced such a problem and solved by this.good luck.
Build > configuration manager > set active solution configuration to Release
Here's an answer to the same question that has not been propagated here yet:
https://stackoverflow.com/a/3127008/78162
Namely, you also need to go to Tools->Options->Projects and Solutions and turn on "Show advanced build configurations."

No IntelliSense for C++/CLI in Visual Studio 2010?

I just moved from Visual Studio 2008 to Visual Studio 2010 (final) and noticed one major flaw:
When I try to use AutoComplete in a C++ source file for managed C++, a small note in the footer appears:
IntelliSense for C++/CLI is not available
Uh, has IntelliSense for C++/CLI been dropped from Visual Studio 2010? Is there any way to get this back? It is rather useful...
You are correct. Unfortunately it has been dropped. You can check this opened issue on Microsoft's Connect website.
I'll just quote them for the sake of the answer:
Unfortunately in this release we had to cut the intellisense support for C++/CLI due to time constraints. If you want to get some intellisense like quick info and memberlist on the native classes you can get it by choosing no /clr support in the project properties.
About getting back intellisense, your best chances for now are using third-party tools like VA Assist for example. I've tried it with Visual Studio 2008 and its IntelliSense is a whole lot better than the default one.
It is available again in Visual Studio 2012.
If you want to get IntelliSense back, install Visual Assist X from Whole Tomato Software. Here you can get a 30-days trial to check the intellisense.
According to the Visual C++ Team Blog, C++/CLI Intellisense will be in the next version of Visual Studio, but not in a service pack for VS2010. That blog post also gives some detail as to what went wrong and led to this sad state.
I don't know if you can use this settings but it work for me. I only check the Common Language RunTime Support for the cpp files that use it. I do not check it for the whole project and I've got intellisense for all the files that don't use the CLI.
Yes! you can enable the IntelliSence, but in a tricky way. Follow these instructions:
Go to your project properties. (Right click on your project name in
Project Explorer, and select Properties. or simply Alt + Enter)
From Configuration Properties, select General
In the right-hand section, find "Common Language Runtime Support"
and change it to "No Common Language Runtime Support".
Click the OK Button.
Now the IntelliSence is working. But a problem is an error when you compile your code! (The error is: error LNK1123: failure during conversion to COFF: file invalid or corrupt)
You can simply go back to Project Properties an change Common Language Runtime Support to "Common Language Runtime Support, Old Syntax (/clr:oldSyntax)".
Good luck.
This solution is only if you don't want Common Language Runtime
It worked for me in VS2010
Go to Project Propreties > Configuration Properties > General > Common Language Runtime Support and set it to No Common Language Runtime Support.
This will work fine just after hitting Apply button.
As mentioned you could install some paid software such as "Visual Assist X from Whole Tomato Software".
or
You could use open source tools that contain intellisense*, one such tool is Qt Creator 3.3.1 (opensource). You have two options, either setup your entire project with Qt to compile using VS2010 compiler, or use Qt to link to your source files and compile with VS2010. You write your code in Qt, save, flip windows to vs2010 and compile and debug.
When changes are saved in Qt, vs2010 will automatically reload the source file in the project and you can compile.

Is there a free Visual Studio addin for Nunit?

I'm cheap and don't want to pay for ReSharper or TestDriven.NET, is there a free visual Studio addin for NUnit?
You can create a blank project (Choose console application for example) and in the property of the project you can select DEBUG tag and select "Start External Program". Put the path of Nunit. Then, in the start option, the command line arguments select the DLL that contains all your tests (mine is always in the nunit\bin...). Then select "enable unmanaged code debugging" and you will be able to start the project inside VS and even use the debugger step-by-step.
This is a free solution.
Now you can use Gallio: it's open source. www.gallio.org
By the way TestDriven can be downloaded for free if it's for personal use or Open Source project.
I had to find a way to use .Net Reflector inside VS few days ago and when I downloaded TestDriven it cames with. Never got any popup asking me to paid.
NUnit actually ships with a basic integrated runner. It's not very good, and not very publicized, but unless Charlie has taken it out, it should be in the source.
I know this is an old question but another way to do this is to add an external tool from the tools menu to run nunit - set the arguments to be $(TargetName)$(TargetExt) and initial directory to $(ProjectDir)\bin\Debug
check out this link
This is an old question and things have changed since the answer was accepted.
You may try NCrunch to run tests automatically or manually.
If you're running Visual Studio 2012, there is a plugin written by Charlie Poole, one of the NUnit contributers, that makes use of the new Visual Studio Unit testing plugins.
Download VsTestAdapater - it's also in the extension manager.
Unfortunately it doesn't have much grouping options yet, either by run/not run - so you can't group by class, solution and so on. It also doesn't show you any stacktrace if a test fails, just a simple green tick or red box and a message.
I haven't used it, but NUnitit is a free Visual Studio Add-in for NUnit.
http://nunitit.codeplex.com
From my experience, the best add-in for visual studio is resharper. TestDriven.Net is also good for unit tests. Hope that helps
Also found this one : http://visualstudiogallery.msdn.microsoft.com/c8164c71-0836-4471-80ce-633383031099
It is able to launch your tests in debugger, however you need to recompile the code manually each time you change something - no auto run-build integration

Resources