Windows Live 编写器自动化

发布于 2024-12-20 21:47:03 字数 1544 浏览 5 评论 0原文

我希望能够从我的 (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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

诠释孤独 2024-12-27 21:47:03

设法让它工作。

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

这是工作代码:

static void Main(string[] args)
{

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

}

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");

}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文