Less MSIèrables – Extract the content of a .MSI file

Yesterday, I decided to spent some time reviewing the WindowsLiveWriter plugin gallery and search for a replacer for Steve Dunn CodeFormatter plugin. I’ve been using this plugin since the beginning of the year but it reveal some problems composing the Html.

My friend Paulo told me about Douglas Stockwell "Paste from Visual Studio" plugin and I decided to try this one.

I download the vspaste.msi and tried to install it without success. As far as I understood (I didn’t take this to depth) the .MSI was looking for a specific registry entry and since I’m using the portable version of WLW the key wasn’t found.

I knew that WLW plugins don’t required any special install procedure, they just need to be in the plugins folder.

I decided then to extract the .MSI content in order to be able to copy the assembly to the correct folder in my flash drive.

Searching the web I found a little tool called "Less MSIèrables" that exactly feets my needs.

It’s a free tool written in C# for .NET 1.1 that allow us to open an .MSI file, explore its contents, and extract selected items.


We can also run it from the command line.

Its not perfect and I found a few possible improvements:

  • GUI – adding Drag’n’Drop capability
  • GUI – adding a select/unselect all files checkbox
  • CPI – adding a -l option to list all files within a .MSI file
  • CPI – adding a -e option to extract a list of files

The good news is that author made the source code available, so anyone can extend the tool.

In conclusion, it’s free, it’s cool and I think I going use it many times in future, helping me to see if I really need to install a .MSI.

For those of you that prefer not to use free tools, Microsoft provides us with msiexec.exe tool. This one is available in Windows XP and higher and also allow us to extract .MSI files using the following syntax:

msiexec.exe /a vspaste.msi /qb TARGETDIR=c:\temp

ASP.NET – Dynamic Control Mapping

I already posted here about Tag Mapping and how helpful it can be, but naturally there’s are a few improvements that I would like to see available in future framework release.

The one I expect the most is about the capability of mapping dynamic created controls using the same rules as Tag Mapping uses when interpreting the page markup.

Without this capability we can never use widely the tag mapping because whenever we need to create dynamic controls they will be strongly coupled to a specific control implementation.

Imagine this scenario:

  1. First you have built an web application that use standard ASP.NET TextBox  control, some of them dynamically created.
  2. Now, imagine that you want to reuse that application, as is, but instead of ASP.NET Textbox control you want to use your own Textbox implementation.

This task could be easily accomplished using Tag Mapping if no dynamic controls were used, but in this scenario ASP.NET give us no solution, so the application cannot be reused without modifications.

Naturally, you can copy/paste your application and make the necessary changes, or even add a few if statements, but that will only increase complexity and maintenance effort.

Until the .NET team provide us such capability we must do the magic ourselves.

My proposal is an help class (DynamicControlBuilder) that provide us two methods: GetMappedType and CreateControl.

/// <summary>
/// Gets the mapped <see cref="System.Web.UI.Control"/> type.
/// </summary>
/// <param name="type">The <see cref="System.Web.UI.Control"/> type to be mapped</param>
/// <param name="prefix">The namespace prefix.</param>
/// <returns>A <see cref="System.Type"/> object.</returns>
public static Type GetMappedType(Type type, string prefix)
    if (!typeof(Control).IsAssignableFrom(type))
        throw new ArgumentOutOfRangeException("type", "Must inherit from Control.");
    Type mappedtype;
    if (!string.IsNullOrEmpty(prefix))
        TagPrefixInfo prefixinfo;
        if (!m_prefixes.TryGetValue(prefix, out prefixinfo))
            throw new ArgumentException("prefix", "No prefix found.");
            type = BuildManager.GetType(string.Format("{0}.{1}, {2}", prefixinfo.Namespace, type.UnderlyingSystemType.Name, prefixinfo.Assembly), false); if (type == null) { throw new ArgumentException("type", "Control not found within specified prefix."); }
    if (m_tagMappings.TryGetValue(type.UnderlyingSystemType, out mappedtype))
        return mappedtype;
    return type;

/// <summary>
/// Creates a dynamic mapped <see cref="System.Web.UI.Control"/>.
/// </summary>
/// <param name="type">The <see cref="System.Web.UI.Control"/> type to be mapped</param>
/// <param name="prefix">The namespace prefix.</param>
/// <returns>A <paramref name="T"/> object.</returns>
public static Control CreateControl(Type type, string prefix)
    Type mappedType = GetMappedType(type, prefix); 
    return (Control)Activator.CreateInstance(mappedType);

The main goal is to enable any of the following usages:

this.Page.Controls.Add(DynamicControlBuilder.CreateControl(typeof(System.Web.UI.WebControls.TextBox), "foo")); 

Try it !

DynamicControlBuilder.cs (7.13 kb)

kick it on DotNetKicks.com