Re: Failed to load runtime error when setting RuntimeVersion="v4.0" in dna file

630 views
Skip to first unread message

Govert van Drimmelen

unread,
Jun 27, 2012, 7:46:58 AM6/27/12
to Excel-DNA
Hi Eric,

It might be that your assembly is a mixed assembly, with both native
and managed code, that targets .NET 2.0. (For example
System.Data.SQLite).

If so, .NET 4.0 won't load it be default. You can explicitly allow it
to load by adding something like this to your excel.exe.config file:

<startup useLegacyV2RuntimeActivationPolicy="true">
<supportedRuntime version="v4.0"
sku=".NETFramework,Version=v4.0,Profile=Client"/>
</startup>

I think "useLegacyV2RuntimeActivationPolicy" is the right term to
Google for in this context.

If your assembly is a regular managed assembly targeting .NET 2.0, I
don't expect any problems like this.

Regards,
Govert

On Jun 27, 1:29 pm, Eric <eric.decha...@gmail.com> wrote:
> Hi Govert,
>
> There is a new excel addin that was created by a different team that change
> excel.exe.config to supportedRuntime version="V4.0". The ExcelDNA addin
> that I created basically cannot run side by side with that add-in. What I
> did is change the .dna file for my addin to have "<DnaLibrary
> RuntimeVersion="v4.0">. The .Net error failure was now gone and I can load
> my dll however when I start to call the function which references another
> dll which is compiled using .net v2, I am getting this:
>
> *Could not load file or assembly 'xxx, Version=1.1.7.0, Culture=neutral,
> PublicKeyToken=20fc1ffb797ec904' or one of its dependencies. Failed to load
> the runtime. (Exception from HRESULT: 0x80131700)*
>
> Have you come across this error?
>
> Regards,
> Eric

Govert van Drimmelen

unread,
Jun 27, 2012, 8:47:40 AM6/27/12
to Excel-DNA
Hi Eric,

It's true that .NET 4 is generally backward-compatible. But it will,
by default, not load mixed .NET 2.0 assemblies.

I have an add-in that references System.Data.SQLite, and targets .NET
4, and needs that excel.exe.config for it to work. Without the
excel.exe.config change I get a different and clearer error though:
"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."

So probably you have some other issue. If you can simplify it to a
sample that you can post and I can reproduce I can look further. But
it's not something I've heard of before.

Regards,
Govert






On Jun 27, 2:35 pm, Eric <eric.decha...@gmail.com> wrote:
> Hi Govert,
>
> The excel.exe.config already have that settings so I had to change my dna
> file to have the RuntimeVersion attribute set to v4.0. Thats when the error
> started. You are right I have something like SQLite referenced in my DLL.
> v4.0 runtime should be backwards compatible right?
>
> Regards,
> Eric

Govert van Drimmelen

unread,
Jun 29, 2012, 11:07:54 AM6/29/12
to <exceldna@googlegroups.com>
Sure - you can get to me at gov...@icon.co.za

-Govert

On 29 Jun 2012, at 16:46, "Eric" <eric.d...@gmail.com> wrote:

Hi Govert,
 
Do you have a private email where I can send a sample project? I am afraid the solution I had didn't really solve the problem and I would like to ask your help because I am stuck.
 
Regards,
Eric
On Wednesday, 27 June 2012 17:58:03 UTC+1, Eric wrote:
Hi Govert,
 
I found the issue on my addin. A certain referenced DLL was failing to load at startup but after trying it to load again, it was loaded successfully. Seems a bit odd so I have to investigate further.
 
Anyways, thanks for being so helpful as always.
 
Regards,
Eric

--
You received this message because you are subscribed to the Google Groups "Excel-DNA" group.
To view this discussion on the web visit https://groups.google.com/d/msg/exceldna/-/H7Y69Ro53RcJ.
To post to this group, send email to exce...@googlegroups.com.
To unsubscribe from this group, send email to exceldna+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/exceldna?hl=en.
Reply all
Reply to author
Forward
0 new messages