Windows Live Writer Plugin – Hello World!

Tonight, I started looking at how to create a windows live writer plugin. Live writer has really made my blogging life easier and every release adds excellent features. In this post, I will discuss how to start a simple plugin which will put “Hello World” inside of your blog post html. In later posts I will discuss how to implement other features, finally releasing my planned plugin – but more on that at a later date.

1) The first task is to create a C# Class Library. We use a class library so the assembly created is a dll instead of an exe.

2) Windows Live Writer comes with an API to allow us to hook into the application. We need to reference this API, which can be found at C:Program FilesWindows Live WriterWindowsLive.Writer.Api.dll.

3) Now we have correctly referenced the assembly, we can reference it within our class

using WindowsLive.Writer.Api;

4) We then need to provide Windows Live Writer with some information about the plugin. We include a WriterPluginAttibute to the top of the class

using WindowsLive.Writer.Api;

namespace LiveWriterHelloWorld
(“be03e3b4-9adb-4b54-a201-81f043bad8b4”, “Hello World!”,
PublisherUrl = “”,
Description = “Insert Hello World! into the blog post”)]

public class Class1

The first two parameters are mandatory, one is the ID which is the GUID for the assembly. You can find the guid by going into the properties of the project, assembly information (see below). The second parameter is the name of the plugin. There are other parameters you can set to give more information about the plugin. In this case, I just set PublisherUrl and give it a description.


4) Next, we need to set the InsertableContentSourceAttribute to the class. This sets the text in the Menu (Insert > Hello World) and the sidebar section.

image image

The code required is this

[InsertableContentSourceAttribute (“Hello World!”, SidebarText = “Hello World!”)]

5) We need to inherit from the ContentSource class

public class HelloWorldPlugin : ContentSource

6) Next, we need to override the CreateContent method in the ContentSource class. This is what will be called from Windows Live Writer when the plugin is selected.

However, this class uses both DialogResult and IWin32Window so you will need to reference the System.Windows.Forms assembly.

public override DialogResult CreateContent(IWin32Window dialogOwner, ref string content)
content = “”;
return DialogResult.OK;

This code simple sets the content out parameter to nothing, and returns a OK DialogResult message.

7) Lets populated it with some real content. We simple set the content variable for this example.

content = “Hello World“;

8) That’s it! Done. However, we need to test it. We could have wrote unit tests for this which references the assembly to test our code works without loading Writer, however we still need to test the actual integration into Live Writer. To do this, we need to copy the LiveWriterHelloWorld.dll assembly in the debug folder to “C:Program FilesWindows Live WriterPlugins”.

But copying the file manually every time you build is boring! So we can edit the post build events in the project property to do this manually. Note, if your on Vista your build (or VS) will need to be running as Administrator in order for it to access the C partition.


The code is XCOPY “$(TargetPath)” “C:Program FilesWindows Live WriterPlugins”

9) Close down all instances of Live writer and reopen and your new plugin will be loaded. We could have added a icon by setting the value in the plugin attribute.

image image

When you select the item, a bold Hello World will be inserted.


This is great as the content is actually inserted into the html so we have a lot more control over what we can insert.

I hope you have found this useful, its just a very quick overview of how to get started creating the plugin’s.

Download code: HelloWorldPlugin.cs.txt

Technorati tags:

3 thoughts on “Windows Live Writer Plugin – Hello World!”

  1. Sorry about that Joe, I must remember to tick the box which forces me to add a category.

    Thanks for the heads up!! I’ve added it to the category/label.

    What do you think to my posts?

Leave a Reply

Your email address will not be published. Required fields are marked *