The Stochastic Game

Ramblings of General Geekery

Posts tagged with visualstudioexpress

Visual Studio Express’ limitations lead to bad practices

Visual Studio Express only has a subset of what you can find in Visual Studio Professional, which makes complete sense, but two missing features actually prevent users from following best programming practices in my opinion. The whole point of Express is to let enthusiasts and students discover the joys of programming – so we might as well let them do it the proper way.


Target the .NET Compact Framework using Visual Studio Express

Microsoft only supports Visual Studio Professional for developing Windows Mobile applications and, more generally, code based on the .NET Compact Framework. You get nice things like application deployment and emulators and remote debugging and all. But if you just want to compile something against the .NET Compact Framework, for example to check that you’re using supported methods and classes, you can do that with Visual Studio Express.

Create a project in Visual Studio Express and open it in a text editor. In the first “<PropertyGroup>” node, add the following at the end:

   1: <NoStdLib>true</NoStdLib>

This will tell MSBuild to not include mscorlib.dll automatically, so we can make it use the Compact Framework’s version.

Next, re-open the project in Visual Studio Express, delete all the system references (System.dll, System.Xml.dll, System.Data.dll, etc.), and re-add them, only this time use the Compact Framework’s assemblies. You’ll have to directly browse to those DLLs, as they probably won’t show up in the default dialog.

Now rebuild you application. It should build against the Compact Framework. You can test that by adding an instruction that’s unsupported, like for example “Thread.Sleep(TimeSpan)”.

Visual Studio Tips & Tricks

Stephen Walther recently blogged about tricks that every developer should know about Visual Studio. Most of those he mentioned I use on a daily basis, so I highly recommend them. It actually surprises me how many other programmers don’t know about those features. Somehow, most programmers know Visual Studio as much as they know Microsoft Word: there’s a big space in the middle to type your text, and then maybe they know a couple of menus and shortcuts and that’s it.

Anyway, here are a few other features I use frequently:

Tip #1 – Use CTRL-I for incremental search

I’m a big fan of incremental search. It’s actually the reason I originally switch from Internet Explorer to Firefox, back when Firefox was in beta (I already had tabs with Netcaptor). By the way, I’m happy to see IE8 now also features incremental search but, well, I’m hooked on FF now… anyway…

In Visual Studio, the incremental search mode is entered with CTRL-I. Then you can start typing right away what you want to find. You can also use backspace and all, as expected. The only problem is that it uses the last search mode defined in the “Find” dialog, so if the “Match case” option is currently checked, it will only perform incremental search on what you type in a case sensitive way. This may be a bit confusing at first, but using incremental search really makes navigating code faster.

Tip #2 – Use navigate backward and forward

Like the first tip, this tip make it faster to navigate code (because we’re spending more time reading code than writing code).

CTRL– (minus sign) and CTRL-SHIFT– allow you to respectively navigate backward and forward. The first one is the one I use almost all the time: I’m looking at some code, see a call to a function, go to the definition of that function, search for something, and then I want to go back to where I was at first. Well, without having to worry about anything, I can navigate backward twice and I end up where I want. No need to find the correct tab, figure out if I stayed in the same file or not while jumping through the code, etc. Wicked!

Tip #3 – Define some external tools

You can define “external tools” with, surprisingly, the Tools > External Tools menu item. A common thing for me is to define revision control related stuff there because most of the time I don’t like how buggy and slow source control plugins are. I also do this in Visual Studio Express where there is no support for plugins at all in the first place.

For example, say you’re using Perforce. You can create a new external tool like this:


It will checkout the current file (the one you’re editing if the focus is in the text editor, or the one selected in the Solution Explorer if that’s where the focus is). Now you just need to bind “Tools.ExternalCommand2” (because it’s the second external tool) to the keyboard shortcut of you choice (mine is CTRL-K, CTRL-E for “open for edit”). Shazam! Just use your keyboard shortcut and you can checkout a file without leaving the text editor.

You can setup other commands, like show the history of the file or make a diff with the previous version. You can also easily adapt this to other systems, like SubVersion (except in this case you won’t need the “open for edit” command because SVN doesn’t lock files by default).

XAML markup is for real men

The Visual Studio designer for WPF is quite lame as it stands now, and although it will get a lot better when Visual Studio 2008 SP1 is released, if you're a WPF developer, you really need to know how to read and write XAML by hand, much like web developers and designers know how to read and write HTML and CSS by hand.

Since you're not a wussy, what you actually want is for Visual Studio to always show a full view of the XAML markup when you open a XAML document. It's also a good thing because you won't have to wait for a few seconds for the designer to load the first time.

To do this in Visual Studio 2008 Express, go to the Options dialog, check "Show all settings", and go to "Text Editor", "XAML", "Miscellaneous". There, check the "Always open documents in full XAML view".



Regain control over build configurations in Visual Studio Express

I do almost all my development at home with Visual Studio Express. These products are wonderful and free. Well... granted, if they were not free, they would also be less wonderful too, probably. But they're still great pieces of software, and I'm pretty sure they played a critical part in building the vibrant .NET community we have now. I wish Microsoft would also release a free "Express" version of Office, but I guess I can keep on dreaming for a while longer.

The Express versions of Visual Studio have of course less features than their "professional" counterparts. Some features, however, are present, but are just disabled by default. This is the case for the build configurations.


By default, you only get a couple of disabled combo-boxes, and you only know what's supposed to be there if you've already worked with Visual Studio Professional. Visual Studio Express will switch between Debug and Release versions of your project depending on what you're doing. For example, if you start the debugger by pressing F5, the "play" button, or choosing "Debug > Start Debugging", it will switch to the Debug configuration. If you start the program without debugging by pressing Ctrl+F5 or choosing "Debug > Start Without Debugging", it will switch to the Release configuration.

This is fine, but can be annoying at times, especially when you have inputs or outputs. For example, if you write a log file in the same directory as the executable, you'll have to remember to open the correct one depending on whether you pressed F5 or Ctrl+F5. This can lead to situations where you're looking for an error when there's nothing wrong because you're not looking in the correct directory!

Also, you might want more configurations than just Debug and Release. You might want completely different configurations. If you've worked with Visual Studio Professional, you may even be wondering what happened to the Configuration Manager in the Express versions.


To fix this, choose "Tools > Options", and then check "Show all settings" on the bottom left corner of the dialog. You'll get all the advanced options, including the "Projects and Solutions" category. Check the option called "Show advanced build configurations".


Click OK, and look at those beautifully enabled combo-boxes!


Now you can set the current build configuration, and whether you start your project through the debugger or not won't change the executable being launched.

Also, the Configuration Manager is back, and will let you create new configurations:


You will soon find that other parts of the UI have now more options related to build configurations, such as the Project Properties interface.