我有一个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);
}
}
}发布于 2011-05-01 17:13:54
这是一个已知的错误,调用带有“out”的方法时不能在AutomationFactory中使用-请参阅SL4 - AutomationFactory - Call method with 'out' parameters raise exception: 'Could not convert an argument for the call to...'
顺便说一句,我不确定您要对GetHierarchy调用中的1做什么--它是指向将用所选HierarchyScope枚举的XML填充的字符串的指针。它应该是一个字符串out变量,而不是一个整数-但不管怎样,由于这个错误,它仍然不能在SL4中工作。
https://stackoverflow.com/questions/5813670
复制相似问题