2011-12-13 69 views
0

我希望能够从我的(C#)应用程序中打开Windows Live Writer,并且已经开始填写博客文章。Windows Live Writer自动化

这应该很简单。 Windows Live Writer定义了一个Application API,它公开了一个名为WindowsLiveWriterApplicationLib的COM接口。根据this等博客文章,在向typelib添加新引用(通常位于此处:C:\ Program Files(x86)\ Windows Live \ Writer \ WindowsLiveWriter.Application.tlb)之后,您应该能够编写代码像这样:

static void Main(string[] args) 
{ 

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

} 

...除非它不工作。不事件编译。相反,我得到的错误是这样的:

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?) 

它声称的类不能被嵌入,有没有构造,并且不包含我打电话的方法。 (当它在对象资源管理器中清楚地实现时)。

我在这里丢失了什么明显的东西?

+0

为什么downvote? –

回答

3

管理得到它的工作。

我最后必须使用RegSvr32.exe注册WindowsLiveWriter.Application.dll。之后它开始工作。

这里是工作代码:

static void Main(string[] args) 
{ 

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

} 
+1

我只想说,现在是3年半后,我刚刚通过Google搜索相同的问题发现了这篇文章。我发现它很有帮助(它回答了我的问题)。所以我试着去注意它,并意识到问题和答案都是由我自己决定的!爆笑! –