问题描述:

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 :)

网友答案:

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

网友答案:

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

相关阅读:
Top