Is there anyway to tell Visual Studio not to open all the documents when I load solution? - visual-studio

When you open a solution in Visual Studio 2008 (or ealier versions for that matter), it opens all the documents that you did not close before you closed Visual Studio. Is there anyway to turn this functionality off, or a plugin that fixes this behavior? It takes forever to load a solution with 50 files open?

Have you tried deleting the .suo file?
It's a hidden file that lives beside your solution (sln) file. suo is "solution user options", and contains your last configuration, such as what tabs you left open the last time you worked on the project, so they open again when you
reload the project in Visual Studio.
If you delete it, a new 'blank' suo file will be recreated silently.

You can automate the process of closing all the files prior to closing a solution by adding a handler for the BeforeClosing event of EnvDTE.SolutionEvents -- this will get invoked when VS is exiting.
In VS2005, adding the following to the EnvironmentEvents macro module will close all open documents:
Private Sub SolutionEvents_BeforeClosing() Handles SolutionEvents.BeforeClosing
DTE.ExecuteCommand("Window.CloseAllDocuments")
End Sub
Visual Studio 2008 appears to support the same events so I'm sure this would work there too.
I'm sure you could also delete the .suo file for your project in the handler if you wanted, but you'd probably want the AfterClosing event.

From Visual Studio 2017 Update 8 there is an option in projects and solutions which you can use to enable this:

ALT-W-L
That's the key combination to close all open tabs, which can be pressed before closing a project, unless you prefer clicking Window | Close All Documents before closing the project.
--Gus

I dont think there is an option for this (or I couldnt find one) but you could probably write a macro to do this for you on project open.
This link has some code to close open files which you could adapt:
http://blogs.msdn.com/djpark/
I couldnt find the answer to this particular question but a good link for ide tips and tricks is:
http://blogs.msdn.com/saraford/default.aspx

Alternative answer:
Before you close your solution, press and hold Ctrl+F4, until all windows have been closed.

VS attempts to save the last known view. Other than the scripts mentioned above you can manually close all documents before exiting VS

Related

Where does Visual Studio store the watch window data?

I use to have some complex expressions in the watch window and out of a sudden the watch window is completely empty now. Of course I can put the expressions back manually but it would be really interesting to know where Visual Studio stores the watch window data? I doubt that it's stored in some solution related file since after a clean build the watches are still there.
I am using Visual Studio 2013 on Windows 10.
Watch window information is stored in the .suo file for the solution. I couldnt find it in any of the official documentation for, but the breakpoints are there and if you configure the watch window, then close VS, then delete the .suo file and open VS the watch window is empty. After closing VS, restoring the .suo file and opening VS again the watch window configuration is back. This is confirmed for instance by this blog post:
What informations are saved in my .suo file
This file is used by Visual Studio to store user/solution specific
information such as Opened Files, Expanded Nodes in the Solution
Visual Studio .suo fileExplorer, Opened Tool Windows and its
Positions, User Tasks, Breakpoints, Start-up Project, Contents of
Watch window, Whether the project is loaded/unloaded etc. The same
file is used by Visual Studio Addins (VSPackages) to persist
information that are specific to that solution/user.
I don't know where your .suo file went though, did you accidentally delete it?

Why is ReSharper's cleanup code option unavailable?

When using ReSharper in Visual Studio, I often cannot run the "code cleanup" option, as it is grayed out in the menu. I have also tried using the hotkey but I get the error message: The key combination (Ctrl+E, C) is bound to command (ReSharper_CleanupCode) which is not currently available.
I've done a lot of research about it online and found that often the reason this option is not allowed is that the file I am working on has not been added to the solution explorer.
If I add the JavaScript file I'm working on to the solution explorer, it then allows me to code cleanup, but this is EXTREMELY inconvenient for me; I open many files in my work and I do not want to make a new project/solution, then manually add the file each time to use this ReSharper feature. (also by adding files to the solution explorer, the files stop saving and I have to manually copy/paste the code from them into the original document when I'm done working with them.)
Is there a setting in ReSharper that I can change to allow me to code cleanup my currently selected file under all circumstances without needing to add it to the solution manual first?
If not, is there a way to configure or utilize Visual Studio 2015 in such a way that allows me to easily add JavaScript/CSS/HTML files to Visual Studio and also to the solution explorer when I don't have a solution/project already created and loaded? (and also actually save the file when I'm done working on it to where I dragged/dropped it from, rather than embedded in a solution file (.sln)?) (Currently, Visual Studio DOES save files with CTRL + S, but ONLY if it has not been added to a solution/project. It's currently how I'm editing all of my files.)
I realize this is quite old, but I encountered this in VS2017 with Resharper 2018.1.2.
The only "workaround" I found was to Suspend Resharper, then Resume it.
Tools -> Options -> Resharper Ultimate -> General -> Suspend Now
Then in the same menu
Resume Now.

Visual Studio 2013 - Open .aspx and .cs files from other project at the current project

Probably it's a stupid question but i would like to open aspx and cs files from the windows explorer without opening a new instance of visual studio, is this possible?
Greets,
Firmino
There are several ways you can improve your experience opening files in VS.
You can use drag and drop
Troubleshooting: You can't drag and drop between apps in Windows if one of them is running with admin rights and another is not. Normally, you don't need either of Explorer or VS to run with admin privileges.
Visual studio running with no admin rights will most likely will be reused to open a file when you doubleclick in the Explorer (sometimes it still opens new instance with no sensible reason)
You can use File_Menu->Open->File (Ctrl+O). This will basically open an Explorer instance for you.
You can use File_Menu->Recent files if you have opened desired file recently
You can just add file to the project (and then get rid of it when it's no longer needed) (Shift+Alt+A)
You can use Show All Files feature (a toggle button in Solution Explorer) to view all the files under project folder (recursively), even if they are not included in the project. You cannot see folders higher in hierarchy, but you could make for example a symlink or just a dumb copy
You can file a feature request or a bug report (it can be done from VS itself) to make developers know about this situation
Hope any of those solutions will work for you.
Right Click On The File
Click Open With
And Select Notepad..
It Would Do The JOB

Visual Studio 2010 Bookmarks problem

When I create bookmarks into editor code with Bookmarks window, work for a while adding methods, removing statements etc. and then I reopen the IDE the line number for bookmarks are wrong...
Any idea?
One way to work around this problem is to not close visual studio before finishing writing your code. The bookmarks will update if the program is still running, but will show the wrong lines if loading a save file.

Can't "go to declaration" in *.ashx files (Visual Studio 2008)

When I open *.ashx files in Visual Studio, I don't have the helpful "Go to Declaration" context menu when right-clicking on a function.
How can I restore this functionality (this is a new install)?
Thanks very much.
Click on the text you want to go to and key F12 if it's not showing up for you.
Much like Windows Operation Systems need to reboot when things start breaking down, Studio sometimes needs a restart if that doesn't work.
Obviously this doesn't get your menu item back, but it's a fix that you might prefer over selecting that from the right-click mouse menu.
This is a shot in the dark since I do not work with ASP-related stuff.
Short Answer
If your *.ashx files belong to a project, open the project first.
Longer Answer
Most of my work in Visual Studio 2008 is with C++ and C# code. If I open a .cpp file or .cs file in VS2008 independent of the project it belongs to, VS2008 doesn't give me the Go To Declaration context menu either. When I open files independent of the project they belong to, VS2008 (or any Visual Studio version for that matter) is little more than a glorified editor. To get the benefit of Go To Declaration and other features, e.g., Intellisense, I have to first open the project and then open the file from within VS2008.
Alternate Answer
If you are already doing this, you might try deleting the .suo file in your project directory and letting VS2008 re-create it.
Apology
Sorry if this was simply stating the obvious. I know I've been frustrated at times when I've opened a file outside the context of its project only to realize what I want to do requires me to open the project anyway. Someone new to Visual Studio might not realize the project is sometimes required.

Resources