2017-07-27 208 views
1

WriterDemo example使用VB.NET与UNO API进行交互。 (也包括与SDK下载在file:///C:/Program Files/LibreOffice 5/sdk/examples/CLI/VB.NET/WriterDemo/中的文件。)用于LibreOffice SDK的VB.Net示例

要构建并运行,我设置的命令行环境根据https://api.libreoffice.org/docs/install.html,然后使用make WriterDemo.run执行的Makefile文件。但它崩溃在这条线:

xContext = Bootstrap.bootstrap() 

错误消息:

Unhandled Exception: System.Runtime.InteropServices.SEHException: External component has thrown an exception. 
    at cppu.bootstrap(Reference<com::sun::star::uno::XComponentContext>*) 
    at uno.util.Bootstrap.bootstrap() 
    at WriterDemo.Main() 
make: *** [WriterDemo.run] Error -1066598274 

这是问题Equivalent of Microsoft.Office.Interop.Excel for Open Office and/or Libre Office for VB.NET/Visual Studio 2017的随访。

回答

0

使用Visual Studio而不是Makefile。

  • 启动一个新的Visual Basic控制台应用程序。
  • 将WriterDemo.vb中的代码粘贴到Module1.vb中。通过右键单击解决方案资源管理器中的文件,将Module1.vb重命名为WriterDemo.vb。
  • 在项目属性中,将启动对象更改为WriterDemo
  • 右键单击References并选择Add References。浏览到SDK中的cli文件夹,例如C:\Program Files (x86)\LibreOffice 5\sdk\cli。 (GAC中的文件不适用于我。)
  • 从该文件夹中选择所有5个文件,然后按添加。然后确保每个框中都有复选标记。
  • 修改App.config以修复here所述的加载问题。
  • 为避免发生警告,请按here所述将处理器体系结构设置为x86
  • 它也可能需要set UNO_PATH,虽然它为我工作,但没有这样做。

现在在工具栏中按下Start(或Debug - > Start Debugging)。如果一切顺利,它将启动LibreOffice并将一些内容插入Writer。

描述VB 2005的较早示例是https://forum.openoffice.org/en/forum/viewtopic.php?f=20&t=21494

感谢@Zev Spitz的提示和更正。