Creating a plugin for Windows Live Writer using VB.NET

Although I know, that the majority of people use C# for creating plugins to Windows Live Writer – I’d still like to make a small guide into the basic concept of creating a plugin using VB.NET.

1) Create a new project in Visual Studio .NET
ScreenHunter_27  
Select the template "Class Library" and type the name of your project in the Name field.

2) Delete the default class created.

3) Add a new class to your project.
ScreenHunter_28

4) Add a reference to the Windows Live Writer API.

ScreenHunter_29

- and a reference to System.Windows.Forms

ScreenHunter_30

5) Import the namespaces

Imports WindowsLive.Writer.Api
Imports System.Windows.Forms

7) Create a Folder in your project and name it Images:

ScreenHunter_31

Create a new PNG-image at the size of 20 by 18 pixels and save it in your "Images"-folder.

8) Add the file as a ressource

    1. Double-click "My Project"
    2. Click "Resources"
    3. Click "Add Resource" – and make sure you click "Add Existing File", and select the image saved in your Images-folder
    4. If you find that type system.drawing.bitmap is not defined – try adding and removing a form.

10) Click your image in the Images-folder and under Build Action select "Embedded Resource".

9) Add some code (Please note, that the GUID should be unique for your plugin – if you need a guid – then go to http://www.replymedia.net/guid):

Imports WindowsLive.Writer.Api
Imports System.Windows.Forms
<WriterPluginAttribute("05D06AD8-694D-458B-9631-F8F19F88A9BA", _
"Insert current date and time", _
Description:="Inserts current date and time", _
ImagePath:="DemoPlugin.png", _
HasEditableOptions:=False, _
PublisherUrl:="http://tech.pederborgpoulsen.dk"), _
InsertableContentSourceAttribute("Current Date and Time")> _
Public Class Plugin
    Inherits ContentSource
    'Overrides the function CreateContent
    Public Overrides Function CreateContent(ByVal dialogOwner As System.Windows.Forms.IWin32Window, ByRef newContent As String) As System.Windows.Forms.DialogResult
        Try
            'Adding content to newContent - newContent is returned to Windows Live Writer
            newContent = FormatDateTime(Now(), DateFormat.GeneralDate).ToString
            'Returns to caller
            Return DialogResult.OK
        Catch ex As Exception
            'Do some error-handling
        End Try
    End Function
End Class

10) Build the project and copy the DLL-file to your Windows Live Write Plugin-directory.

11) Start or Restart Windows Live Writer – and notice that your plugin appears in the Insert-list:

ScreenHunter_33

12) And that clicking on it inserts the current date and time: 05-09-2006 21:32:33

… Happy Coding …

4 Comments »

  1. Creating a plugin using VB.NET « Windows Live Writer Plugins said,

    September 7, 2006 @ 12:01 pm

    [...] [...]

  2. lifeware said,

    September 12, 2006 @ 10:56 pm

    Peder your tutorial worked great! :) i made a plugin! How can i put an about box?

  3. Peder Borg Poulsen said,

    September 13, 2006 @ 11:36 am

    Hm… Don’t really know how to add an about-box. It’s quite easy to add it to your project, and display it using a button or so – but, don’t really know how to display the info of your plugin, and not Windows Live Writer. I might look into that.
    :-)

  4. JSBettridge said,

    January 24, 2007 @ 6:28 am

    This tutorial was very good. Another way to resolve the missing bitmap error that is slightly easier is to Add a referance to System.Drawing. Thanks for the tutorial!

RSS feed for comments on this post · TrackBack URI

Leave a Comment