在 C# 中创建新的 Calc 文档 (OpenOffice)

发布于 2024-10-29 13:48:49 字数 788 浏览 6 评论 0原文

我正在尝试打开新的 Calc 文档,但收到此错误:

System.IO.FileLoadException:混合模式程序集是针对运行时版本“v2.0.50727”构建的,如果没有其他配置,则无法在 4.0 运行时中加载信息。

CLI 参考包含在项目中。

    void OpenSpreadsheetClick(object sender, EventArgs e)
    {
        XComponentContext oStrap = uno.util.Bootstrap.bootstrap();
    //The next step is to use OpenOffice.org's service manager to create a desktop:
    XMultiServiceFactory oServMan = (XMultiServiceFactory) oStrap.getServiceManager();
    XComponentLoader oDesk = (XComponentLoader) oServMan.createInstance("com.sun.star.frame.Desktop" );
    string url = @"private:factory/scalc";
    PropertyValue[] propVals = new PropertyValue[0];
    XComponent oDoc = oDesk.loadComponentFromURL(url, "_blank", 0, propVals);
    }

如何修复它? Tnx寻求帮助:)

i'm trying to open new Calc document, and i'm getting this error:

System.IO.FileLoadException: Mixed mode assembly is built against version 'v2.0.50727' of the runtime and cannot be loaded in the 4.0 runtime without additional configuration information.

Cli references are inlcuded in project.

    void OpenSpreadsheetClick(object sender, EventArgs e)
    {
        XComponentContext oStrap = uno.util.Bootstrap.bootstrap();
    //The next step is to use OpenOffice.org's service manager to create a desktop:
    XMultiServiceFactory oServMan = (XMultiServiceFactory) oStrap.getServiceManager();
    XComponentLoader oDesk = (XComponentLoader) oServMan.createInstance("com.sun.star.frame.Desktop" );
    string url = @"private:factory/scalc";
    PropertyValue[] propVals = new PropertyValue[0];
    XComponent oDoc = oDesk.loadComponentFromURL(url, "_blank", 0, propVals);
    }

How to fix it?
Tnx for help :)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(2

你另情深 2024-11-05 13:48:49

在我看来,您需要对 app.config 进行此操作:

  <startup useLegacyV2RuntimeActivationPolicy="true"> 
    <supportedRuntime version="v4.0"/> 
  </startup>

查看此(有些相关)帖子以获取更多信息:http://blogs.msdn.com/b/jomo_fisher/archive/2009/11/ 17/f-scripting-net-4-0-and-mixed-mode-assemblies.aspx

编辑:如果您想了解有关 useLegacyV2RuntimeActivationPolicy 标志实际用途的更多信息,MSDN 上有一个页面: http://msdn.microsoft.com/en-us/library/bbx34a2h.aspx

It looks to me like you need to this to your app.config:

  <startup useLegacyV2RuntimeActivationPolicy="true"> 
    <supportedRuntime version="v4.0"/> 
  </startup>

Check out this (somewhat related) post for more info: http://blogs.msdn.com/b/jomo_fisher/archive/2009/11/17/f-scripting-net-4-0-and-mixed-mode-assemblies.aspx

Edit: If you want to find out more about what the useLegacyV2RuntimeActivationPolicy flag actually does, MSDN has a page on it here: http://msdn.microsoft.com/en-us/library/bbx34a2h.aspx

流星番茄 2024-11-05 13:48:49

将项目中的目标框架设置为 3.5 或 2.0。

Set your Target Framework in your project to 3.5 or 2.0.

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