Friday, November 14, 2008

SQL Server 2008: What's New

  • More powerful management
  • Improved performance and scalability
  • Better security and availability
  • Changes for developers

Once again, Microsoft has released a new version of SQL Server that promises to improve life for database administrators. The latest version is SQL Server 2008, and it offers a large variety of new
features and functionality that will make the administration a whole lot better.
Database administrators who have been using SQL Server® 2005 for any length of time will find many of the same features that they use in their day-to-day jobs, but they'll also soon discover that these familiar tools have been enhanced in SQL Server 2008. The new functionality built on the existing features goes a long way in reducing the number of workarounds or customizations once needed for using various features in complex database environments.
New features in SQL Server 2008 involve a large range of database job roles, making it difficult to categorize them. As I classify features under different topics, I realize that some readers will be wondering why I placed Feature X under Category Y when it clearly belongs under Category Z. It's a matter of perspective, and it's affected by how your company does business.
I do understand that database people often find themselves doing many different job roles, but I will try to break down the new features so they fit into the following generic categories: Management, Scalability, Performance, High Availability, Security, Development, and Business Intelligence.

What's New for Management?
For database administrators (like me), the additional management functionality makes SQL Server 2008 a very exciting new product. The new policy management, multiple server query capability, configuration servers, and data collector/management warehouse offer powerful new abilities for database administrators who are often responsible for managing large and complex database environments with hundreds or thousands of databases on dozens or even hundreds of servers.
The SQL Server 2008 Policy Management feature, which was actually called Declarative Management Framework in the Community Technology Previews (CTPs), allows you to create and execute configuration policies against one or more database servers. With these policies, you can ensure that standard configuration settings are applied and maintained on each of the targeted servers and databases. You can see an example of this feature in Figure 1.
Figure 1 The Data and Log File Location Best Practice policy (Click the image for a larger view)
Policies are created from a predefined set of facets. Each facet contains a subgroup of SQL Server 2008 configuration settings and other events that you can control. You pair these facets with conditions in order to create a policy. Conditions are the values that are allowed for the properties of a facet, the configuration settings, or other events contained within that facet.
Conditions are also values used for policy filters. Say you want the policy to be executed only against a certain database. In this case, you can create a condition that contains the name of the database and then add this condition to the policy. Now the policy will only apply to that one database. Trust me on this—SQL Server 2008 Policy Management may sound complex, but once you try it you'll realize it's pretty intuitive.
The new Multiple Server Interaction and Configuration Servers capabilities come in handy when you need to execute queries against multiple servers at the same time. You can register servers in your Management Studio and then place those servers together under a grouping. When you need to execute a policy or query against all the servers in the grouping, you simply right-click on the grouping and do so.
As an added benefit, you can configure this feature to return one resultset per server or merge all the resultsets together into one big resultset. You can also specify whether you want the server and database names as part of the results so you can separate the individual results from each server. Being able to store the registered servers on the configuration server rather than in each individual's Management Studio is a big benefit.
Another nice new management feature is the Data Collector. Database administrators often need to collect management data from a large number of servers, and many of these DBAs have created their own custom solution for doing so. The Data Collector is a built-in mechanism that eases the task of collecting management-related data. It allows you to use the SQL Server Agent and SQL Server Integration Services (SSIS) to create a framework that collects and stores your data while providing error handling, auditing, and collection history.
Unlike third-party tools and custom jobs, the Data Collector will be easily understood by most database administrators since it uses SQL Server Agent and SSIS to create a set of jobs and packages to handle the connections, collection, and storage of data (as you can see inFigure 2). Once this data is stored in a central location, referred to as the Management Warehouse, it can be viewed and organized through a set of T-SQL statements and SQL Server 2008 Reporting Services reports. This central data store makes it much easier to analyze and view the overall management metrics of the database environment.
Figure 2 The Data Collector Disk Usage Log file (Click the image for a larger view)

What's New for Scalability?
Over the years, SQL Server database administrators have found their database environments becoming increasingly large. As the size of your database environment increases, you need new methods and tools to achieve the scalability that most enterprises require. SQL Server 2008 has introduced several new features that will help.
SQL Server 2008 has built-in compression that allows you to compress the database files and the transaction log files associated with the compressed database. SQL Server 2005 introduced the ability to compress data on a read-only file or filegroup, but this form of compression simply used the compression ability of Windows® NTFS. With SQL Server 2008, you now get both row-level and page-level compression, offering benefits you don't get with compression at the data file level.
Compression at the row and page levels reduces the amount of data space needed, plus it reduces the amount of memory needed since the data remains compressed while in memory. Compressed data in memory results in increased memory utilization, which benefits the scalability of many systems.
SQL Server 2008 also introduces compression at the backup level. While database backups only back up the active portion of the database, this still represents as many as hundreds of gigabytes or even dozens of terabytes. In database environments that have more than one copy of a multi-terabyte backup file, these backups often take up valuable storage space that could be used more effectively. By allowing database administrators to compress their backup files, SQL Server 2008 frees up some of this space, so it can be used for live data.
Then there's the Resource Governor. This new feature lets you define the amounts of resources that individual or groupings of workloads are allowed to use during execution. With Resource Governor, you can create an environment in which many different workloads coexist on one server without the fear of one or more of those workloads overwhelming the server and reducing the performance of the other workloads.
The benefit of this feature is that you can more effectively use the total amount of resources that are available on your database servers.Figure 3 shows an example of using the Resource Governor to limit activity on a server.

What's New for Performance?
The general performance of databases improves with SQL Server 2008. Thanks to several new features found in SQL Server 2008, you can control and monitor the performance of your databases and the applications that execute against them.
When you have large numbers of transactions performed every second, the locking that normally occurs during these transactions can have a negative impact on the performance of your database applications. SQL Server is designed to reduce the total number of locks a process holds by escalating locks from the smaller row-level and page-level locks to large table-level locks. But it's important to understand that this escalation of locks can cause problems. For example, a single transaction can lock an entire table and prevent other transactions from working with that table.
SQL Server 2008 works with the table partitioning mechanism (which was introduced in SQL Server 2005) to allow the SQL Server engine to escalate locks to the partition level before the table level. This intermediary level of locking can dramatically reduce the effects of lock escalation on systems that have to process hundreds and thousands of transactions per second.
SQL Server 2008 offers several new query processor improvements for when the query interacts with partitioned tables. The query optimizer can now perform query seeks against partitions as it would against individual indexes by only working with the partition ID and not the partitioning mechanism at the table level.

What's New for High Availability?
As database environments become more complex and databases grow in size, the ability to ensure the availability of those databases becomes increasingly difficult. The familiar mechanisms you have used in the past to achieve high availability are still present in SQL Server 2008. But some of these features have been enhanced in SQL Server 2008 and some new ones have been added.
With SQL Server 2005, many administrators started implementing database mirroring to achieve high availability. SQL Server 2008 offers many improvements for the practice of database mirroring. For instance, in the past, database mirroring occasionally had performance issues related to moving transaction log data from the principal to the mirrored databases. In response, SQL Server 2008 now reduces the amount of information that is moved across the network from the principal's transaction log to the mirror's transaction log by compressing the information before sending it to the mirror's transaction log for hardening.
You now have the ability to repair corrupted data pages on the principal. If a principal database suffers corrupt data pages due to errors 823 and 824, the principal can request a fresh copy of those data pages from the mirrored servers. This request of good data pages is an automated process that is transparent to any users who are currently accessing the principal databases.
Another new feature, Hot Add CPU, lets you add additional CPUs to a database server without affecting the availability of the databases residing on that server. However, you should know that Hot Add CPU does have some limitations, as it is only useful when running the 64-bit Itanium-based Windows Server® 2008 Enterprise Edition or Datacenter Edition, and it requires the Enterprise Edition of SQL Server 2008.

What's New for Security?
SQL Server 2005 introduced data security in the form of data encryption. With SQL Server 2008, encryption is greatly enhanced with the introduction of two features: Extensible Key Management and Transparent Data Encryption.
Extensible Key Management allows for an enhanced structure to safely store the keys used in the encryption infrastructure—not only in the database itself but also outside the database in third-party software modules or with a Hardware Security Module.
Transparent Data Encryption offers improved flexibility for encrypting data by allowing encryption to be a property of the database and not just the result of functions in a line of code. The result is that administrators do not have to perform the large number of changes that are required for their database structure and application code when they perform encryption at the data level. The code in Figure 4 shows how you can encrypt a database with Transparent Data Encryption.

What's in Store for Developers?
Database administrators are not the only people that will benefit directly from the changes in SQL Server 2008. There are a number of new features that are designed to help database developers. These range from several new T-SQL enhancements to new components that can help developers create and utilize database queries.
Many database developers are responsible for creating the queries that are needed for returning the data required for their applications. You're probably familiar with the LINQ (Language Integrated Query) tool that enables database developers to issue queries against a database using a Microsoft® .NET-based programming language instead of the normal T-SQL statements. Well, SQL Server 2008 enhances LINQ by providing a new LINQ to SQL provider that allows developers to issue LINQ commands directly against SQL Server tables and columns. This will reduce the amount of time it takes to create new data queries.
When developing against databases, developers use higher-level objects that they map to individual database tables and columns. These objects, also known as entities, represent the data needed for database applications and, therefore, the developer doesn't need to understand the actual storage structure of the data and schema of the database. The new ADO.NET Entity Framework now allows developers to create database queries using these entities. The abstracting of the underlying database structure allows developers to be more productive.
SQL Server 2008 offers many different enhancements to T-SQL that allow database developers to be more efficient. One example is the new MERGE statement, which allows the developer to check for the existence of data before trying to insert the data. This check prior to performing the INSERT statement allows the data to be updated. No longer is it necessary to create complex joins in order to update data that exists and to insert data that does not already exist, all during a single statement.
In addition, separating time and date data from the combined date/time data type has been made easier. SQL Server 2008 introduces two separate data types to handle date and time data. Different data types will translate to improved performance for many queries since there will no longer be a need to perform an operation on the data before it can be used in the query.
When creating newer database structures, database developers often find themselves stretching the structure of databases in order to implement mapping applications. SQL Server 2008 helps to address this issue with new spatial data types. The two spatial data types, GEOGRAPHY and GEOMETRY, allow developers to store location-specific data directly into the database without having to break those data elements down into formats that fit other standard data types. The code in Figure 5 is an example of a simple spatial table.
A very common issue for database developers in the past was how to store and utilize large binary objects such as documents and media files. The method typically used was to store the files outside of the database and just store a pointer in the database to the external file. With this method, however, when you move the file, you must also remember to update the pointer.
SQL Server 2008 handles this issue with the new FILESTREAM data type. With this data type, files can still be stored outside of the database, but the data is considered part of the database for transactional consistency. This allows for the use of common file operations while still maintaining the performance and security benefits of the database.

What about Business Intelligence?
Increased use of SQL Server over the last few years has been driven in large part by the adoption of business intelligence strategies. Business intelligence capabilities are not new to SQL Server, but SQL Server 2008 does bring some new features to the table.
For example, when data is stored in data warehouses, space is often wasted due to NULL values. Columns that store NULL values take up the space of the largest allowed data size defined in the column. This means that a column with thousands of NULL values can actually consume many MB of space without actually storing any data.
SQL Server 2008 introduces sparse columns, which allows NULL values to be stored without taking up any physical space on the disk. Because sparse columns do not consume actual space, tables that contain sparse columns can actually exceed the 1,024 column limit.
SQL Server 2008 also introduces a new mechanism, Change Data Capture, for managing incremental changes that need to be loaded into the data warehouse. This captures and places changed data into a set of change tables. Capturing updated, deleted, and inserted data in an easily consumed storage schema allows for the incremental loading of data warehouses from those tables—as opposed to having to build custom insert statements that try to figure out the changes made to existing rows of data before updating the data warehouse.

SQL 2008 includes the TSQL command MERGE. Using this statement allows a single statement to UPDATE, INSERT, or DELETE a row depending on its condition. The example below demonstrates the MEGRE being used to combine a new list of Inventory Item descriptions into the existing Inventory Master. In addition to new Descriptions, there are some new parts included in the NewInventory table. Without the Merge statement, two commands would need to run. The first would look for a match then upgrade the Description. The second statement would look for non matches and then INSERT. With MERGE, one statement can perform both tasks as shown below.

Microsoft Office 2007
SQL Server 2008 can tightly integrate with Microsoft Office 2007. For example, in SQL Server Reporting Server reports can now export directly to Word. In addition, both Word and Excel can be used as templates for SSRS reports by using the Report Authoring tool. Excel SSAS performance has been improved and there is a data mining add-in.

SQL Server 2008 contains many new features and enhancements, a large numbers of which were not covered in this series. Additional information can be found at the main SQL 2008 Microsoft page: Listed below is a concise bulleted list of the SQL Server 2008 features reviewed in this series.

  • Transparent Data Encryption. The ability to encrypt an entire database.

  • Backup Encryption. Executed at backup time to prevent tampering.

  • External Key Management. Storing Keys separate from the data.

  • Auditing. Monitoring of data access.

  • Data Compression. Fact Table size reduction and improved performance.

  • Resource Governor. Restrict users or groups from consuming high levels or resources.

  • Hot Plug CPU. Add CPUs on the fly.

  • Performance Studio. Collection of performance monitoring tools.

  • Installation improvements. Disk images and service pack uninstall options.

  • Dynamic Development. New ADO and Visual Studio options as well as Dot Net 3.

  • Entity Data Services. Line Of Business (LOB) framework and Entity Query Language (eSQL)

  • LINQ. Development query language for access multiple types of data such as SQL and XML.

  • Data Synchronizing. Development of frequently disconnected applications.

  • Large UDT. No size restriction on UDT.

  • Dates and Times. New data types: Date, Time, Date Time Offset.

  • File Stream. New data type VarBinary(Max) FileStream for managing binary data.

  • Table Value Parameters. The ability to pass an entire table to a stored procedure.

  • Spatial Data. Data type for storing Latitude, Longitude, and GPS entries.

  • Full Text Search. Native Indexes, thesaurus as metadata, and backup ability.

  • Reporting Server. Improved memory management.

  • SQL Server Integration Service. Improved multiprocessor support and faster lookups.

  • MERGE. TSQL command combining Insert, Update, and Delete.

  • SQL Server Analysis Server. Stack improvements, faster block computations.

  • SQL Server Reporting Server. Improved memory management and better rendering.

  • Microsoft Office 2007. Use OFFICE as an SSRS template. SSRS to WORD.

Friday, November 7, 2008

.NET Framework 3.5 SP1

ASP.NET Data Scaffolding Support (ASP.NET Dynamic Data)

.NET 3.5 SP1 adds support for a rich ASP.NET data "scaffolding" framework that enables you to quickly build functional data-driven web application. With the ASP.NET Dynamic Data feature you can automatically build web UI (with full CRUD - create, read, update, delete - support) against a variety of data object models (including LINQ to SQL, LINQ to Entities, REST Services, and any other ORM or object model with a dynamic data provider).

SP1 adds this new functionality to the existing GridView, ListView, DetailsView and FormView controls in ASP.NET, and enables smart validation and flexible data templating options.  It also delivers new smart filtering server controls, as well as adds support for automatically traversing primary-key/foreign-key relationships and displaying friendly foreign key names - all of which saves you from having to write a ton of code.

You can learn more more about this feature from Scott Hanselman's videos and tutorials here.

ASP.NET Routing Engine (System.Web.Routing)

.NET 3.5 SP1 includes a flexible new URL routing engine that allows you to map incoming URLs to route handlers.  It includes support for both parsing parameters from clean URLs (for example: /Products/Browse/Beverages), as well as support to dynamically calculate and generate new URLs from route registrations.

This new routing engine is used by both ASP.NET Dynamic Data as well as the new ASP.NET MVC framework.  It will support both WebForms and MVC based requests. 

ASP.NET AJAX Back/Forward Button History Support

.NET 3.5 SP1 adds new APIs to ASP.NET AJAX to allow you to better control the history list of a browser (enabling you to control the behavior of the back/forward button of the browser).

You can learn more about this feature in the article here and the screencast here.

ASP.NET AJAX Script Combining Support

.NET 3.5 SP1 introduces a new element on the server control, which allows you to declaratively define multiple script references within it.  All the script references within the CompositeScript element are combined together on the server and served as a single script to the client, reducing the number of requests to the server and improving page load time for ASP.NET AJAX applications.

The script combining feature supports both path based scripts and assembly resource based scripts, and dynamically serves up the combined scripts using the ScriptResources.axd handler.

Thursday, September 18, 2008

Internet Explorer 8 Beta 2

Internet Explorer 8 Beta 2 Now Available

We’re excited to release IE8 Beta 2 today for public download. You can find it at Please try it out!

You’ll find versions for 32- and 64-bit editions of Windows Vista, Windows XP, Windows Server 2003, and Windows Server 2008. In addition to English, IE8 Beta 2 is available in Japanese, Chinese (Simplified), and German. Additional languages will be available soon.

While Beta 1 was for developers, we think that anyone who browses or works on the web will enjoy IE8 Beta 2. Before the team blogs about our Beta 2 in detail, here’s an overview of what you’ll find in IE8.

We focused our work around three themes: everyday browsing (the things that real people do all the time), safety (the term most people use for what we’ve called ‘trustworthy’ in previous posts), and the platform (the focus of Beta 1, how developers around the world will build the next billion web pages and the next waves of great services).

Everyday Browsing

We looked very hard at how people really browse the web. We looked at a lot of data about how people browse and tried a lot of different designs in front of many kinds of people, not just technologists. As tempting as it is to list here all the changes both big and small in IE8, we’ll take a more holistic approach. That’s how we built the product and how we’d like to talk about it.

From our customer research, we saw that the bulk of user activity outside of web pages involved tabs and “navigation” – the act of getting to the site the user wants to get to. We also knew that adding features has an impact only if they’re “in the flow” of how people actually use the product. Another menu item might matter in a checklist on a blog somewhere, but won’t matter to real people browsing. That’s why IE8’s New Tab experience is so remarkable: it’s obvious – after you see it:

IE8 New Tab Page

IE8 makes bringing back tabs (and entire IE sessions) users have closed a lot easier; it’s in the natural flow of how users work. IE8 also takes into account that there are often relationships between new tabs that users open, and the browser can make it a lot easier to figure out which tabs go with which. Below, the tabs that came from the links in the search results page are grouped together and colored differently from the headlines the user followed off another page, which are different from links the user followed off other pages:

IE8 Tab Grouping

Navigation – or getting to where you want to – is a lot faster and easier too. Typing in the Smart Address Bar not only searches across Favorites, History, and RSS feeds, but provides a great experience:

IE8 Address Bar

We put a lot of different designs in front of users in order to find one that was this effective. It’s easy to scan, with the different sections marked off and one line for each item, and the highlighting is easy on the eye. Deleting typos (or other unwanted suggestions) from this list is also easy – notice the red "x" above appears when a user places his mouse over an item.

Beyond tabs and navigation, people use services all the time. When you have an address but want a map, or want to just select some text and make a blog post out of it, IE8’s Accelerators (formerly known as ‘Activities’) are handy. For Beta 2, we’ve worked with a lot of great partners to deliver a bunch of choices for users. They’re much faster and easier than the “select, copy, new tab, navigate, paste, repeat” process in today’s other browsers.  We think users will enjoy the consistent experience they’ll get from service to service, and appreciate being in complete control of which are installed and are the default. We hope that websites (and enthusiasts!) write more of them and give us feedback. Staying up to date with the latest information is a lot easier with Web Slices, that put information directly in your Favorites bar where you can get at it quickly.

This is a good moment to talk about performance. We think about two kinds of performance: real world and lab. In a lab, we measure performance in milliseconds. That’s important work, and we did a lot of it since Beta 1. You’ll find IE8 is a lot faster than IE7 on many sites. We can go through and detail, for example, exactly which Gmail operations are faster in IE8 than other browsers and vice versa.

Real world performance is about how people get their tasks done, and that’s something you don’t measure in milliseconds. We think you’ll enjoy the impact of IE8’s new tabs, Smart Address Bar, Favorites bar, Search box, Accelerators, and Web Slices on your daily browsing.

Visual Search in IE8 speaks for itself. Websites can offer rich search results as you type in the Search box:

IE8 Visual Search SuggestionsIE8 Visual Search Suggestions

After installing IE8, try out Visual Search from the New York TimesWikipediaAmazon, or eBay. (Many other sites offer regular text suggestions as well.)


Safety isn’t about technologies and features, but two words: in control. We think users should be in control… of their settings, their information, what code runs on their machine, of their browser overall.

Previous posts have described what you’ll find in IE8 Beta 2 with respect to the SmartScreen Filter and protection from phishing and malware as well as many other defenses. The XSS Filter is particularly exciting because it offers real people a real defense from a real threat, by default and out of the box. We’ve blogged about InPrivate previously as well. Taken together, these features do a great job putting the user in control of their information.

The reliability improvements in IE8 Beta 2 are big. Crash recovery is nice, but not crashing is even better. Because in IE8 Loosely-Coupled IE (LCIE) separates the frame (the address bar, back button, etc.) from the tabs, and the tabs (mostly) from each other, crashes are more contained and affect fewer tabs than before. We think users will also appreciate having close boxes on all their toolbars so that disabling ones they don’t want – while leaving the ones they do – is easier.


IE8 is more interoperable with other web browsers and web standards. The contribution of CSS 2.1 test cases to the W3C is an important in order to really establish a standard way to assess standards support. We think that CSS 2.1 remains the most important place to deliver excellent interoperability between browsers. We think developers will enjoy the improvements to the built-in tools, as well as the other opportunities to integrate their sites in the user’s daily life with Accelerators and Web Slices. You can find more information at the IE Development Center,

After deciding to default IE8 to the most standards-compliant mode available, we wanted to be sure to address compatibility concerns for organizations and individuals. Would websites that expect IE8 to behave the way IE7 does create a problem for end-users? Since March, we’ve been telling developers about a small change they can make to their sites to tell IE8 to show their sites as IE7 does. Many have – but there are a lot of sites that may have not yet addressed this. The Compatibility View button (new to IE8 Beta 2) is a good solution to provide end-users a good experience as the web transitions.

Some Important Details

Anyone interested in customizing and redistributing IE8 (the way others have IE7) can find information about the IEAK here. (We’ll have a more detailed post about IEAK and group policy soon.) One important aspect of a beta release is getting feedback; we’re using the same channels as described in this Beta 1 post (for example, this IE Beta newsgroup).

Read more about guidelines for upgrading to IE8 Beta 2 today. Also, If you are currently using IE8 Beta 1 on Windows XP or Windows Server 2003 with Automatic Updates turned on, you will receive IE8 Beta 2 through Windows Update.

Download IE8 Beta 2, use it – the browser itself, the developer tools, writing an Accelerator, marking part of your page as a Web Slice – and let us know what you think.

Tuesday, June 17, 2008

Silverlight 2 Beta 2 Now Available

You can download both Silverlight 2 Beta 2 and the Visual Studio and Expression Blend tools support to target it. This add-on to Visual Studio 2008 allows you to use the .NET Framework to create Silverlight 2 Beta 2 Web sites. The Silverlight 2 Beta 2 runtime and the Silverlight 2 Beta 2 SDK are installed as part of this package. Silverlight 2 Beta 2 supports a go-live license that allows you to start using and deploying Silverlight 2 for commercial applications. There will be some API changes between Beta 2 and the final release, so you should expect that applications you write with Beta 2 will need to be updated when the final release comes out. But the developer team says these changes will be straightforward and relatively easy, and that you can begin planning and starting commercial projects now.

You can start learning Silverlight 2 by watching the getting started video. This video will show you how to install the Silverlight tools and how to create your first Silverlight application.

Thursday, March 20, 2008

Microsoft .NET Framework 3.5 Certification Exams

Microsoft has added three new exams for .NET Framework 3.5 on Microsoft Learning site for Windows Presentation Foundation, Windows Communication Foundation and Windows Workflow Foundation 3.5 and they are available from June 2008.

Monday, March 17, 2008

Inside Visual Studio 2008

Boosting developer productivity

Visual Studio is designed as a container environment that integrates the functionality of multiple visual designers for just about any supported type of application and component. This means you have readymade templates for a variety of Windows and web application types, including Windows Forms, Windows Presentation Foundation (WPF), ASP.NET sites, and web services. In addition, Visual Studio 2008 offers ad hoc designers for creating workflows and Windows Communication Foundation (WCF) services. The characteristics of each output component are managed through projects, and in turn grouped in solution containers.
The true added value of Visual Studio—and perhaps the primary reason to consider upgrades—is the boost it gives to developer productivity. Dozens of wizards, smart and context-sensitive popup windows, effective debuggers, and visual designers are examples of facilities that may not necessarily make any code automatically smarter, but still help you focus on key points—skimming over chores, repetitive tasks, and overzealous procedures.

Multitarget Projects

Have you noticed that previous releases of Visual Studio only supported one version of the .NET Framework? For years, my desktop was swarming with shortcuts to different versions of Visual Studio based on the projects I maintained at the time: Visual Studio 2002 for .NET Framework 1.0 applications, Visual Studio 2003 for .NET Framework 1.1, and Visual Studio 2005 for .NET Framework 2.0 applications. Finally, Visual Studio 2008 introduces a cool feature called “multitargeting” that lets us create applications for specific versions of the .NET Framework.
Multitargeting brings two main benefits to the table:
  • You no longer need to install two or more different versions of Visual Studio to deal with the various clients and projects.
  • You are no longer subliminally invited to upgrade to the next, super-cool version of .NET because of the new, super-cool time-saving features of the next Visual Studio. One IDE fits all .NET Frameworks, you could say. All frameworks? Well, not exactly.
Multitargeting in Visual Studio 2008 starts with .NET 2.0 (Figure 1) and should continue for most of the foreseeable future versions. Significant changes in the Common Language Runtime (CLR) that occurred between .NET 1.1 and 2.0 made it impossible to extend multitargeting to just any existing versions of the Framework. The nice thing about multitargeting is that any piece of the Visual Studio 2008 UI adapts to the target platform. The toolbox of controls, compiler settings, the list of assemblies to reference, IntelliSense on objects, and, of course, binaries are all specific to the selected platform.

Figure 1: Choosing a target platform for a Visual Studio 2008 project.

Figure 2: Upgrade the target .NET of an existing project.

The target platform is not a definitive choice. At any moment, you can upgrade or downgrade to any of the supported targets. You do this from the property pages of the project in the Solution Explorer (Figure 2). Should you install Visual Studio 2008 if you’re mostly maintaining existing .NET Framework 2.0 applications? Clearly, the big news about Visual Studio 2008 is the support it offers for 3.x .NET applications. However, even from a platform-agnostic perspective, there’s something it offers—an improved set of facilities with a particular attention to web developers. JavaScript debugger, CSS, master pages designer, and LINQ helper tools are all features available independently from the target platform.

Some C# and VB Syntactic Sugar

In Visual Studio 2008, C# and Visual Basic offer a few time-saving features that basically give the compiler the burden of creating some required code. In the end, these features are just syntactic sugar that make C# and VB programming easier and more pleasant.
“Automatic properties” is a feature that instructs the compiler to automatically add a default implementation for the getter/setter methods of a class property. This code is now perfectly legal in a class compiled with the newest C# compiler:

public string ContactName { get; set;}

The compiler automatically expands thiscode like this:

private string contactName;
public string ContactName
get { return contactName; }
set { contactName = value; }

Automatically generated get/set properties are not equivalent to public fields. From a metadata perspective, properties and fields are quite different entities. The idea here is that you just delegate to the compiler the creation of some plumbing code, in the most common and simple scenario. At a later time, you can always come back and provide your own getter/setter methods.

Object initializers are another piece of syntactic sugar to speed up the creation of the code that initializes an object. Instead of going through a potentially long list of assignment instructions, you can code it like this:

Person person = new Person {
LastName="Esposito", Age=24 };
The idea is extended to collections, as in this code:

List friends = new List
{ new Person {FirstName="Nancy", LastName="Davolio", Age=28 },
new Person { FirstName="Andrew", LastName="Fuller", Age=35 },

Compared to the syntax required in Visual Studio 2005, the savings is pretty clear and can easily sum up to tens of lines of code for large procedures.

Richer Languages Beyond the Sugar

Programming languages are not immutable. Especially when they’re tightly coupled to a runtime environment such as the CLR, they progress as the underlying machinery is refined and enhanced. For example, the .NET Framework 2.0 supplied a C# compiler with additional features compared to the compiler for the .NET Framework 1.x. In Visual Studio 2008 and with .NET 3.5 onboard, you can use a significantly richer C# and Visual Basic .NET languages.
Both languages now incorporate features that enable functional programming and add specific keywords for Language Integrated Queries (LINQ).
Extension methods are a way to extend the otherwise hard-coded contract of a class by adding new methods programmatically without creating a derived or partial class. The idea behind extension methods is bringing the flexibility of duck-typing to a strongly-typed and compiled environment such as the CLR. In practice, you may use extension methods whenever you feel that a given class you’re using lacks a helpful method. If you have no access to the source code of this class, in Visual Studio 2008 you define an extension. Extension methods can be defined for any class, including native classes of .NET. Listing One shows how to extend the System.String class with a few methods such as IsDate, IsInt32, and ToDate.

Listing One
namespace Samples
public static class StringExtensions
public static bool IsInt32(this string content)
int number;
bool result = Int32.TryParse(content, out number);
return result;
public static bool IsDate(this string content)
DateTime date;
bool result = DateTime.TryParse(content, out date);
return result;
public static DateTime ToDate(this string content)
DateTime date;
bool result = DateTime.TryParse(content, out date);
if (result)
return date;
return DateTime.MinValue;
public static int ToInt32(this string content)
int number;
bool result = Int32.TryParse(content, out number);
if (result)
return number;
return Int32.MinValue;

An extension method is defined as a static method on a static class. The binding between the method (say, IsInt32) and type (say, System.String) is established through the this keyword in the method’s prototype:

public static bool IsInt32 (this string content)

The type that follows the this keyword is treated as the type to extend.

The following code illustrates how you can use these new methods in your code:
void btnDate_Click(object sender, EventArgs e)
string content = textBox1.Text;
if (content.IsDate())
DateTime date =content.ToDate();
label2.Text = String.Format("Next day is {0}",date.AddDays(1).ToString("dd MMMM yyyy"));
label2.Text = "Not a valid date.";

Extension methods are checked at compile-time and can be applied also to any parent class or interface in .NET. (Extension methods could be used to obtain a feature that looks similar to mix-ins. Overall, a mix-in is a sort of interface with implemented methods. A class that implements a mix-in includes—but not inherits—all the members on the mix-in’s interface. Currently, C# and Visual Basic .NET don’t natively support mix-ins, even though instructing the compilers to produce the code for it didn’t appear to be a huge effort. With extension methods, you can simulate mix-ins in the latest C# and Visual Basic .NET.)

The var keyword is another interesting new entry. Used to qualify a variable, it doesn’t indicate a late-bound reference. Instead, it merely indicates that you don’t know the type of the variable at the time of writing. However, the type won’t be determined at runtime (late-binding), but the compiler infers the type from the expression assigned to the var variable. For this reason, an initial value assignment is required to avoid a compiler error. When var is used, a strongly typed reference is always generated.

The var keyword enables another cool C# feature—the anonymous type. This is an unnamed type that you define using the same object initializer syntax mentioned earlier:
var person = new { FirstName="Nancy", LastName="Davolio", Age=28 };
For the CLR, anonymous and named types are exactly the same entity. Anonymous types can be used in a variety of scenarios, but have been introduced primarily to support LINQ queries. The same can be said for lambda expressions. Lambda expressions are used as a convenient way to create delegates, especially (but not uniquely) in LINQ. In .NET, a delegate is an object-oriented wrapper for a function pointer and points to an existing and named function in a class. In .NET 2.0, managed languages offered new, powerful construct—anonymous methods. Basically, you have an explicit code snippet defined inline and used as an unnamed method of some class. Lambda expressions are a further refinement of the idea of an anonymous method, just less verbose and niftier.

LINQ Facilities

Most Windows and web applications are centered on some sort of data repository, usually a relational database. To retrieve data, you have to use a different API each time. It can be SQL for relational databases, XQuery and XPath for XML documents, some interface (ICollection, for instance) for collections and arrays. The main goal of LINQ is unifying this model by providing an ad hoc framework. Conveniently, this query framework is wired to some new keywords in C# and VB:

int[] fiboNumbers = new int[] {0,1,1,2,3,5,8,13,21,34};
var data = from n in fiboNumbers
where n % 2 == 0
select n;

As weird as it may seem, this is C# code that compiles in Visual Studio 2008. The new keywords are from, where, and select. Their meaning is really close to the meaning that analogous keywords have in SQL. Translated to human language, the query assigns to the data variable all elements in the queryable object (a collection, in this case) that match the specified condition (all even numbers in this case). Here’s another LINQ expression that uses lambdas:

var data = (from c in customers
where c.Country == "USA"
select c).SelectMany(c => c.Orders);

A lambda expression is characterized by the => operator, prefixed by input parameters, and followed by the parametric expression to evaluate. The preceding code selects all U.S. customers and flattens the result set to a list of orders. Without the SelectMany keyword and the input lambda, you’ll get an array of collections of orders—not a list of order objects.
LINQ operators work on objects that implement a particular interface IQueryable. .NET 3.5 counts a number of these objects. They are wrappers for wellknown data containers such as collections, XML documents, DataSets, and SQL Server databases. The model is extensible too, so third-parties can provide their own LINQ engine to query Oracle databases or perhaps the filesystem.

The most interesting of LINQ queryable objects is the object that wraps a SQL Server 200x database. It is a user-defined class that inherits from a base class named DataContext. Visual Studio 2008 provides an ad hoc visual tool called “O/R designer”; see Figure 4. After you set up a database connection in the Server Explorer window, you drop tables and stored procedures in the designer and get a dynamically generated class to work with. Next, you simply instantiate this class and use it as the queryable object:

NorthwindDataContext dataContext = new NorthwindDataContext();
var data = from c in dataContext.Customers
where c.Country == "Spain"
select c;

You can then go through the returned result set using a for/each statement or just bind the object to a data-bound control.

Figure 3: O/R designer modeling the SQL Server's Northwind database.

Visual Studio 2008 Projects

LINQ facilities span over all types of projects where database access and queries make sense. But other improvements are specific to web projects. For example, the editor of master pages has been enhanced to fully support nested master pages. Nested master pages were already working in ASP.NET 2.0, but were not fully backed by the visual designer of Visual Studio 2005. In addition, Visual Studio 2008 delivers support for split-view editing and a new CSS designer. A JavaScript debugger and IntelliSense extended to JavaScript classes complete the offering for web developers. From the framework perspective, the .NET Framework 3.5 has built-in support for AJAX that goes a little beyond what was already released as ASP.NET AJAX Extensions 1.0 for ASP.NET 2.0. In addition to features such as UpdatePanel and ScriptManager, you find AJAX-enabled Web Parts, WCF support for JSON, plus bug fixes and performance improvements.
On the Windows side, in Visual Studio 2008 you finally have a true WPF designer with a toolbox and a classic Properties box. Figure 4 previews the feature.

Figure 4: WPF designer in Visual Studio 2008.

Visual Studio 2008 also has flavors specifically created to facilitate tests and full application management, such as Visual Studio 2008 Team Suite and Visual Studio 2008 Team Foundation Server. The good news is that unit testing support is not just faster, but is included in the Professional edition of Visual Studio 2008.
WCF and Workflow Support
Version 3.0 was the first version of .NET to ship without a dedicated version of Visual Studio. Microsoft released a few extensions to Visual Studio to make it easier for developers to build WCF services and workflows, but in fact it just separates downloads. WCF and workflow projects and related renewed designers are included in Visual Studio 2008. Figure 6 shows the workflow designer whose toolbox distinguishes between version 3.0 and 3.5 activities. The newest activities include an activity to send and receive JSON data to and from a WCF service.

Figure 5: Workflow designer in Visual Studio 2008.


Visual Studio is Microsoft’s flagship for developers, and Visual Studio 2008 is the first version of Visual Studio to support multiple version of .NET. You can choose the target platform when you create the project and find around you an IDE that offers only controls and components adequate to the target platform. The improved capabilities of editors and designers, though, are shared by all projects, regardless of the platform. Visual Studio 2008 fully integrates in the IDE tools for creating workflows as well as WCF and WPF assemblies. It also brings in AJAX capabilities in ASP.NET web projects and adds JavaScript to the list of languages for which it can offer serious debugging and IntelliSense features. Available in a variety of formats such as Standard, Professional, and Team Suite, it is also available in free Express versions.