VS 2010 - Adding additional projects to Solution - visual-studio-2010

At work we have just upgraded from VS2008 to VS2010 (keeping up with the times, I know). In VS2008 I used to navigate to various project folders in Source Control Explorer and double click the vbproj file and it would add it to my current Solution (or create a new solution if there wasn't one). The functionality in VS2010 seems to be that when I do this it closes my current Solution and opens the new project on its own.
Is there any way to get the VS2008 functionality back? I know I can right click on my Solution and Add->Existing Project..., but that takes a lot longer. I've tried Googling this but have come up blank.
Thanks in advance.

No, this beaviour was taken out from VS between 2008 and 2010. In 2010 when you double-click a *.csproj or *.vbproj file it will always open it up in a "temporary solution".
This gets annoying when comparing diffs between local changes to your project file... in my view VS should open it in the editor if anything. /rant

Related

Cannot unload project in Visual Studio 2013

I have a solution with a project file that I need to modify as text (i.e. the XML). This is done by right clicking on the project and selecting Unload Project, then right clicking on it again and selecting Edit Project.csproj. However, this does not work on all projects. Sometimes I get the message
The operation could not be completed
I want to know why this message sometimes appears (i.e. what is it about my project / solution configuration that could bring this about) and whether there is another way to edit the .csproj within Visual Studio (if I try and close the solution then open the .csproj file Visual Studio just opens the solution again).

MS Visual Studio.net - saved source files missing after reboot

The other day I created a MS visual studio 2010 C# project and started coding. I saved the source frequently, but I did not select a destination to save to (just pressed ctrl+s and assumed the source was being saved). However I had to run and threw my laptop in my backpack on sleep. Unfortunately this laptop (acer aspire 5252 fyi) battery drains extremely quickly when on sleep, and eventually my computer shut off. Now I can't find my source files anywhere and I'm going crazy because I know I saved it and it's several days worth of work.
I tried doing a windows search but couldn't find the project files. I also did a little experiment - I created a new project and without saving the entire solution, I pressed ctrl+s on the source files. Save was successful, but I cannot even find the file that's open in the IDE. Even the "open containing folder option" is grayed out (see screen shot).
I really need these source files back. Obviously it's because I didn't save the solution that the source got wiped out, but where do the source files get saved temporarily before the solution is saved?
Thanks.
You are using Visual Studio's support for temporary projects. Nice feature for quicky test projects (and SO answers) but not a great way to ensure that your projects are still there after VS quits. Programming without source control is similarly inadvisable.
Tools + Options, Projects and Solutions, General. Ensure that the "Save new projects when created" option is ticked to minimize the odds that you'll forget to pick a solution folder. Triple-check that creating a new project now gives you a "Location" property in the dialog.
There is a default location for projects to be saved. That is probably where your files went.
In Visual Studio, on the menu, click Tools > Options > Projects and Solutions > General. There is a "Visual Studio projects location".
On my Windows 7 machine, the folder for Visual Studio 2010 is
C:\Users\<username>\Documents\Visual Studio 2010\Projects
Your unnamed project is probably saved with a default name like WebSite1.
If you would like to change that default location, here is some information on how to do that.
Visual Studio temporary projects are normally found in *C:\Users\"User Name"\AppData\Local\Temporary Projects* . It is a temporary folder that is deleted as soon as Visual Studio starts up.
How to save a Temporay Project from above link:
To save a temporary project
In Solution Explorer, choose the solution or project that you want to save.
On the menu bar, choose File, Save or Save As.
The Save Project dialog box opens.
In the , Name box, specify a name for the project.
In the Location box, specify where you want to save the project.
Select the Create directory for Solution check box.
Note: This check box is not available for Visual Basic web projects, Visual C# web projects, or other directory-based projects.
In the New Solution Name box, specify a name that differs from the project name.
Select the Add to Source Control check box if you want to add the solution to a version-control database or repository.
Choose the OK button.

How to avoid automatically unfolding of projects in Visual Studio 2010 Solution Explorer

I have all the projects in a solution folded, so you can't see their files in the Solution Explorer. And a file belonging to one of those projects open. Once I browse to that file pane, the project containing the file is automatically unfolded in the Solution Explorer.
Is there a way to avoid that automatic unfolding?
I'm not 100% sure what you're after, but in the VS 2010 options, under "Projects and Solutions/General" there is an option called "Track Active Item in Solution Explorer".
I've just tried unchecking that and, with a mutiple project solution all collapsed, when clicking into an open code file it doesn't open up the project in the solution window. Try that and see if it produces the result you're after.
Let me know if I've misunderstood your question though!

How to revert file in Visual Studio 2010 (reload the file from disc)

I'm starting to use Visual Studio (2010) after years with Eclipse.
Every now and then I've found Eclipse's "Revert" feature pretty useful, that is, to reload the file from disk, discarding all changes. (Nothing to do with version control reverting.)
How can I do this with Visual Studio? Should be pretty simple but I haven't found it yet.
I know that I can do this with "undo until *-indicator disappears" but that's pretty impractical.
Unfortunately I do not know of a built-in way to do this in VS other than closing the file and reopening it without saving.
There might be some extension that does this, but I am not aware of it :(
In the current version, you find in the Explorer, in the left sidebar. Then Open Editors, and right click on the file you want to revert.
If you are using git with Visual Studio:
Solution Explorer > Right Click On File > Git > Undo Changes

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