Tips, tricks and all the info about Microsoft Visual Studio 2008

A completely non-comprehensive introduction to Visual Studio 2008

, posted: 11-Mar-2008 09:00

Visual Studio 2008 was officially launched a few days ago. I have to keep reminding myself of this fact since it’s been available to MSDN subscribers since late last year, and the Beta versions were of course around long before that. But anyway, now it’s been launched, so you can all take your hands away from your eyes and try to look both surprised and pleased.

I actually think there’s quite a lot to be pleased about, and some of it actually surprised me (and not in an icky Crying Game sort of way either). But since this is not a review (although it may read that way in places) I’ll merely highlight points of interest and leave you to make up your own minds.

Installation
This is mostly a no-brainer:  you pop the DVD in the drive and you’re prompted to install Visual Studio, and then the documentation.

However, if you’re installing Visual Studio 2008 on Windows Vista there are some precautions you should take.  If you are prompted for a restart during the installation process, and choose to restart, your machine may be restarted while setup is still in progress, leaving things in a dodgy state. So I strongly urge you to ignore any restart prompts until installation has completed. 

Aaron Stebner has a very comprehensive post that explains the situation (and options) far better (and more accurately) than I could.

Having selected which features you want to install (I recommend a custom install just so you see what you’re getting) you can now go and have a coffee. In fact you can realistically go to a local coffee shop and have a coffee (this is an improvement on the earliest versions, where you could actually wait for the beans to be harvested, visit another country for coffee and come back and the installation still wouldn’t have finished).

Alternatively, you can enjoy the Microsoft version of watching paint dry...you should be aware however that if you do so you’ll have to sit through another parade of happy shiny people who are apparently implausibly pleased to be using software. And staring at you the whole time. Yecch.

New Imagery
A little-commented on but very welcome change in Visual Studio 2008 is that the Image Library (introduced in Visual Studio 2005) has been refreshed – even more welcome is that it includes a nice selection of imagery designed for Windows Vista.

This is seemingly a small thing, but it does help to enable developers who target Vista to produce applications whose icons (for example) fit the look of the operating system rather than being stigmatised with amateurishness. 

A nice new feature is that in addition to the usual icons, images and animations there is now a large selection of common elements which can be included in other imagery, and these are typically provided in a range of sizes. The Image Library can be found in a .zip file typically located in a nested folder path under Visual Studio 2008’s Common7 folder

Of A Multiplicity of Frameworks, and Multitargeting
This is what I can’t help thinking of as The Complicated Bit. There was a time when we all knew what we meant by running .NET 1.0, .NET 1.1 or .NET 2.0, and life was simple, if sometimes frustrating (because knowing what you mean by running one of the above doesn’t necessarily mean you know when your code is executing against which one, but that’s another story).

Then came .NET 3.0, and life ceased to be simple (although it was admittedly cooler). This time there was no change to the Common Language Runtime or the Base Class Library, just a set (admittedly a significant set) of additional libraries to add functionality that didn’t previously exist.

So it was useful to think of .NET 3.0 as “.NET 2.0 + Extra Bits”. For this reason many of us questioned the wisdom of going up a full major version number, but what was done was done.

.NET 3.5, the version that accompanies and is a prerequisite for Visual Studio 2008, continues that approach, but while it builds on and extends rather than replacing 2.0 and 3.0, it does require Service Pack 1 for both 2.0 and 3.0 – so when you install .NET 3.5, the installation not only installs the 3.5 bits but also patches 2.0 to 2.0 SP1, and 3.0 to 3.0 SP1 (if one or the other of these is not already present it will install it for you, so the .NET 3.5 installer is fully self-sufficient and doesn’t require you to have previously installed any other .NET bits).

To recap: when you install .NET 3.5, once the smoke clears you will have (in addition to any 1.x versions you may have lying around) 2.0 SP1, 3.0 SP1 and 3.5.

You may recall that 3.0 gave us Windows Presentation Foundation, Windows Communication Foundation, Workflow Foundation (the Windows Telepathy Foundation for obtaining user requirements was however not included) and some other goodies such as System.IO.Packaging.

With 3.5 we get extensions to WPF and WCF, built-in support for AJAX, and once more some other goodies (including such welcome additions as System.TimeZoneInfo).

If you’re still confused (or you weren’t before but you are now) I recommend the following post by Daniel Moth.

ASP.NET
In the pre-.NET 3.0 days, a new .NET Framework version also meant a new version of ASP.NET.
When you installed 1.1 on a web site, all 1.0 applications would by default be remapped to run against the 1.1 runtime.  With 2.0 the upgrade behaviour was slightly more complex but also considerably friendlier.
With 3.0 and 3.5 however there is no site upgrade, other than the essentially invisible matter of the service pack.

Your ASP.NET 2.0 applications continue to run against 2.0 SP1, and any new web applications you create will be ASP.NET 2.0. While people commonly talk about ASP.NET 3.5 to indicate all the new features available in this release, in a real sense there is no ASP.NET 3.5, as IIS will happily confirm for you (this is worth pointing out, because people who check IIS and find no reference to ASP.NET 3.5 may wrongly assume that the installation has been unsuccessful or incomplete).

The not insignificant upside to all of this is that you can install .NET 3.5 on a web server and not have to worry that all your existing web applications will start misbehaving (or not behaving at all, or sulkily displaying big red text to  frighten your users away). This was definitely not the case when we moved from 1.0 to 1.1.

Multitargeting
Multitargeting is a new feature in Visual Studio 2008 that allows you to specify that a project should target .NET 2.0, 3.0 or 3.5. The New Project dialog now includes a dropdown that enables you to make this selection.



A very helpful feature is that the Add References dialog shows references for a framework version excluded by the current framework selection as disabled.  The following example for instance is from a .NET 2.0 project:



The key point about multitargeting is that only the libraries and features appropriate to the current framework selection are made available (this also applies to the Toolbox). If you create an application with .NET Framework 2.0 selected the output should therefore be equivalent to the output of an identical project created with Visual Studio 2005 on the same machine.

The one point you should be careful of is that if you are creating a 2.0 or 3.0 project you need to ensure that you do not inadvertently make use of one of the small number of features added as part of 2.0 SP1 or 3.0 SP1 respectively, unless you are only going to be running the output on your development machine.

Note however that where Visual Studio 2005 allows you to create Smart Device projects for both .NET Compact Framework  1.0 and 2.0, Visual Studio 2008 does not support versions of the Compact Framework lower than 2.0, and on conversion of such a project from Visual Studio 2005 to 2008 will upgrade it to target 2.0.

New Editor Features

JavaScript Improvements
The most noticeable JavaScript change is that we finally get decent intellisense.  Intellisense improvements  (see below) are an overall feature of Visual Studio 2008, and for JavaScript they mean that the development experience has finally progressed from the absolutely abysmal to now only somewhat annoying.

Not only are the standard language features made available, but even when you’re editing an external script file the document object model is available. Very nice.

Another huge improvement is that JavaScript debugging now actually works (naturally if you’re using Internet Explorer you need to enable script debugging). Overall these changes will be a tremendous productivity (and preservation-of-will-to-live) boost to AJAX developers in particular.

General Intellisense Improvements
General code editing (non-JavaScript) intellisense has been improved to the extent that for this reason alone it’s painful to switch back to Visual Studio 2005 – when I do so it feels as if VS2005 intellisense is broken, when it’s simply working the way it always has (and this is significant given that I had the same feeling whenever I had to move from Visual Studio 2005 back to 2003 – so we’ve moved forward yet again).

There are separate improvements for C# and VB.NET – a good place to check out the details is this excellent post from Scott Guthrie.

Organize Usings (C#)
This is a new item in the code editor context menu for C#.  It’s a small feature but a nifty one that opens a sub-menu with three options: Remove Unused Listings, Sort Usings and Remove and Sort. I won’t explain what these do because they should be self-explanatory: I’ll just say that they cover things I’ve often done laboriously by hand, or more often meant to do but never got around to because it was too tedious.

Web Development
Although there is not strictly speaking a new version of ASP.NET, there are a lot of new and improved features for ASP.NET developers.
The new Visual Web Developer editor is based on that used by Expression Web and includes many of the same features (including a split screen mode).

CSS
Support for CSS includes the new CSS Properties, Manage Styles and Apply Styles options. CSS Properties shows the CSS rules that are applied to the current selection and indicates which stylesheet they are defined in (if any), and also indicates whether a particular rule is overridden or for some reason won’t (or might not) be applied at a lower level by showing that property with a red line struck through it.

Apply Styles and Manage Styles are similar to each other but the former is more visual, in that not only are the effects of the style indicated as much as possible in the way the style name is displayed, but when you select a style it will be applied to the current selection to the extent that this is possible.

This is similar to the style previews in Word 2007 except that in this case the style changes are really applied to the elements in question and will stay in effect if you don’t replace or clear them.



Manage Styles adopts a more conservative approach, listing the styles but using a traditional preview window below the list of styles,  displaying the letters “AaBbYyGgLlJj” with the current style applied.



To apply a style to the current selection from Manage Styles right-click the style name and select Apply Style from the context menu.

As the illustrations show both Apply Styles and Manage Styles allow you to define a new style. This can be added to the current page, a new stylesheet or an existing one.

Both options also use a colour-coding system for styles where the colour of the filled circle to the left of the style name indicates whether the style is a class (green), an element style (blue – you’ll typically see at least one of these - the body style added to new stylesheets by default), an element ID style (red) or an inline style (yellow).

Additionally, the filled circle next to styles which are actually in use is circled. Both also display the style definition if you hover over the style name, and both options also allow you to go to the source and edit the style directly (although Manage Styles has the advantage here in allowing you to simply double click on the style name to do this).

AJAX
Where AJAX support was released as an add-on for Visual Studio 2005 it is included out of the box with Visual Studio 2008, including the Toolbox tab for AJAX Extensions and a Web.config file prepopulated with the basic settings required .

Thankfully the integration also goes deeper than this – for instance the AJAX support extends to adding a smart tag for controls that prompts you to select an Extender for that control (so you no longer have to drag it from the Toolbox and wire it  up manually – don’t forget to add a ScriptManager though if there isn’t one already). Properties of Control Extenders are shown on the property grid of the control they extend .

LinqDataSource
So far I haven’t said anything about LINQ, which is actually one of the most significant new features delivered with VS 2008 and .NET 3.5 (to be clear, if you want to use it you should be targeting 3.5). This is not because I don’t like it or don’t think it’s important: on the contrary I think it’s such a significant enhancement that I can’t possibly do justice to it in an overview such as this.

That, and I’d spend half a page trying to explain what it is and what it isn’t. And you don’t want that, especially since the chances of me not adding to the sum total of human confusion in the attempt are not great.

Just as we have previously had SqlDataSource, ObjectDataSource, AccessDataSource (I don’t know why, but whatever) XmlDataSource and SiteMapDataSource, LinqDataSource adds support for databinding to the result of a LINQ query. By default it leans towards LINQ to SQL, but by setting the Result property of an OnSelecting event handler for instance you can effectively use any LINQ query you like (within reason, and don’t quote me on this).

I’m not going to address here the question of whether you should use a LinqDataSource: in my opinion there are cases where it’s appropriate and cases where it probably isn’t, and there’s no sense in being precious and making blanket pronouncements on the subject.

Vista Features
Visual Studio 2008 is the first version that natively supports Windows Vista.

Unlike Visual Studio 2005 you don’t have to apply an update before it will run, nor do you have to run the whole thing as Administrator (you will still encounter a UAC prompt in certain circumstances, but that’s just normal Vista behaviour).

There are also new features when developing for Vista (as opposed to just on Vista).

When creating desktop applications for Vista it’s necessary to include a manifest in order to interact correctly with UAC (unless you’re happy to run in legacy mode). The UAC manifest allows you to set a requested execution level, and creating and compiling with it under VS 2005 was a fiddly manual process involving too many steps and prone to error.

Visual Studio 2008 provides the new app.manifest project item, which as its name suggests is none other than a UAC manifest.

As before the experience is different for C# and Visual Basic.NET. In both cases there is a relevant entry on the Application tab of the Properties item on the Project menu.

For Visual Basic this takes the form of a “View UAC Settings” button that gives you direct access to the app.manifest file. For C# there is a dropdown labelled “Manifest”, whose initial entries are “Embed manifest with default settings” and “Create application without a manifest”, but if you add an app.manifest file to the project (you can find it easily from the Add New Item dialog under “Application Manifest File”) it is added to the dropdown as the default selection.

Another feature worth mentioning is that .NET 2.0 SP1 automatically uses the new versions of the Common Dialogs for an application running on Vista (including one created with VS 2005). If you’re attached to the old format however you can prevent this behaviour by setting the dialog’s AutoUpgradeEnabled property to “false”.

New Project Types and Other Things Worthy of Note
Project types which had to be installed as extensions for VS 2005 are provided out of the box (a term I’m dangerously close to overusing) in VS 2008, so File->New-> Project will show you Web for Web Application Projects, WCF for a variety of WCF projects and Workflow for, oddly enough, Workflow.

The WPF project templates are listed under Windows, along with Windows Forms templates.

Support for all of these features is greatly improved from the versions that were available for VS 2005: for WPF we now have non-broken intellisense for XAML along with a good facility for wiring events, WCF projects benefit from a test host environment (so you can try your services out before deploying them) and so on.
.NET 3.5 brings enhancements and additions to WPF, WCF and WF themselves, some of which are worthy of whole articles in their own right (which is a good excuse for me not talking about them in detail here), and several of these are reflected in the existence of new project templates that were not present for the .NET 3.0 extensions to VS 2005.

There are other many other features worth checking out, from IDE enhancements such as the addition of Code Metrics to language enhancements (for C# my favourites include auto-implemented properties, initializers, type inference and extension methods – of which the last two are key enablers for LINQ, while in addition to initializers, type inference and extension methods VB adds XML Literals).

The new Framework features, IDE enhancements and the results of the ongoing evolution of .NET languages make Visual Studio 2008 a very desirable upgrade for existing Visual Studio users, and if you’ve been coding in Notepad for the past 10 years or so the case should be even more persuasive. 

Get it while it’s hot.

Download Visual Studio 2008 90 day trial
For detailed information and to request a free 90-day trial DVD of Visual Studio 2008 Team Suite to be sent out to you, go to the Microsoft Visual Studio webpage.

About the Author
Kevin Daly is has been programming professionally for almost 22 years. He has been using .NET and C# continuously since the Beta 2 in 2001, which probably explains the bags under the eyes. Other examples of his views, rants and even the odd code sample can be found on his blog at http://www.kevdaly.co.nz/weblog, the construction of which did in fact involve LINQ to SQL, LINQ to XML, WCF HTTP programming and Other Good Things. He will now stop talking about himself in the third person because it’s frankly a bit weird.

Other related posts:
The Visual Studio 2008 blog is back
Visual Studio 2008 JavaScript Debugging
Windows Workflow Enhancements in Visual Studio 2008








Comment by Bhupendra, on 31-Jan-2009 01:42

i am using vs2008 to create smart device project. i want to set Target Framework to .netcf2.0 is it possible? as it is disable in project property. any other way to do that. thanks in advance.


About the Visual Studio 2008 Blog

In the years since the hugely successful release of Visual Studio 2005, Microsoft has used developer feedback from all over the world to introduce over 250 new features in the 2008 release.

This sponsored blog will bring Visual Studio 2008 tips and tricks from well known developers in the Australian and New Zealand tech community directly to you.

Make sure you bookmark this blog or subscribe to our RSS feed.



Other blog posts

The New Zealand ALM Conference...
Writing your own Html Helpers ...
Automating Visual Studio 2008...
Windows Azure Table Storage - ...
Windows Azure Table Storage - ...
XML and XSLT in Visual Studio ...
Introduction to New SQL Server...
Using the Visual Studio 2008 P...
Getting started with Windows A...
Why consider sitting for an MC...


Some recent comments

Praveen M on Visual Studio 2008 support for building SilverLigh: I installed SILVERLIGHT TOOLS for VS2008 at my work. I am able to do silverlight...

zefo on Unit testing with Visual Studio 2008: Just minor recommendation: better use *.png for the screenshots. Jpeg is more su...

gil ziny on Unit testing with Visual Studio 2008: When I associate the unit test with TFS testing policy, if fails during check-in...

lynette on Visual Studio 2008 JavaScript Debugging: i have enable in IE the ability to debug scripts. if i go to my section in my c...

Junkie on Why consider sitting for an MCTS or MCP Certificat: The way you presented the case for certification has been completely different f...

Brian Link on Unit testing with Visual Studio 2008: You seem to be incorrect in one of your opening remarks - it seems that web.conf...

Dipanwaya on Unit testing .Net Compact Framework applications w: Steps Behind the Test in the VS 2008? How to test a module in the VS 2008 Envir...

Ricardo on Visual Studio 2008 support for building SilverLigh: Yes! Found the solution myself :) Reset the environment of Visual Web Developer...

Ricardo on Visual Studio 2008 support for building SilverLigh: Have the same problem after installing Visual Web Developer 2008 SP1 and Silverl...

kjward on Automating Visual Studio 2008: thanks lots for all the great info. i'm sure the answer to my question is in th...



Disclaimer

The Visual Studio 2008 blog is sponsored by Microsoft NZ. The blog posts are the authors' genuine accounts of their experiences with Visual Studio 2008 and are not influenced or filtered by Microsoft NZ in any way.