Using legacy v2 runtime activation policy without modifying excel.exe.config

609 views
Skip to first unread message

Tony

unread,
Jul 22, 2013, 6:14:13 AM7/22/13
to exce...@googlegroups.com

Hello,

 

I'm trying to set up my ExcelDAN based add-in so that it will act according to the following config settings:

 

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

</configuration>

 

The trouble is I'm not permitted to modify the excel.exe.config on end user machines.

 

I did some investigation into the ExcelDNA C++ code and found a mechanism which appears to allow me to supply a config alongside my xll instead. The code (ExcelDnaLoader.cpp) is commented thus: "// Check if a .config file exists next to the .xll as MyAddIn.xll.config. Use it if it exists.".

 

But putting the config I want in this file does not work for me - the settings are ignored. I've stepped through the ExcelDNA code and am satisfied that the file is being read. Please can you advise me on this problem.

Govert van Drimmelen

unread,
Jul 22, 2013, 6:49:46 AM7/22/13
to exce...@googlegroups.com
Hi Tony,

The <add-in>.xll.config will be used as the configuration file for the AppDomain that Excel-DNA creates (you can check that this works with the sample in Distribution\Samples\Packing\PackConfig, just to be sure it is actually loaded for your add-in).
However, it might be that the setting you are trying to apply does not work when used from the AppDomain configuration file, but only if it is set in the process config file initially. Since it relates to the runtime, that's quite possible.

Can you also confirm that there is no existing excel.exe.config file which might interfere with what you are trying to set?

You might try this approach to setting it at runtime: http://reedcopsey.com/2011/09/15/setting-uselegacyv2runtimeactivationpolicy-at-runtime/ but I have not tried it myself, and am not sure whether it must be set before the runtime is loaded.

If you don't have the source to the mixed mode assembly, perhaps one can rewrite or edit the binary in some way that makes .NET 4 happy to load it.

Cheers,
Govert
Reply all
Reply to author
Forward
0 new messages