Activate Windows from the Command Line

I build lots of VPC’s for demos, labs, prototypes, etc.  With the various flavors of Windows out there, I find it hard to find the Windows Activation icon to verify activation.

I found a new tip today to fire Windows Activation from the command line.    This technique works on Windows XP and Windows Server 2003, but does not work on Windows Vista or Windows Server 2008.

No more searching to find the Windows Activation icon!

  1. Click Start > Run
  2. Type “oobe/msoobe /a”
  3. This command triggers the “Out Of Box Experience” activation application, which opens the Windows activation screen. 
  4. If Windows is already activated, it will tell you so, otherwise, you can continue to activate Windows. 


Thanks to for this useful tip!  For more info, see How To Activate Windows XP in 5 Minutes or Less. it! digg it! reddit! technorati! yahoo!

Windows Server 2008 – Can’t Ping the Server

After installing Windows Server 2008, I found I can’t ping the server, even within a “Private Network”.  I like to ping stuff in my spare time, so this was distressing to me.  I suspected to find a firewall issue, but was surprised to find enabling the Network Discovery option in the firewall configuration settings didn’t fix it.

Configure Windows Firewall Settings – File and Printer Sharing

By default, Windows Firewall for WIndows Server 2008 is configured to disallow File and Printer Sharing on the network.  By default Windows Server 2008 firewall is configured with Windows Firewall running, and with File and Printer Sharing disabled.  This blocks ICMP Echo Request packets used by the PING command. You can allow the server to respond to ping requests by doing the following:

  1. Turn off Windows Firewall on the Windows 2008 Server (not recommended)- OR –
  2. Enable the File and Printer Sharing option in Windows Firewall Configuration Settings
    1. Start > Control Panel > Network and Intranet
    2. Under the Windows Firewall section heading, Click the Allow a program through Windows Firewall link
    3. In the programs and ports list, check the File and Printer Sharing option it! digg it! reddit! technorati! yahoo!

WPF XAML Markup – How Do I Preserve Whitespace Characters?

An issue you’re likely to run into in XAML (WPF, XBAP, and SIlverlight applications) is the need to keep whitespace characters intact in your markup.  By default, XML collapses all whitespace, ignoring strings of spaces, tabs, and return characters inside an XML node, which it graciously converts to a single space.

If you want to include a series of spaces in your XML node markup, you can add a xml:space=”preserve” attrbute to your XML elements.  This attribute  is part of the XML standard.  If you turn it on, it preserves all whitespace appearing inside the XML node, including any hard return characters included inside the XML node.

<Button Name="btnSample" xml:space=preserve">Respects my      spaces
and carraige return</Button> it! digg it! reddit! technorati! yahoo!

Virtual PC / SQL Server – Restore Database Failure – Media Family Incorrectly Formed

I ran into a problem with SQL Server restore operations recently.  I got burned for quite a while, because I thought I had a problem with my SQL Server 2000 and SQL Server 2005 installation, a SQL Server or O/S version issue, or a problem with my database backup file.  Small SQL backup files restore fine, but large backups fail on the restore on VPC images

When I restored the large backup files, ISQL RESTORE DATABASE commands fail with the following symptoms:

  • Msg 3241, Level 16, State 37, Line 1 The media family on device ‘C:\Temp\MyLargeDatabase.bak’ is incorrectly formed. SQL Server cannot process this media family.
  • The media set shows a Backup Set Name of *** INCOMPLETE ***
  • RESTORE HEADERONLY FROM DISK=’C:\Temp\MyLargeDatabase.bak’ returns BackupName of *** INCOMPLETE ***, Position = 1, the rest of the fields are NULL

The Problem

Virtual PC Shared Folders corrupt files!  Especially large files.  Small files seem to work fine.  I’ve heard reports of problems with files over 1GB to 4GB in size.  My database was around 8GB.

You get the errors shown above when you reference a file across a VPC Shared Folder, or when you create a local VPC file copy by copying a file to your VPC disk over a Shared Folder connection.

The Solution

Copy or reference files using a traditional networking file share between the host and guest, and avoid using Shared Folders for large files (or altogether).


If you think you may be having a similar issue, you can use a tool like SlavaSoft’s fsum to perform checksum comparisons file on the host and guest systems to verify what’s going on.  Or you can take my word for it and save yourself the trouble.  I’ve experienced this (the hard way) with Virtual PC 2007. it! digg it! reddit! technorati! yahoo!

SharePoint 2007 (MOSS) – How To Determine Service Pack Version

So, what version of SharePoint 2007 is on this server?  Sounds like an easy question, doesn’t it?  Oh, I forgot, this is SharePoint!

SharePoint Server 2007 (including MOSS 2007) or WSS 3.0

Correct Methods

  • Central Administration > Operations > Servers In Farm > Database Schema Version – You will see the Database Schema Version in the top of the screen and a list of servers with the version numbers listed in the relevant column against each server in the farm
  • Site Settings > Modify All Site Settings > Site Information > Database Schema Version – You will see the schema version of the site content database
  • Query the Versions table of the farm configuration database – The entries in this table will show the version number and the date it was applied to the farm

Misleading Methods – The following methods are documented all over the web, but your results may be misleading

  • IIS Web Site Properties > HTTP Headers Tab >  Custom HTTP headers box which displays a version number – This shows the build version of MOSS at the time the Virtual Directory [Web Application] was created, which is probably not what you’re looking for.
  • Add / Remove Programs – Select Microsoft SharePoint Server 2007 or Windows SharePoint Services 3.0 > Click here for support information.  This will show the current version of the software installed on a WFE server, but it does not always update and may differ from other servers on the farm.  For better results, use the methods listed above instead.
Cumulative Update KB956056 & KB956057
Infrastructure Update KB951695 & KB951297
SP1 + KB948945
SP1 + KB941274
SP1 + KB941422
October 2007 public update
August 24, 2007 hotfix
Beta 2
Beta 2 TR
Office 12 PDC Pre-beta


Running a Prior Version Of SharePoint?

If you’re unfortunate enough to be running an older version of SharePoint (SharePoint Portal Services 2003, 2001, SharePoint Team Services, or WSS 2.0), please see SharePoint Portal Services / Team Services – Determine Service Pack Version.

References it! digg it! reddit! technorati! yahoo!

SharePoint Portal Services / Team Services – Determine Service Pack Version

If you’re unfortunate enough to be running an older version of SharePoint Portal Services or WSS 2.0, here’s some version info to help you figure out what version is running.

SharePoint Portal Server (SPS) 2003

Control Panel > Add/ Remove Programs > Microsoft Office SharePoint Portal Services > Click Here for Support Information.
– OR –
Locate the mssrch.dll file (located in \Program Files\SharePoint Portal Server\Bin), right-click > File Properties > Version and check the version number:

SP3 11.0.8168.0
SP2 11.0.8126.0
SP1 11.0.6715.0
RTM 11.0.5704.0


Windows SharePoint Services (WSS) 2.0

Control Panel > Add/ Remove Programs > Microsoft Windows SharePoint Services > Click Here for Support Information. Note the version numbers:

SP3 11.0.8173.0
SP2 11.0.7969.0
SP2 Beta 11.0.6551.0
SP1 + KB887981 11.0.6411.0
SP1 11.0.6361.0
RTM 11.0.5608.0


SharePoint Portal Services (SPS) 2001

Locate the mssrch.dll file (located in \Program Files\Common Files\Microsoft Shared\MSSearch\Bin), right-click > File Properties > Version and check the version number:

SP3 10.0145.7329
SP2a 10.0145.6011.5
SP2 10.0145.6011.0
SP1 10.145.4629.0
RTM 10.145.3914.3


SharePoint Portal Team Services (SPTS)

10.0.2627.01 is the version with no service packs. 

In the Administrative Tools menu, you will see a link to Microsoft SharePoint Administrator. This will display a web page, where you can see the version number of the virtual server(s), e.g., The ISAPI filter is fpexedll.dll.


Running SharePoint 2007 (MOSS)?

If you’re lucky enough to be running an newer version of SharePoint (SharePoint 2007, MOSS 2007, or WSS 2.0), please see SharePoint 2007 (MOSS) – How To Determine Service Pack Version.

References it! digg it! reddit! technorati! yahoo!

WPF / WF – What Is A Dependency Property?

A new type of property, called a dependency property, was added to the .Net Framework with the release of .Net 3.0.  Dependency properties are used in both Windows Presentation Foundation (WPF) and Workflow Foundations (WF).  They are very similar in both frameworks, but are used for different purposes.

Dependency properties provides the plumbing for property value resolution, change notification, data binding, styling, validation, etc. for properties exposed in Windows Presentation Foundation (WPF) UI elements and Workflow Foundations (WF) custom activities.  Each dependency property is registered with a central repository that handles the change event notifications for you. 

Key Point – The Value of Dependency Properties Are Resolved

The ultimate goal of a dependency property, like any property, is to manage state.  But unlike normal .Net properties, the local property value is not stored in an instance variable. 

Instead, dependency properties are registered with the dependency property framework, and the underlying property value is resolved – meaning the value is determined by the dependency property framework based on rules defined by the property registration.

How To Create A Dependency Property

All WPF UI elements and Workflow Activities are derived from a high-level base classes called DependencyObject, which provides the basic functionality required to implement dependency properties.

public class MySampleControl : Control
    // Step 1: Register the dependency property 
    public static readonly DependencyProperty SpecialBrushProperty =
            DependencyProperty.Register("SpecialBrush", typeof(Brush), 

    // Step 2: Provide set/get accessors for the property
    public Brush SpecialBrush
        // IMPORTANT!!
        // -----------
        // Dependency property accessors should not include custom logic 
        // because the framework may call the base.GetValue() and 
        // SetValue() methods directly
        get { return (Brush)base.GetValue(SpecialBrushProperty); }
        set { base.SetValue(SpecialBrushProperty, value); }

As show in the code, there are two steps involved in creating a dependency property:

  1. Create a static field to hold a DependencyProperty object
    • By convention, the field should be named with the normal property name, followed by a “Property” suffix
    • This field will not contain the value of the property.  It simply defines the property that is registered with the dependency system
    • This field should be defined as a public, static, read-only field
      • The property must be available at all times, possibly shared among classes
      • The field is defined with the read-only keyword, meaning it can only be set in the static constructor of the type.
    • The field must be instantiated with a call to the static DependencyPropert.Register() method, passing:
      • The name of the property
      • The type of the property 
      • The type of the class that owns the property

      • Optionally, metadata used to define how the property is treated by the WPF framework
        • Meta-data flags to specify how the property affects the layout of the element (AffectsMeasure, AffectsArrange, AffectsRender, etc.)
        • Callbacks for handling property value changes (PropertyChangedCallback)
        • Callbacks to define custom value logic (CoerceValueCallback) 
        • Callbacks to validate values (ValidateValueCallback)
      • Optionally, metadata used to define how the property is treated by the WF framework
        • Include DependencyPropertyOptions enumerated value to specify additional characteristics for the property (ReadOnly, MetaData, etc.)
  2. Create property accessors (get / set)
    • Call DependencyProperty.SetValue() and GetValue() methods to set local values
    • DependencyObject is a high-level framework base class for WPF UI elements and WF activities
    • DependencyObject exposes the GetValue() and SetValue() methods

Isn’t That A Lot of Code for a Property?

At first glance, yes, this looks like an extremely complicated way to declare a property.  OK, at second glance, it’s still pretty complex.  But once you understand the power of dependency properties provide, especially in the Windows Presentation Framework (WPF), they’ll become a welcome addition to your coding toolbox. 

The convention takes a little getting used to. But after you’ve created a few, it comes quite naturally.  Visual Studio also includes some snippets to help add dependency properties:

  • Insert Snippet > NetFX30 > Define a DependencyProperty
  • Insert Snippet > Other > Workflow > DependencyProperty > Property

Subtle Differences Between in WPF and WF

While WPF and WF both use a similar dependency property frameworks, they are not identical!!

WPF UI elements and WF activities derive from a base DependencyObject class, and use a DependencyProperty class to register properties and get/set property values.  Despite the shared names, they are not the same classes!!

  • DependencyObject and DependencyProperty classes used by WPF reside in the System.Windows namespace
  • DependencyObject and DependencyProperty classes used by WF reside in the System.Workflow.ComponentModel namespace

Though their usage and function are very similar, they are not directly related to one another.

How are Dependency Property Values Resolved?

Property values for dependency properties are resolved automatically by the framework according to the following order of precedence:

  1. Property system coercion
  2. Active animations or animations with a hold behavior (WPF)
  3. Local value
  4. TemplateParent template properties (WPF)
  5. Implicit style (WPF)
  6. Style triggers (WPF)
  7. Template triggers (WPF)
  8. Style setters (WPF)
  9. Default (theme) style (WPF)
  10. Inheritance
  11. Default value from dependency property metadata

Note that the local value is 3rd in the order of precedence.  This means that a property may have a value, even if a local value for the property has never been set.  Also, if a property does have a local value, it may be overridden by higher level precedence items like an animation or data binding.

When Should I Use Dependency Properties In WPF?

Dependency properties are one of the most important concepts within WPF.  In WPF, dependency properties are required to support:

  • Data Binding
  • Animation
  • Styling
  • Value expressions
  • Property invalidation
  • Per-type default values

In short, it makes sense to expose dependency properties any time you expose a property for a custom UI element or control. 

When Should I Use Dependency Properties In WF?

Dependency properties are not used as heavily in Workflow Foundations (WF) as they are in Windows Presentation Foundation (WPF) , but they are still an important part of the WF framework.  They are used primarily when developing custom workflow activities that expose properties to support the following scenarios:

  • Activity Binding
    • This is the most common use of dependency properties in WF
    • Allows activities to expose properties that can be used to bind state to another activity
    • For example, binding the input of one workflow activity to the output of another workflow activity
  • Attached Properties
    • Attached properties are used to create a parent activity that can manage the state of it’s child activities
    • For example, the Conditioned Activity Group can attach a When property to each child
  • Meta Properties
    • Meta properties are defined by including new PropertyMetadata(DependencyPropertyOptions.Metadata) in the DependencyProperty.Register() method call 
    • Meta properties are set at design time and cannot be changed at run-time

    • Meta properties exist to guarantee the integrity of an activity
    • For example, at runtime, you can’t change the InterfaceType of an CallExternalMethod activity because InterfaceType is a meta-property

Sources it!

digg it!