在 C# 中创建新的 Calc 文档 (OpenOffice)
我正在尝试打开新的 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在我看来,您需要对 app.config 进行此操作:
查看此(有些相关)帖子以获取更多信息: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:
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
将项目中的目标框架设置为 3.5 或 2.0。
Set your Target Framework in your project to 3.5 or 2.0.