Disable the Toggle Completion Mode in Visual Studio

When writing code in Visual Studio, the shortkey Ctrl+Alt+Space toggles the completion mode of IntelliSense in the Text Editor.
The completion mode can be manually changed by going to this menu in VS2012:
EDIT > IntelliSense > Toggle Completion Mode

However the shortkey can be annoying while coding, depending on your keyboard configuration and language.

To disable this shortkey command in Visual Studio 2012 follow these steps:

  • Go to TOOLS
  • Select Options…
  • Go to Environment > Keyboard
  • Below the Show commands containing: type the word completion and hit the TAB-key
  • The filtered listbox should now contain a command called Edit.ToggleCompletionMode
  • Select it and hit the button Remove
  • Click OK to close the Options form

visual studio 2012 keyboard command options

These steps are very similar to Visual Studio 2010.

Get information from Team Foundation Server (TFS) via C# code

This code shows you how you could interact with your team foundation server. In my case a TFS 2010.

Open a new console application in Visual Studio and add these references:

  • Microsoft.TeamFoundation.Client
  • Microsoft.TeamFoundation.VersionControl.Client
TeamFoundationServer tfs = new TeamFoundationServer("http://yourtfsserver:port/something");
List<string> changedFiles = new List<string>();

VersionControlServer VCServer = (VersionControlServer)tfs.GetService<VersionControlServer>();

try
{
string path = @"C:\Users\<username>\Documents\Visual Studio 2010\Projects\just the path to your solution";
VersionSpec version = VersionSpec.Latest;
int deletionId = 0;
RecursionType recursion = RecursionType.Full;
string user = @"domain\yourusername";

foreach (Changeset item in VCServer.QueryHistory(path, version, deletionId, recursion, user, null, null, Int32.MaxValue, true, false, true))
{
  foreach (Change c in item.Changes)
  {
	// c.Item.ServerItem;
  }
}
}
catch { }

Happy coding ;)

Debugger Canvas for Visual Studio

Microsoft and Brown University have collaborated to create Debugger Canvas, a free Power Tool that adds Code Bubbles™ to Visual Studio for a new way to debug.

Do you get lost in the document tabs? Are you tired of the debugger jumping around from file to file? Debugger Canvas pulls together the code you’re exploring onto a single pan-and-zoom display. As you hit breakpoints or step into code, Debugger Canvas shows just the methods that you’re debugging, with call lines and local variables, to help you see the bigger picture.

Release info:

We are currently in the last phase of shipping! The first alpha release will be available in early June 2011. (download link)

Something I will check out for sure! ;)
Update: works only with Visual Studio 2010 Ultimate :(

More info on the Microsoft Research page.

[ source ]

White screen of Darn

Ever had a White screen of Darn (WSOD) in Visual Studio or an error like this: “exception of type system.componentmodel.design.exceptioncollection was thrown” ?

If the [Clean Solution] and [Rebuild Solution] didn’t work.
Here is how to find the culprit:

  1. Open Visual Studio 2010 and open/load your solution containing the problem
  2. Open a second Visual Studio 2010 instance

In the second VS2010 instance do the following things:

  1. Go to [Tools] > [Attach to Process…]
  2. Select devenv.exe with which contains the solution with the problem from the Available Processes and click OK
  3. Next go to [Debug] > [Exceptions…]
  4. Check [Common Language Runtime Exceptions] in the [Thrown] column

Now go to your first Visual Studio 2010 instance with your project and open the designer file which causes you the PITA (Pain In The Ass).

Your second VS2010 instance should break on the exception, showing you where it goes wrong in your code.

Enjoy ;)

Remove and sort using statements

A lot of people don’t know this but you can actually clean up your using statements in your Visual Studio projects almost automatically.

In case you didn’t know, here is how to do it:

You have a big list of using statements in your class. It might look like this by default:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

Just do a right-mouse click on the using statements and select:
[Organize Usings] > [Remove and Sort].

This will remove all the unnecessary and unused usings. The result might look as clean as this:

using System.Windows.Controls;

Sometimes, nothing could be removed or sorted but in most new class files there are a lot of default usings. It might be good to clean them once in a while, especially if you wrote and removed lots of (test) code in a class.

Happy programming ;)

Visual Studio LightSwitch (beta)

Microsoft Visual Studio LightSwitch gives you a simpler and faster way to create professional-quality business applications for the desktop, the web, and the cloud. LightSwitch is a new addition to the Visual Studio family.

They just released a Beta. ;)

[ source ] [ twitter ]