Stop Visual Studio asking for each project: has been modified outside the environment. Do you wish to reload? - visual-studio

Do you wish to reload the project? Where's the Reload All option.
Vote for this question and hopefully MS will implement a fix in VS2020.
With pleany of projects in a solution I for one dread doing an svn update.
This has been an issue from VS2003 but after a decade of clicking mindlessly on buttons it's getting on my wick.
Does anyone have a hack / registry entry / secret way of saying yes short of saying ignore (quick), closing and reloading the solution?

There are a couple of options you can tweak for this scenario. Both are under the Documents Options
Tools -> Options
Environment -> Documents
The first option is to just uncheck "Detect when files changed outside the environment". This will stop the reload dialog but will force you to manually reload.
The second option just below it is a bit better "Auto-load changes, if saved". This will just automatically load the changes without prompting you for every project.
Personally though I would go a slightly different route here. The problem is occuring because your managing your source code control outside of Visual Studio. If you switched to using an addin to manage within Visual Studio it would remove these problems altogether. For svn there are several free packages available including Ankhsvn which is fairly popular

http://msdn.microsoft.com/en-us/library/ms165643(VS.80).aspx
DetectFileChangesOutsideIDE
Get/Set (Boolean)
Determines whether the environment automatically reloads files opened in the IDE when the operating system notifies the IDE that the files have been modified on disk.
EDIT:
Some clarification, as that page isn't immediately obvious.
Tools Menu->Options -> Environment->Documents->Uncheck Detect when file is changed outside the Environment

Related

How can I save code changes in debugging mode in vb6

When an app stops in debugging mode and I make changes to the code
Is there a way to save the code with the changes, without stop the app?
Although the VB6 IDE does not provide this natively, an add-in for the IDE called MZTools has been around for ages which adds this feature.
Personally I've used MZTools 3.0 for many years, and this works really well.
This is what its help system says:
Shortcut To Save File At Debug-Time
The Shortcut To Save File At Debug-Time feature allows you to define a keyboard shortcut (Options
window, Shortcuts tab) to save the selected file at debug-time. The
Visual Basic IDE does not allow to save files at debug-time, but often
it is useful to save the modifications that you have made to the
source code at debug-time.
Remarks:
This feature is not available in the VBA version of MZ-Tools. This
feature only works at debug-time. Since Visual Basic disables buttons
or menus of add-ins at debug-time, the only way to save a file at
those times is through a keyboard shortcut. The file must be
previously saved at design-time, that is, MZ-Tools does not prompt for
a name to save the file (it shows an error message instead).
This is the options window for how I have it configured locally:
Note that originally MZTools was free in version 3 and later they switched to a paid version; if I hadn't gotten v3 originally however it would be well worth paying for, not only for this feature.
The short answer is you can't.
If you make the project before the crash, maybe this piece of code can be found in a ".tmp" file. But searching in .tmps is often a waste of time.
I particularly always force myself to stop the debug and save my progress.
And I always use this setting which forces me to remember to save:

Visual Studio doesn't remember changes to settings

I've noticed that my VS15 forgets changes I make to the settings in options and check boxes under Tools on reboot.
For instance, when I exchange a string in a document, I get the pop-up telling my how many substitutions have been made. There's the check box showing/hiding this message next time. I uncheck it and fairly enough the pop-up doesn't come up again. Until I restart VS, that is. After that, the pop-up is back!
The same goes for many other options (typical NuGet packages' suggestion based on the contents of CSHTML-file, for instance). However, all the settings I make in Resharper menu are remembered. Also, the key short-cuts seem to be remembered.
I restarted, updated and reinstalled - no luck there. Starting VS in admin mode gives no change, neither. I noticed that if I change the values in the registry, the changes are effective in VS. It's like VS won't write the modified settings to the registry by itself (and I'm damn sure too chicken and too lazy to horse around in the registry for that).
Has anybody else experienced that?
What more can I do to diagnose it?
How do I kill the problem?

Detect file changes outside the Visual Basic 6 IDE?

Background
I am working with VB6 legacy code and I am using an external editor because of the features that it has. Unfortunately, those changes aren't refreshed in the IDE because VB6 doesn't monitor loaded code for changes.
I have done some extensive searching on the subject including looking for alternative editors, a fairly exhaustive internet search including following all of the links on this StackExchange link and haven't found a way to refresh the code window to reflect the external file changes.
My company doesn't have access to the latest edition of Visual Studio and will not be purchasing it anytime in the near future. Until then, there is code to fix.
Question
Aside from restarting the program are there any methods that can be used to refresh the code displayed in the VB6 editing window?
Check out vbAdvance add on. It will prompt you to reload source file in case of external modification.
I think a found one possible solution.
The MZ-Tools set has an function called Reload file from Disk. It also allowed me to create a shortcut for this function through the MZ-Tools options menu, so I assigned it to the shortcut keys of my choosing.
It's a solution, but I'm still looking for anything that might be better.

TFS and working with multiple solutions

How do people generally deal with TFS when you've got to work with multiple solution files? If you've got one instance it's easy because you can always go to that window for the source control explorer, pending changes, check on builds or work items. But when you have 4-5 solutions, it becomes tricky to deal with. You might expand some folders or check some pending items on one VS instance but you have to remember which one you did it on.
Having a separate instance dedicated just to TFS tasks is tempting, but there's only one window state for the whole program. If that instance is closed last, all instances will come up with all the TFS windows open.
How do other people deal with this? Can you use separate profiles somehow and cordon off a "TFS" instance of Visual Studio?
Use the Pending Changes window. View -> Other Windows -> Pending Changes. This has a toolbar option to show only those changes pending for the current solution also. It's the last toolbar button in the Pending Changes window. I usually make this a full document in VS and then memorize the keyboard shortcut to it: ALT+V, E, H. Obviously you could bind your own shortcut, but what fun is that.
Eclipse has a similar perspective/view to Pending Changes, but it's name escapes me and I don't have my Ubuntu VM up at the moment.
Solution Explorer and Source Control Explorer are definitely not my recommendation for check-in activities. I personally like to clear out all of the checkboxes on Pending Changes and then Diff each file. This keeps me from A) waiting too long before a checkin (it sucks to compare 20 files 1 by 1) and B) avoids checking in a change I didn't intend.
If you have multiple instances of Visual Studio open at one time (which I'm not quite sure why you would need to do this), your changes are "synchronized" across all instances of Visual Studio. Don't do your check-in from the solution explorer, do it from the Source Control explorer, then you're sure to get all your updates in a single check-in.
You might find VSCommands useful when working with VS/TFS - it can be configured to display the Solution and TFS Branch name in the title bar, this indication is invaluable when working with multiple instances of VS (or multiple branches of the same project).

Edit and Continue: "Changes are not allowed when..."

Even if I create a clean WinForms project, Edit and Continue doesn't work and gives me the error:
Changes are not allowed when the debugger has been attached to an already running process or the code being debugged was optimized at build or run time.
Edit and Continue option is checked in Tools → Options → Debugging.
Optimization is not enabled.
Seems like there is no any managed profiler set up.
I am running in Debug mode
I am running on x64 CPU and Windows XP 32-bit, but setting platform target to x86 rather than AnyCpu doesn't help.
Repairing Visual Studio installation doesn't help.
I also found this article on MSDN website:
Unsupported Scenarios
Edit and Continue is not available in the following debugging scenarios:
Debugging on Windows 98.
Mixed-mode (native/managed) debugging.
SQL debugging.
Debugging a Dr. Watson dump.
Editing code after an unhandled exception, when the "Unwind the call stack on unhandled exceptions" option is not selected.
Debugging an embedded runtime application.
Debugging an application with Attach to rather than running the application with Start from the Debug menu.
Debugging optimized code.
Debugging managed code when the target is a 64-bit application. If you want to use Edit and Continue, you must set the target to x86. (Project Properties, Compile tab, Advanced Compiler setting.).
Debugging an old version of your code after a new version failed to build due to build errors.
But I can answer "No" to every item in this list.
It worked before, but several days ago it stopped working, and I don't know what could be the reason.
Other Applicable Solutions:
Below is an incomplete, unordered list of possible solutions to try if you* are trying to fix Edit & Continue quickly.
Make sure you are in Debug Mode
Make sure you're not launching a mixed mode process
Try to set the CPU target to x86 rather than AnyCPU (on x64 machines)
Uncheck the Optimize Code checkbox for Debug Mode in Project Properties->Debug
Uncheck the Optimize Code checkbox in Project Properties->Build
Uncheck Enable Optimizations in Advanced Compiler Settings
(ASP.NET) Check nightcoder's answer if it is the case
(ASP.NET) Check this answer (by matrixugly) if it is the case
(ASP.NET) Ensure you have Edit and Continue enabled on the Web tab (vs2010)
(ASP.NET) Go to Properties > Web > Servers, and make sure that Enable and continue is checked under Use Visual Studio Development Server.
(ASP.NET WebAPI) Make sure you've stopped in the Controller's method using a breakpoint, before trying to edit it.
(vs2017) Go to Tools > Options > Debugging and uncheck (deselect) 'Edit and Continue'. This is actually the opposite of the 'conventional' advice (see some other points in this post). It does not allow you to actually make changes in your running program (i.e. it does not hot-swap the code changes that you make) - it simply allows you to edit your code (i.e. it prevents that annoying message and "locking" your editor).
Go to Tools > Options > Debugging > General and make sure Require source files to exactly match the original version is unchecked.
Check Enable Windows debug heap allocator (Native only) [VS Community 2017]
Are you using Microsoft Fakes? It inhibits Edit & Continue.
Kill all the *.vshost.exe instances by selecting End Process Tree in the Task Manager. VS will regenerate a correct instance.
Remove all the breakpoints with Debug->Delete All Breakpoints
Enable and Continue exists in both the Tools > Options > Debugging menu and also in the Project Settings. Be sure to check both places. edit & Continue is not supported with the extended Intellitrace setting.
Be sure Debug Info in Project Properties > Build > Advanced > Output > Debug Info is set to Full
Some plugin may be interfering. Check by disabling/uninstalling and then trying again the other solutions.
If you're not paying enough attention, the error you get while trying to fix this may change to something else that is easier to diagnose. E.g. A method containing a lambda expression cannot support edit and continue.
Make sure the System variable COR_ENABLE_PROFILING is not set to 1. Some profilers set this when installing and leave it like that after uninstalling. Open a command prompt and type set to quickly check it your system is affected, if so remove the variable or set it to 0:
In Windows 8 and above, search for System (Control Panel).
Click the Advanced system settings link.
Click Environment Variables.
Remove COR_ENABLE_PROFILING
Be aware of unsupported scenarios (as reported in the question) and that unsupported edits.
* by 'you', I mean the visitor of the page who is hammering his head on a keyboard to find The solution.
Feel free to edit this answer to add your workaround if not listed here!
If you're debugging an ASP.NET application, go to properties > web > Servers, and make sure that "enable and continue" is checked under Use Visual Studio Development Server.
I finally got to solve the problem: UNINSTALL Gallio
Gallio seems to have quite some many rough edges and it's better to not use MbUnit 3.0 but use the MbUnit 2.0 framework but use the gallio runner, that you are running without installing from the installer (which also installed a visual studio plugin).
Incidentally, I had the issue even after "disabling" he Gallio plugin. Only the uninstall solved the problem.
PS. Edited by nightcoder:
In my case disabling TypeMock Isolator (mocking framework) finally helped! Edit & Continue now works!!!
Here is the answer from TypeMock support:
After looking further into the edit
and continue issue, and conversing
about it with Microsoft, we reached
the conclusion it cannot be resolved
for Isolator. Isolator implements a
CLR profiler, and according to our
research, once a CLR profiler is
enabled and attached, edit and
continue is automatically disabled.
I'm sorry to say this is no longer
considered a bug, but rather a
limitation of Isolator.
I had the same problem. I even re-installed VS 2008 but the problem did not go away. However, when I deleted all the break points then it started to work.
Debug->Delete All Breakpoints
I think it was happening because I had deleted an aspx page that had break points in its code, and then I created another page with the same name. This probably confused the VS 2008.
"Edit and Continue", when enabled, will only allow you to edit code when it is in break-mode: e.g. by having the execution paused by an exception or by hitting a breakpoint.
This implies you can't edit the code when the execution isn't paused! When it comes to debugging (ASP.NET) web projects, this is very unintuitive, as you would often want to make changes between requests. At this time, the code your (probably) debugging isn't running, but it isn't paused either!
To solve this, you can click "Break all" (or press Ctrl+Alt+Break). Alternatively, set a breakpoint somewhere (e.g. in your Page_Load event), then reload the page so the execution pauses when it hits the breakpoint, and now you can edit code. Even code in .cs files.
Couple of things to check
Make sure your compile is set to Debug vs. Release
Make sure you're not launching a mixed mode process
If on a 64 bit machine Make sure to set the CPU target to x86 rather than AnyCPU
EDIT
I don't believe this should matter but make sure that the hosting process is enabled for the target platform. Probably won't help.
If it repros for new projects then it might be something even more subtle. I would try the following.
Backup HKCU:\Software\Wow6432Node\VisualStudio\9.0 (maybe just rename it)
Delete the same key
Try the repro again
None of the above solutions worked for me(running on a 64x machine).
Finally I clicked on 'advanced compiler settings' and UNCHECKED 'enable optimizations' and I can now step through code and edit while debugging.
For me, for a reason that I don't understand, the setting "Generate debug info" in the "Advanced Compiler Settings" was set to "pdb-only" instead of "Full".
By default, this parameter is always set to "Full" but a mysterious poltergeist has changed this parameter on last night. :)
P.S. I'm in Visual Basic .Net with Visual Studio 2010
If your concern is with an ASP.NET app, ensure you have edit and continue enabled on the web tab (vs2010). There was also a separate setting for ASP.NET debugging in earlier versions.
Regards,
Adam.
I found that even though under project properties build & debug tab are set to Debug and all the other setting are correct I still get the message, however after digging some more
under the Build menu select Configurations Manager... and make sure Debug is selected in two places there as well. go figure...how many different places do they need to set debug?????? even though you set Project - Configuration to Debug then under Build - Manager it is not changed so you have change the same setting there as well Project Configuration - seems like a microsoft issue again.......
This problem is due to Intellitrace setting
If Intellitrace is enabled make sure Intellitrace event only is checked
Otherwise this will not allow edit and continue..
If you will click on Intellitrace options you will see the warnings.
Following shooting helped me using VS2010:
go to Tools, Options, Debugging, General and make sure "Require source files to exactly match the original version" is unchecked.
That happens when the debugger hasn't hit a breakpoint or you haven't hit Break All (pause). It couldn't be that simple could it?
The error says a possible cause is: "the code being debugged was optimized at build or run time". Go to Project Properties->Debug and uncheck the Optimize Code box for Debug mode.
I had this problem in Microsoft Visual Studio 2008 and the solution is easy. when you run your project please set in "Debug" mode not "Release". The another people solution can be useful.
If I create a new project, edits while debugging do not work. If I create a new website, edits while debugging work as expected.
I ran into this today - turns out that having Debug Info set to pdb-only (or none, I'd imagine) will prevent Edit and Continue from working.
Make sure your Debug Info is set to "full" first!
Project Properties > Build > Advanced > Output > Debug Info
In my case just reseting to default debugger settings and setting IntelliTrace-> only intellytrace events helps
Some things that seemed to help using VS2010:
go to Tools, Options, Debugging, General and make sure "Require source files to exactly match the original version" is unchecked.
multiple .vshost.exe instances can be left over from e.g. detaching the VS debugger from a stopped process. This will interfere with breakpoints and compiles as well. Use Task Manager, Processes tab to kill all instances of .vshost.exe by right-clicking each instance and selecting End Process Tree. VS will create a new instance.
I removed a dataset from my project because I didn't use it. After that I could modify the program when debugging.
I did all the changes mentioned in every other answer and none worked. What did I learn? Enable and Continue exists in both the Tools > Options > Debugging menu and also in the Project settings. After I checked both, Enable and Continue worked for me.
Seems illogic, but only way was disabling edit and continue from VS 2017 options... Then AspNet edit and continue began to work...
what worked for me was unchecking "Use Managed Compatibility Mode" under
Tools -> Options -> Debugging
TBN: checking or unchecking "Require source file to exactly match the original version" seems not influences the E&C
Hope this can help.
Enable edit and Continue only work run IIS Express.
Don't work in Local ISS or External Host.
I'm adding my answer because the thing that solved it for me isn't clearly mentioned yet. Actually what helped me was this article:
http://www.rubencanton.com/blog/2012/02/how-to-fix-error-changes-are-not-allowed-while-code-is-running-in-net.html
and here is a short description of the solution:
Stop running your app.
Go to Tools > Options > Debugging > Edit and Continue
Disable “Enable Edit and Continue”
Note how counter-intuitive this is: I had to disable (uncheck) "Enable Edit and Continue".
This will then allow you to change code in your editor without getting that message "Changes are not allowed while code is running".
Note however that the code changes you make will NOT be reflected in your running program - for that you need to stop and restart your program (off the top of my head I think that template/ASPX changes do get reflected, but not VB/C# changes, i.e. "code behind" code).
I install the stackify, when i enable this on icon tray, it stop my debugging with edit, so i found
Close the visual studio , in my case its vs2017
Go to icon tray and right click on stackify icon and disable .NET Profiler
Open Visual studio run application again in debug mode with debugger and it allow me edit while debugging
I had this annoying issue since I upgraded my VS 2019 to 16.4.3 and caused me a lot of headache.
Finally I solved the problem this way:
1. Stop Debugging
2. Select the solution from "Solution Explorer"
3. In the Properties window change the "Active config" Property From "Release|Any CPU" To "Debug|Any CPU"
4. In Debug > Options > General Check the Edit and Continue checkbox
That worked for me, and hope it works for you too.
embed interop types visual studio should be set to false
I had this happen in a linked class file. The rest of the project allowed E&C, but I got the same error editing the linked file. Solution was to break linked file into it's own project and reference the project.
I faced the same problem. My problem was that I could modify a file, but not another (both are in same project). Later I found that the file I couldn't modify was also part of another project. That another project (Unit Test) wasn't loaded, and intelligent VS debugger shows the error that assembly for this given file was not loaded, and changes aren't allowed. How weird!
Hence, I had to unload the unit-test project and continue the EnC debugging.

Resources