0

I would like to be able to open Windows Live Writer from my (C#) application and have the beginnings of a blog post filled out.

This should be very simple. Windows Live Writer defines an Application API that exposes a COM interface called WindowsLiveWriterApplicationLib. According to blog posts such as this, after you add a new reference to the typelib (usually located here: C:\Program Files (x86)\Windows Live\Writer\WindowsLiveWriter.Application.tlb), you should be able to write code like this:

static void Main(string[] args)
{

    var wlw = new WindowsLiveWriterApplicationLib.WindowsLiveWriterApplicationClass();
    wlw.BlogThisHtml("test","test");

}

...except it isn't working. Doesn't event compile. Instead I get errors like this:

Error   1   The type 'WindowsLiveWriterApplicationLib.WindowsLiveWriterApplicationClass' has no constructors defined    

Error   2   Interop type 'WindowsLiveWriterApplicationLib.WindowsLiveWriterApplicationClass' cannot be embedded. Use the applicable interface instead.  

Error   3   'WindowsLiveWriterApplicationLib.WindowsLiveWriterApplicationClass' does not contain a definition for 'BlogThisHtml' and no extension method 'BlogThisHtml' accepting a first argument of type 'WindowsLiveWriterApplicationLib.WindowsLiveWriterApplicationClass' could be found (are you missing a using directive or an assembly reference?) 

It claims the class can't be embedded, has no constructors, and does not contain the method I am calling. (when it clearly does in Object Explorer.)

What obvious thing am I missing here?

CleverPatrick
  • 9,261
  • 5
  • 63
  • 86

1 Answers1

3

Managed to get it working.

I wound up having to register WindowsLiveWriter.Application.dll using RegSvr32.exe. After that it started working.

Here is working code:

static void Main(string[] args)
{

    WindowsLiveWriterApplication wlw = new WindowsLiveWriterApplication();
    ((IWindowsLiveWriterApplication2)wlw).BlogThisHtml("test", "testhtml");

}
CleverPatrick
  • 9,261
  • 5
  • 63
  • 86
  • 1
    I'd just like to say that is now 3 and a half years later and I just found this post by googling for the same question. I found it helpful (it answered the question I had). So I try to upvote it and realize that both the question AND the answer are by me! Hilarious! – CleverPatrick May 14 '14 at 19:04