2008-12-03

WPF applications and CA2104 rule

If you are using static fields such as:

 public static class Constants

    {

        public static readonly FontFamily MyFontFamily  = new  FontFamily("Segoe UI");

    }

with “{x:Static}” markup extensions such as:

FontFamily="{x:Static this:Constants.MyFontFamily  }"

you will get the following warning:

CA2104 : Microsoft.Security : Remove the read-only designation from 'Constants.MyFontFamily' or change the field to one that is an immutable reference type. If the reference type 'FontFamily' is, in fact, immutable, exclude this message.


If you remove the “readonly” modifier you get a different warning:

CA2211 : Microsoft.Usage : Consider making 'Constants.MyFontFamily' non-public or a constant.             

In order to solve the problem convert the field, to a property with get accessor only, such as:

public static FontFamily MyFontFamily

        {

            get

            {

                return new FontFamily("Segoe UI");

            }

        }

2008-09-20

Cool way to show crashed plugins

Google’s Chrome has a cool way to display crashed plugins such as Flash.
A sad puzzle piece icon!




2008-09-05

Quick way to rename objects on WinForms with Visual Studio

Here is a quick way to rename objects of windows forms:

  1. Open the windows forms designer.
  2. Open the Document Outline (View|Other Windows|Document Outline)
  3. Select the objects using Document Outline and rename them using F2 (edit)

Better than renaming from Properties window?


Vista and Bluetooth Headsets

I decide to pair my Nokia BH-208 Bluetooth headset with my Compaq NX8220 laptop (running Vista Business SP1) to watch some cool videos from mix conference. I open the headset, enable the wireless and Bluetooth device and try to pair the headset. BUT the headset is not list of devices. Why? I try to understand what is going on.

A quick search on the web provides the answer.

Windows Vista RTM doesn’t support Bluetooth headsets. They include the functionality in beta versions, but they removed in RTM versions. This also includes the SP1 release which is already installed in my laptop.

I am pissed off, and decide to found a solution.

  1. I found that Microsoft release Windows Vista Feature Pack for Wireless for OEM vendors only, and not for general public, but the update can be found on the internet.
    I download and installed it. Beware that feature pack requires SP1.
  2. Download and install the Bluetooth device drivers from HP because headset is a Bluetooth Peripheral Device and Vista needs drivers for this.

After that the headset appears in the list of devices and paired successfully.

 

2008-03-13

Read the news in a different way!

Great blog for WPF Data Binding

Beatriz Costa works in the Data Binding Test Team and has great information for data binding.