.NET 4 addin using mixed mode assembly

Jan 7, 2015 at 7:37 AM
Hi,
I'm creating a .NET 4 addin which makes use of mixed mode assembly which is built for .NET 2.0. This mixed mode assembly fails to load in .NET 4 addin
I can see a similar threads relating this most relevant being https://exceldna.codeplex.com/discussions/253974.

So the solutions suggested in the above post are as follows which are not most ideal in our case
  1. Keeping an excel.exe.config in Office installation folder which sets useLegacyV2RuntimeActivationPolicy = true. This is not ideal because of two reasons. Cannot reach each and every user to put config file in this location. Also this breaks some of the existing addins which use .NET 2.0 as setting this attribute disables side-by-side execution of assemblies.
  2. Setting the attribute useLegacyV2RuntimeActivationPolicy to true programatically in addin as mentioned in this blog. http://reedcopsey.com/2011/09/15/setting-uselegacyv2runtimeactivationpolicy-at-runtime/ .This doesn't work as the runtime is loaded even before we make a call to set this attribute in our code. This means we are calling this too late.
3.Creating a xll.config. Excel-DNA does set up an AppDomain for each add-in, and will load as configuration file for the AppDomain a file <MyAddin>.xll.config. So adding this config also didn't work for me.

I know that the above mentioned discussion is quite old but any way to achieve this requirement is much appreciated.
Coordinator
Jan 7, 2015 at 8:27 AM
Hi,

I have no new information on this issue beyond the discussion you point to: https://exceldna.codeplex.com/discussions/253974
I really suggest you pursue getting the mixed mode assembly recompiled to target .NET 4.

-Govert
Jan 8, 2015 at 5:32 AM
Hi Govert,
Thanks, but unfortunately this is a third party assembly which we are using and they do not have any plan to upgrade it.
So I tried running the addin for runtimeVersion 2.0 with this setting
<DnaLibrary Name="Rbs.Gbm.Mdx.Realtime.AddIn Add-In" RuntimeVersion="v2.0">

But with this setting I'm not able to debug in Visual Studio as it is not even hitting the AutoOpen Method. I'm using VS 2013. If I revert the RuntimeVersion to 4.0 it allows me to debug the same.
May be I'm missing something. Any pointers?
Jan 8, 2015 at 5:51 AM
Hi,
I found the way of doing it from following post.
https://groups.google.com/forum/#!topic/exceldna/Z2esgPK7PxE
Thanks