Windows Live 编写器自动化
我希望能够从我的 (C#) 应用程序打开 Windows Live Writer 并填写博客文章的开头部分。
这应该很简单。 Windows Live Writer 定义了一个 Application API,它公开了一个名为 WindowsLiveWriterApplicationLib。根据博客文章,例如 ,在添加对类型库的新引用(通常位于此处: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?)
它声称该类无法嵌入,没有构造函数,并且不包含我正在调用的方法。 (在对象资源管理器中显然如此。)
我在这里错过了什么明显的事情?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
设法让它工作。
我最终不得不使用 RegSvr32.exe 注册 WindowsLiveWriter.Application.dll。之后它开始工作。
这是工作代码:
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: