2011-12-13 41 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搜索相同的問題發現了這篇文章。我發現它很有幫助(它回答了我的問題)。所以我試着去注意它,並意識到問題和答案都是由我自己決定的!爆笑! –