How to enable NetFx40_LegacySecurityPolicy in EXCEL DNA?

1,166 views
Skip to first unread message

candre...@yahoo.com

unread,
May 13, 2014, 5:27:48 AM5/13/14
to exce...@googlegroups.com

I have a simple excel DNA add in, created in version 0.32.

In my add-in I am dynamically loading another assembly that is found on a network drive.

When I load my excel DNA add-in into Excel and run my Excel-DNA function, I get the following error :

{"This method implicitly uses CAS policy, which has been obsoleted by the .NET Framework. In order to enable CAS policy for compatibility reasons, please use the NetFx40_LegacySecurityPolicy configuration switch. Please see http://go.microsoft.com/fwlink/?LinkID=155570 for more information."}

I have created a .config file for the ExcelDNA project in Visual Studio as shown below :

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <appSettings>
    <add key="DbPath" value="testString"/>
  </appSettings>
  <runtime>
    <NetFx40_LegacySecurityPolicy enabled="true" />
    <legacyCasPolicy enabled="true"/>
    <loadFromRemoteSources enabled="true"/>
  </runtime>
  <startup useLegacyV2RuntimeActivationPolicy="true">
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0" />
  </startup>
</configuration>

Any ideas on how I can resolve this issue?

Any help would be much appreciated.

Govert van Drimmelen

unread,
May 14, 2014, 5:58:22 AM5/14/14
to exce...@googlegroups.com
Hi,

There have been some previous questions on this. You might look at these discussions: https://groups.google.com/forum/#!searchin/exceldna/useLegacyV2RuntimeActivationPolicy

Basically it won't work to add the <runtime> and <startup> bits in the add-in's .config file - you either need to put it in excel.exe.config, or try another plan.

-Govert

Jiri Pik

unread,
May 14, 2014, 11:38:14 AM5/14/14
to exce...@googlegroups.com

I remember you configure .net for access of the network drives somehow – do not remember how.

 

An easy fix is to copy the assembly before loading to a local drive???

--
You received this message because you are subscribed to the Google Groups "Excel-DNA" group.
To unsubscribe from this group and stop receiving emails from it, send an email to exceldna+u...@googlegroups.com.
To post to this group, send email to exce...@googlegroups.com.
Visit this group at http://groups.google.com/group/exceldna.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages