Category Archives: .Net

Visual Studio 2010 and HW acceleration on Windows XP…

Last week during the MVP summit in Seattle we’d the confirmation that the SP1 of Visual Studio was almost ready and today we’ve more details: “Visual Studio 2010 Service Pack 1 will be available March 9th for download for MSDN Subscribers, and will be generally available for download on March 10th, 2011” [from G.Duthie’s blog on MSDN].

“While the Service Pack is mostly focused on improvements in response to feedback on Visual Studio 2010, one new feature I want to highlight is the integration of IIS Express into Visual Studio 2010. IIS Express, which was introduced with the new Microsoft WebMatrix editor, is a lightweight, yet full-featured version of IIS that can run without administrative permissions.”

Another important thing to notice about the SP1, is that it will disable the hardware acceleration of the IDE on Windows XP. Yes, you read correctly, despite WPF’s support for accelerated graphics, this feature will be disabled on XP (for VS only).

Background

When the version 3.5 of the .Net framework was released, Microsoft added a new software rendering engine in case the hardware was not able to do the job. This feature could be enabled at the Window level using the following code:

HwndSource hwndSource = PresentationSource.FromVisual(this) as HwndSource;
HwndTarget hwndTarget = hwndSource.CompositionTarget;
hwndTarget.RenderMode = RenderMode.SoftwareOnly;

With WPF4, this is now possible at the Process level using a single line of code:

RenderOptions.ProcessRenderMode = RenderMode.SoftwareOnly

Another trick you can use in your application is to determine whether your application is currently using hardware acceleration. You can do that by looking at the RenderCapability.Tier enumeration.

In your applications running on XP…

Now the immediate question that might come in your mind is: “If VS2010 is disabling HW acceleration on XP, should I do the same on my WPF application which is shipped on XP too ?”

I guess the answer is “maybe” and it actually depends on various factors:

  • does your user reported crash that seems correlated to video drivers issue ?
  • does your application extensively uses complex graphical effects (for example this is clearly not the case in VS2010) ?
  • what kind of hardware your users are using. Is this recent hardware (which are being downgraded to XP) or is this really old hardware ?

Maybe a good option is to let the user change this settings (while having a default value). In VS2010, you’ll be able to turn on HW acceleration back by using the settings dialog:


Anyway, I thought at the beginning it was a very weird decision. But after all; if the majority of the crashes they see in VS on Windows XP is linked to bad drivers, it makes sense.

MSDN Ultimate Subscription Giveaway

IMG_0833 As a Microsoft MVP for this year, I got 3 MSDN Ultimate Subscriptions to share with friends and co-workers. I already gave 2 of them to co-workers and I’d like to offer the last one to one of my reader !

The “official” pricing for the MSDN Ultimate Subscription is $11,899. The subscription is valid one year and is not restricted to US only. The MSDN Ultimate has the following items (among many others – you can see the detailed list here):

  • Windows Azure Platform
  • Visual Studio 2010 Ultimate
  • Visual Studio TFS 2010
  • Expression Studio Ultimate
  • Windows 7, Windows Server 2008 R2 and SQL Server 2008
  • Microsoft Office Professional Plus 2010, Project Professional 2010, Visio Premium 2010

In order to take your chance to get this subscription:

  • let a comment on this blog post
  • explain what you would like to do with the subscription
  • share you blog address, community website or whatever to show how you’re involved in the .Net community

Contest is now over. The winner of the MSDN Ultimate License is Mike Strobel. Thank you all for letting a comment, I which I had more subscriptions to giveaway…

Attributes-based validation in a WPF MVVM application

Today, I’m proud to share with you my very first article available on CodeProject. This article presents a technique which can be used in order to add validation in a WPF MVVM application based on attribute. Basically, it means that you can write validation logic like that (notice the attribute associated to this property):

[Required(ErrorMessage = "Field 'FirstName' is required.")]
public string FirstName
{
    get
    {
        return this.firstName;
    }
    set
    {
        this.firstName = value;
        this.OnPropertyChanged("FirstName");
    }
}

Of course the article comes with a nice demo application:

You can read the full article here: Attributes-based validation in a WPF MVVM application