Best Web-Based Regular Expression Tester

When writing regular expressions for use with RegEx tools in .Net, there are many resources available on the web.  The best one I’ve found is


Hopefully now that I’ve blogged it, I’ll be able to find it quickly next time.



SharePoint 2010 Virtualization Options

There are new and exciting changes around SharePoint 2010. This post deals with the changes specifically around virtualizing your SharePoint development environment. 

Important points about SharePoint 2010 to consider:

  • 2010 runs on a 64-bit only
  • 2010 has heavier memory requirements than MOSS 2007
  • 2010 can run on Windows Server 2008 or Windows Server 2008 R2
  • 2010 can run on Windows Vista x64 or Windows 7 x64
  • Memory: Give your 2010 environment lots of memory!

I like to run SharePoint (and beta software) in a virtualized sandbox on my laptop. There are several options, but Virtual PC (my old free favorite) is out of the running because it does not support 64-bit guest OS. So what are my other choices?

  • Windows Server 2008 or R2 with Hyper-V
  • Sun’s VirtualBox
  • Native boot to VHD
  • VMWare Workstation (a good choice, but not a free one!)

Hyper-V is a great option.  It lets me hand lots of memory over to my guest OS. I reserve at least 1GB of RAM for the host, and give SharePoint my other 7 GB (my laptop is maxed out at 8GB).

Sun’s VirtualBox is free, and an interesting option.  It’s the only virtualization tool I know of that let’s you run a 64-bit guest on a 32-bit host. On the downside, it doesn’t have good snapshot support, and it won’t let me hand over more that half my RAM to the guest.

Native boot to VHD is awesome!  Windows 7 and Windows Server 2008 R2 support booting natively from a vhd.  It works like a dual boot configuration to disk partition, without requiring a partition. For SharePoint 2010, this is a nice option if your memory resources are limited to 4GB and you want the OS running SharePoint to have all your memory.  For more info on boot to VHD option, see my post.

VMWare Workstation is an excellent virtualization tool, if you don’t mind paying for it.  VMWare ESX is an excellent platform for virtualizing production and test farms.  For laptop-ware though, it’s hard to beat free!

With SharePoint Dev Options on Windows 7 – Why Virtualize?

Developing on Windows Vista and Windows 7 is an interesting option, and the tools support Microsoft is bringing to the game in 2010 are huge steps in the right direction.  That said, development is still best-done on an OS that is a close copy of the production environment. 

Server Operations Systems are more hardened against attacks, and they have more services for features that you will need.  Much of SharePoint development is testing to ensure things will work in your target environment.  This is best accomplished when you’re working on the same operating system.

I’m completely addicted to virtualization, particularly when dealing with server products like SharePoint. 

  1. The flexibility just can’t be matched on physical hardware
  2. Developing for SharePoint involves a lot of machine or domain level configuration. This cannot be easily isolated or duplicated without virtualization tools like snapshots, differencing disks, and good old copy/paste.
  3. Moving VMs between machines is very useful, so I can develop on a desktop when I have one, or on a laptop when I have to.

What’s On My Box?

I’m glad you asked!  I’m running a multi-boot configuration on my laptop. I’m in love with the new boot to vhd option.  I have several boot-to-vhd disks setup on my hard drive to meet specific client needs, etc.  For more info on boot to VHD option, see my post.

For my primary workstation configuration (and SharePoint development) I use a native boot vhd with Windows Server 2008 R2 with Hyper-V.  SharePoint 2010 Beta and other systems I’m currently playing with are running as Hyper-V images.

My DELL D830 laptop is not new, in fact it’s officially limited to 4GB of RAM.  I have it tricked out with 8GB of RAM using a BIOS glitch, so 2008 R2 recognizes 8GB.  If you have a D830 and want to try it read more here.

I reserve 1 GB from my host, and give 7 GB to the my SharePoint 2010 guest OS.  It runs very snappy with this configuration.  For a farm test, I can run more VHD’s if needed, but 2010 really likes the memory.

My SharePoint 2010 test lab is running as a DC/DNS server, with SQL 2008, Office 2010 beta, SharePoint 2010 beta, and Visual Studio 2010 beta.  I left Exchange 2010 out of the mix for now, but will likely setup a separate server for it later to test workflow integration with Outlook.


Windows 7 / Windows Server 2008 R2 – Boot to VHD

Windows 7 and Windows Server 2008 R2 support booting from a VHD directly.  No host OS involved.  Very nice!  It kind of blows my mind a bit to think of the possibilities. 

How Does It Work?

It works like a dual boot machine, where you pick your OS option at startup.  Instead of having physical disk partitions, you can multi-boot onto a VHD instead of a disk partition.  You can boot directly to a VHD running SharePoint 2010 beta for example.   You can have as many of these as you need (and have disk space for).

For people limited to 4GB or RAM on a laptop, this can help SharePoint 2010 run much smoother because it has all the physical memory, no memory sharing with the host.  Your physical disk is available from the booted OS (VHD becomes C:, and physical disks looks like a D:, E:, etc.).  All physical hardware is available, just as if you installed the OS directly to a disk partition.

You can even get it to work with Vista as your main OS on your machine if you’re not ready to rebuild your machine with Windows 7 or Windows Server 2008 R2.  

What’s the Catch?

There are a few catches that I’m aware of: 

  • It only works if the VHD is stored on an internal disk 
  • The OS on the VHD must be Windows 7 or 2008 Server R2
  • Hibernation and bit-locker don’t work when booted from VHD’s.  Suspend does work on my Dell D830 after I installed the NVIDEA drivers for my video card. 
  • It works best with a fixed-size VHD, dynamic VHD disks will run slower
  • There is a slight performance hit, around 3%, when compared to a boot from a physical disk.  It’s negligilbe, I haven’t noticed a difference at all.
  • The vhd is not portable to other boxes due to hardware differences between machines.  You can sysprep and image and move it that way.

Great! Now How Do I Set It Up?

I won’t recreate a detailed walkthrough here, but the basic gist of it is this:

  1. Insert Windows 7 or Windows Server 2008 R2 media
  2. Boot from the CD like you’re installing the OS normally
  3. At the first screen, hit Shift-F10 to open a command window
  4. Use the DiskPart utility to create and mount the vhd.  Type DiskPart at the command prompt cnd enter the following commands:
    1. create vdisk file=C:\VHD-Windows7.vhd maximum=40960
    2. select vdisk file=C:\VHD-Windows7.vhd
    3. attach vdisk
    4. exit
  5. Close the command prompt and continue setup
  6. Select the Custom (Advanced) Install option
  7. Select the VHD disk you created for the install
  8. That’s it!  The Windows installer takes care of the rest.
  9. If you want more control, you can use BCDEdit or EasyBCD to edit the boot menu


If you need a more detailed walkthrough, the best one I’ve seen is here:

If you’re interested in booting a Windows 7 VHD from a system running Vista (I’m not!), you might find these helpful:


SharePoint 2010 Beta – ConfigurationErrorsException

If you’ve installed the SharePoint 2010 public beta, you’ve likely run into the WCF bug. This following errors occur when provisioning Service Applications or when accessing pages that make service calls.

System.Configuration.ConfigurationErrorsException: Unrecognized attribute ‘allowInsecureTransport’. Note that attribute names are case-sensitive. (C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\WebClients\<Service Area>\client.config line <Line Number>).

The service application proxy “User Profile Service Application” could not be provisioned because of the following error: Unrecognized attribute ‘allowInsecureTransport’. Note that attribute names are case-sensitive. (C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\WebClients\Profile\client.config line 56).

You may see this error in the ULS logs after installing SharePoint 2010, or displayed on the page as an error message when provisioning service applications or accessing SharePoint pages that make WCF service calls.

How To Fix It

This is a known WCF issue when installing SharePoint 2010 on Windows 7, Windows Server 2008, or Windows Server 2008 R2.  It’s, lovingly called the WCF Sharepoint Shared Services Roll-up issue. To fix it, install a WCF OS patch:

KB971831: WCF fix for Windows Server 2008 and Vista only

KB976462: WCF fix for Windows 2008 R2 and Windows 7 
Note:  This link is not activated yet, but you can download the WCF fix at

If you have already installed Microsoft SharePoint Server 2010 on a server running Microsoft Windows Server 2008 R2 or Microsoft Windows 7, Microsoft SharePoint Server 2010 does not need to be reinstalled. You can install the WCF fix afterward. However, Service Applications that have been provisioned without the update installed may need to be removed and re-provisioned once the update has been successfully applied.


SharePoint Team Blog: Installation Notice for the SharePoint Server Public Beta on Microsoft Windows Server 2008 R2 and Microsoft Windows 7

Jie Lie’s GeekWorld: SharePoint 2010 Pre-Requisites Download Links

Dell D830 with 8GB of RAM

Dell Latitude D830 laptops have 4GB memory cap, but I’ve found a way to squeeze 8GB of RAM in there (thanks to some helpful comments from others on the web).  This is an unsupported configuration, but its working great!

8GB gives me lots more breathing room for running virtual machines, especially useful for testing SharePoint 2010 in a virtual environment.  My old laptop may be around a while yet!

If you have a D830 and want to try this, here’s how I did it:

  1. You must be running an OS that supports more than 4GB.  64-bit Vista, 64-bit Windows 7, 64-bit Windows Server 2008 or Windows Server 2008 R2.
  2. Upgrade the BIOS to A13 (download it from Dell).  I haven’t tried A14 (the latest BIOS version), but I read reports that this only works with A13.
  3. Install a matching pair of 4GB SODIMM DDR2 667 chips.  I’m using GSKILL chips I picked up from NewEgg for around $265. 
  4. When you reboot the first time, the BIOS will take a while to run through, checking out the new memory.  Verify the new memory, and your system should recognize 8GB when it comes up.  After the first boot, BIOS boots quickly.

I’m running Windows 7  64-bit and Windows Server 2008 R2, booting to a VHD.  No host OS on my PC, just a VHD on my C: drive.  Sweet!! 

Here’s the memory I ordered from NewEgg:


Get a Distinct List from ADO.Net DataSet Using Linq

There are some sample .Net functions out there to pull a list of distinct items from an ADO.Net DataTable, but none of them I found take advantage of LINQ.  So I thought I would post something I came up with to fill the gap.

In the code sample below, the goal is to pull a list of distinct values from a single column in a DataTable.  There are a few ways to approach this, depending on the end-game.  I listed 4 options, 2 with LINQ syntax and their Lambda expression twins.

// —————————————————————–
// Build a list DataTable to test
// —————————————————————–
DataTable tbl = new DataTable();
tbl.Columns.Add(“Title”, typeof(string));
for (int i = 1; i <= 100; i++)
    // Add 1 row
    DataRow row1 = tbl.NewRow();
    row1["Title"] = string.Format(“Title {0}”, i);

    // Add duplicate row
    DataRow row2 = tbl.NewRow();
    row2["Title"] = string.Format(“Title {0}”, i);

    // Add null row for testing
    DataRow row3 = tbl.NewRow();
    row3["Title"] = DBNull.Value;

// —————————————————————–
// All four of these examples yield the same results
// Each returns a list of 100 distinct rows
// Pick your poison!
// —————————————————————–

// Sample 1
// —————————————————————–
// Get a distinct list of titles
// Linq syntax against the DataTable using
// This is functionally the same as the 2nd example
List<string> distinctTitles2 =
        (from r in
            where !string.IsNullOrEmpty(r.Field<string>(“Title”))
            select r.Field<string>(“Title”)).Distinct().ToList();

// Sample 2
// —————————————————————–
// Get a distinct list of titles
// Lambda expression against the DataTable 
// This is functionally the same as the 1st example
List<string> distinctTitles1 = ((IEnumerable<DataRow>)tbl.AsEnumerable())
            .Select<DataRow, string>(r => r.Field<string>(“Title”))
            .Where(title => !string.IsNullOrEmpty(title))

// Sample 3
// —————————————————————–
// Get a distinct list of titles
// On this one, I’m using the tbl.Select() method to get an array of DataRows matching filter criteria
// Linq expression is then used against the DataRow array to get distinct titles
// This is functionally the same as the 4th example
List<string> distinctTitles4 =
        (from r in
        tbl.Select(“Title IS NOT NULL And TRIM(Title) <> ””)
        select r.Field<string>(“Title”))

// Sample 4
// —————————————————————–
// Get a distinct list of title
// On this one, I’m using the tbl.Select() method to get an array of DataRows matching filter criteria
// Lambda expression against the DataRow array to get distinct titles
// This is functionally the same as the 3rd example
List<string> distinctTitles3 = tbl.Select(“Title IS NOT NULL And TRIM(Title) <> ””)
        .Select(r => r.Field<string>(“Title”))

Enjoy! it! digg it! reddit! technorati! yahoo!

COM Interop – QueryInterface not supported (E-NOINTERFACE)


Encountering an error when trying to instantiate COM objects through Primarary Interop Assemblies (PIA’s) or Runtime Callable Wrappers (RCW’s) created using the TLBIMP.exe tool. 

When calling the object for the first time, you encounter the following COM exception:

Unable to cast COM object of type ‘xxx to interface type ‘xxx’. This operation failed because the QueryInterface call on the COM component for the interface with IID ‘{XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX}’ failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).

You are likely to encounter this problem when developing ASP.Net applications, Windows Console applications, or Windows Services.  You are unlikely to experience this issue when developing Windows Forms applications.


The problem is that you are attempting to call Single-Threaded Apartment (STA) model COM components from an Multi-Threaded Apartment (MTA) thread.  The primary thread of Windows Forms applications are STA threads, so the components work fine there.  Most other project types, including Console applications and Windows Service applications are run on an MTA thread by default.  When you attempt to instantiate the an STA component, you will get the ubiquitous error described above.

You might try calling System.Threading.Thread.CurrentThread.SetApartmentState(ApartmentState.STA), but this won’t work.  You cannot change the thread execution model on a running thread. 

To fix the problem, you can set the thread execution type on the main application thread before it is started, but this is not optimal.  It is better to set the threading model specifically for the portion of code that needs it.

A better solution is to spin up a new thread for the job at hand, and set the thread execution state on the new thread before executing it.  There are a few different methods to accomplish this depending on what you’re trying to accomplish.  Here’s one to get you started:

using System.Threading;

// Setup an object to host the thread entry point
// Start a process on an MTA thread 
MyThreadedJob jobHost = new MyThreadedJob(jobId);
Thread t = new Thread(new ThreadStart(MyThreadedJob.Execute));

// Start the thread

// Wait for thread to complete (optional)


More Gory Details

For more of the gory details and differences between threading models in Windows and COM, you can start here. it! digg it! reddit! technorati! yahoo!