Windows Live Writer Automation
本文关键字:Automation Writer Live Windows | 更新日期: 2023-09-27 18:17:37
我希望能够从我的(c#)应用程序中打开Windows Live Writer,并开始填写博客文章。
这应该非常简单。WindowsLiveWriter定义了一个应用程序API,它公开了一个名为WindowsLiveWriterApplicationLib的COM接口。根据这样的博客文章,在您添加一个新的引用到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?)
它声明类不能嵌入,没有构造函数,并且不包含我正在调用的方法。(当它在对象资源管理器中显示时)
我在这里遗漏了什么明显的东西?
总算修好了。
我不得不使用RegSvr32.exe注册WindowsLiveWriter.Application.dll。之后它开始工作了。
工作代码:
static void Main(string[] args)
{
WindowsLiveWriterApplication wlw = new WindowsLiveWriterApplication();
((IWindowsLiveWriterApplication2)wlw).BlogThisHtml("test", "testhtml");
}