【问题标题】:Calling OneNote GetHierarchy() from Silverlight Application从 Silverlight 应用程序调用 OneNote GetHierarchy()
【发布时间】:2011-04-28 04:36:34
【问题描述】:

我有一个 Silverlight 4 浏览器外的提升信任应用程序。我想使用 OneNote 2010 对象模型通过 AutomationFactory 与 OneNote 进行通信,但我无法让应用程序的 GetHierarchy() 方法工作。我知道我在 OneNote 中有数据,因为我可以从 .NET 应用程序调用该方法并从中取回数据。 GetHierarchy() 方法返回 null。有什么建议吗?

class OneNoteAutomation
{
    dynamic oneNote;

    enum HierarchyScope
    {
        hsSelf = 0,
        hsChildren = 1,
        hsNotebooks = 2,
        hsSections = 3,
        hsPages = 4
    }

    public void GetHierarchy()
    {
        if (AutomationFactory.IsAvailable)
        {
            this.oneNote = AutomationFactory.CreateObject("OneNote.Application");

            var result = this.oneNote.GetHierarchy(
                string.Empty, 
                (int)HierarchyScope.hsNotebooks, 1);            
        }
    }
}

【问题讨论】:

  • 只是想看看下面是否回答了您的问题(不幸的是,它不能解决问题,但现在是唯一可能的答案)。
  • 这是一个很好的答案 - 我只是在等待一个能解决我问题的答案。
  • 我听到了。我会对允许您在 SL 中使用 out 的答案感兴趣。不幸的是,我不相信存在。

标签: silverlight silverlight-4.0 onenote


【解决方案1】:

这是一个已知错误,无法在 AutomationFactory 中使用带有“out”的方法调用 - 请参阅 SL4 - AutomationFactory - Call method with 'out' parameters raise exception: 'Could not convert an argument for the call to...'

顺便说一句,我不确定您在 GetHierarchy 调用中尝试使用 1 做什么 - 这是指向将填充所选 HierarchyScope 枚举的 XML 的字符串的指针。它应该是字符串 out 变量,而不是整数 - 但无论如何,由于错误,它仍然无法在 SL4 中工作。

【讨论】:

  • 我已经确认这是 Silverlight 4 COM 自动化编组器中的一个错误:[out] 参数不起作用。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2010-12-29
  • 2012-04-15
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多