Join LiveSide!
Sign In using: Name/Password OpenID
or Live ID: Sign In Live ID
0 out of 8,049 members
are online, & 48 guest(s).

Recent Comments

–Darren Straight
re: Writing Plugins For Windows Live Writer - Getting Started

Log in or Join to leave a comment!

LiveSide on Mobile

Our latest posts and our favorite links,
all on your phone or mobile device
Visit m.LiveSide.net
Or go to www.LiveSide.net
on your mobile device and we'll redirect you!

Tweets We Like

Loading...

LiveSide Time

Redmond

Dallas (server)

London

Shanghai

Windows Live Calendar

PDC LA Nov 17-19

   www.microsoftpdc.com

Follow us on Facebook

    LiveSide.net
   
    Promote Your Page Too

  • LiveSide on the Windows Live Network
  • LiveSide on Facebook
  • LiveSide on Twitter
  • LiveSide RSS  
  • Windows Live Alerts
  •  
  • feedburner
  •  
LiveSide - Developer Blog

Writing Plugins For Windows Live Writer - Getting Started

Hi, I'm Scøtt, or ScottIsAFool as a lot of you know me as smile_regular. Over the next series of blog entries, I will guide you through the process of making a plugin for Windows Live Writer.
In this article, I am going to show how to create a simple plugin for Windows Live Writer, starting from the beginning. Writing plugins for Live Writer is simple enough, but sometimes you just need a little helping hand, and I'm speaking from experience smile_regular.
First off, you will need to make sure that you have the required programs. Make sure that you have the following installed:
  • Windows Live Writer - download
  • Microsoft .NET Framework v2.0 - download
  • Visual Studio Express C# Edition - download (this link takes you to an installer that will require you to download the rest of the files).
Once you have installed them then we are ready to go. Open Visual Studio and start a new project, selecting Class Library andgive the plugin a name. For this example, I will call it MyNewPlugin.
Now we need to tell the plugin to look at the Windows Live Writer API. In the Solution Explorer on the right hand side, right click on the References folder and select 'Add Reference' and browse to the Live Writer folder in your Program Files folder. The dll we want is WindowsLive.Writer.API.dll:
Now that the reference has been create we need to tell the plugin to actually use the APIs, so we need to add
using WindowsLive.Writer.Api;
You should also add the reference for Windows Forms. So, following the same procedure we have just done, add the System.Windows.Forms reference from the .NET section, and again tell the plugin that we need to use it
using System.Windows.Forms;
Next we need to set the plugin's attributes:
    [WriterPlugin("8638eda4-6533-4d19-9da7-ff92ff5a7590","My First Plugin",
        Description="This is my first plugin",
        HasEditableOptions=false,
        Name="My First Plugin",
        PublisherUrl="http://scottisafool.spaces.live.com")]
 
Now, the first thing you see in those attributes is the GUID (the combination of numbers and letters), this is unique to each plugin that you make. To get the GUID for your project, right click on the project name in the Solution Explorer and click on properties, then click on the Assembly Information button in the next screen:
The second string is the text that will appear in Live Writer's Plugins section in the Options; the Description is what appears underneath the list of plugins when you have clicked on your plugin in the options of Live Writer; HasEditableOptions is either true or false and this tells Live Writer whether to put an options button in the Plugin options (for most plugins you probably won't need this set to true, and you certainly don't for this example); PublisherUrl is where you put the link to your site.
Underneath the WriterPlugin code, we need to set what text appears in the Insert section. So we use the code:
[InsertableContentSource("From MyNewPlugin")]
Time to declare the plugin's main class
public class NewPlugin : ContentSource
    {
        public NewPlugin()
        {
        }
Note: after declaring the public class, you must call that class, but keep it empty as in the example above. 
Next we need to override the main class (this is why it was left blank), and we put in the following code: 
public override DialogResult CreateContent(IWin32Window dialogOwner, ref string newContent)
        {
The ref string newContent is what actually gets put back into the blog entry, so we need to set that to equal something:
newContent = "This was put in by my first Live Writer Plugin :)";
Because of how the override works, we need to return a DialogResult of OK (I will go into this in more detail in another post), so we simply put in:
return DialogResult.OK;
Close off anything that is open (ie, }). That is your plugin written, now we need to build it. Before we do though, we should add a command into the post-build section. So, right click on your plugin name in the Solution Explorer and click on properties. Select the Build Events section and copy the following command into the post-build event section:
XCOPY /D /Y /R "$(TargetPath)" "C:\Program Files\Windows Live Writer\Plugins\"
Now we are ready to build the plugin. Hit F6 on your keyboard and watch the fun begin smile_regular. Once the build has finished successfully, open up Windows Live Writer and in the Insert section, you will see your link:
Click it and you will see the text we set for newContent is now in your blog entry. So we have now created a basic plugin for Windows Live Writer
Download the sourcecode for this example here.
Next time I will talk you through how to add an image to your link.
SL
Next - Adding An Icon >>

Comments

Darren Straight wrote re: Writing Plugins For Windows Live Writer - Getting Started
on Tue, Oct 3 2006 7:48 PM

Nice one Scott! :)

DotNetKicks.com wrote Developer : Writing Plugins For Windows Live Writer - Getting Started
on Wed, Oct 11 2006 3:08 AM

You've been kicked (a good thing) - Trackback from DotNetKicks.com

David Mohorn's Blog wrote Windows Live Writer Plugin Resources
on Thu, Oct 12 2006 6:09 AM

Windows Live Writer Plugin Resources

Developer wrote Writing Plugins For Windows Live Writer - Adding An Icon
on Sat, Oct 14 2006 2:36 AM

Ok, so now that we have the basis for our Live Writer plugin, we need to start adding things to it to make it look and feel better. The best way is to add an image to the plugin that will appear in the Insert section of Writer.

Coding4Fun's WebLog wrote Hello World Plugin for Windows Live Writer
on Mon, Nov 20 2006 1:58 AM

Scott shows the world how to create a basic plugin for Windows Live Writer. He goes over a pretty easy

Buy brand amp generic cialis online cialis center. wrote Buy brand amp generic cialis online cialis center.
on Sat, Mar 24 2007 2:47 AM

Brand cialis. Buy brand amp generic cialis online cialis center.

Joey Liang wrote 怎样为你的Windows Live Writer制作一个简单的插件
on Wed, Mar 28 2007 1:14 PM
LiveSide - Developer Blog wrote Windows Live Writer's New APIs, Deployment Methods And A Hidden Extra
on Mon, Jun 11 2007 2:55 PM

With last week's release of beta 2 of Windows Live Writer , the Writer Team released a new set of API

External RSS Feeds wrote Thank you scottisafool
on Mon, Sep 3 2007 4:40 PM

I wanted to send out a little love out to Scott Lovegrove ( scottisafool.spaces.live.com ) on

LiveSide - Developer Blog wrote Writing Windows Live Writer Plugins - A Recap
on Tue, Oct 23 2007 8:33 PM

There was a comment left on my most recent plugin guide: "I would love to see a guide on how to

Sign In Live ID using Live ID, Name/Password, or OpenID
or Join LiveSide to leave a comment!