ExcelDNA .Net error

360 views
Skip to first unread message

Eric de Chavez

unread,
Jul 8, 2011, 6:42:09 AM7/8/11
to Excel-DNA
Hi,

One of the users of our application that uses ExcelDNA encounters this
error:

"The Excel add-in requiers the Microsoft .NET Framework 2.0, 3.0, 3.5.

A problem occured while attempting to load the .NET runtime:
The .Net runtim interface could not be retrieved.

This is an unexpected error.Please report this error to the add-in
developer.

The add-in is built with Excel-Dna and is being loaded from the
following location: ..... .xll"

We have re-installed .NET to the user's machine but still encounter
the same error. Could you help me with this?

Regards,
Eric

Govert van Drimmelen

unread,
Jul 8, 2011, 9:10:08 AM7/8/11
to Excel-DNA
Hi Eric,

I've not had this problem reported before.
This is the line of code in the unmanaged loader that fails:
hr = pRuntimeInfo->GetInterface(CLSID_CorRuntimeHost,
IID_ICorRuntimeHost, (LPVOID*)ppHost);

What version of .NET is your add-in targeting?

My first suggestion would be to check that .NET runs fine - just run
some .NET app that would be using the same .NET version as your add-
in.

It looks like .NET 4 is installed on that machine, so the .NET 4
runtime loading interfaces would be used, even if you are
targeting .NET 2.0 with your add-in. Perhaps you can reinstall .NET 4
on that machine as well as whatever .NET version you are targeting (if
you haven't done so already).

Also try the simplest Excel-DNA add-in - just the ExcelDna.xll and
ExcelDna.dna from the Distribution.

One case that might be usual would be if the user had some beta
version of .NET 4. Maybe you can check what's installed in Add/Remove
Programs list, or by listing the directories in C:\Windows
\Microsoft.NET\Framework\.

Also check the Event Log for anything suspicious.
Anti-virus...? (Though this would be a really funny error to get.)
(Grasping at straws now....)

Regards,
Govert

Govert van Drimmelen

unread,
Jul 11, 2011, 1:59:51 PM7/11/11
to Excel-DNA
Hi Eric,

I can suggest you check whether the simplest add-in from the
Distribution works.
You might need to re-install .NET 4, even though your add-in
targets .NET 2.0, since it looks like the problem is found in
interaction with the .NET 4 runtime host loader (which is used even to
load .NET 2.0, if it is installed on the machine.

Regards,
Govert

Eric de Chavez

unread,
Jul 13, 2011, 11:10:10 AM7/13/11
to Excel-DNA
Hi Govert,

Thanks for the replies. I already did what you suggested. I created a
simple addin with target framework .NET 3.5 and target framework 2.0
but it is still giving the same error.

I also created a simple exe that was built on .Net 2.0 and it ran
successfully, so I don't know if it is the .net 4 runtime loader that
is causing the issue.

Thanks for your suggestions though, it guided me on what should i
do... keep it coming please because I really don't have an idea on
whats causing this particular user to have the error.

Regards,
Eric
> > > Eric- Hide quoted text -
>
> - Show quoted text -

Govert van Drimmelen

unread,
Jul 13, 2011, 12:33:42 PM7/13/11
to Excel-DNA
Hi Eric,

OK, we might have to be a bit more methodical.

* Does it work if your add-in targets .NET 4 (RuntimeVersion="v4.0")?
* Have you also re-installed .NET 4?
* Have you disabled or removed all other Excel add-ins and restarted
Excel?
* Have you disabled any anti-virus software (just to test) and tried
to load the add-in?
* Have you checked the event log for anything suspicious?
* Could you post a list of all the subdirectories under C:\Windows
\Microsoft.NET\Framwork ?

If all of this fails to shed any light, we can make a version that
gives a bit more information about the exact error.

-Govert

Eric de Chavez

unread,
Jul 14, 2011, 5:53:30 AM7/14/11
to Excel-DNA
Thanks Govert. I will try this and update this post once done.
> > > - Show quoted text -- Hide quoted text -

Eric de Chavez

unread,
Jul 15, 2011, 5:07:47 AM7/15/11
to Excel-DNA
Hi Govert,

I tried creating a simple XLL based on the version .29 ExcelDNA and
set the runtime version = v.4.0 and it ran successfully. Looks like
the user's machine has a corrupted v2.0.50727 .NET. I can have my
program use the .29 version and set runtime to v4.0 but I have other
dll that are built on v2 so when I ran my addin it gives me an error:


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.

Does the .dna file support multiple runtimes in the Runtimeversion
attribute? If not, is it possible to do this in ExcelDna?

Thanks very much,
Eric

Govert van Drimmelen

unread,
Jul 15, 2011, 5:28:50 AM7/15/11
to Excel-DNA
Hi Eric,

OK.
I suggest you install .NET 3.5 SP1 on that machine to check if that
fixes whatever makes .NET 2.0 unhappy.
Maybe run the bootstrapper from here: http://www.microsoft.com/download/en/details.aspx?id=22.


Otherwise you can try to get it all working on .NET 4.
Pure managed assemblies built for .NET 2 will run fine in .NET 4.
But mixed-mode assemblies (with some native code inside) will only
load on the different runtime only if a special flag is set in the
config file.

I don't think you can set this flag in a <AddIn>.xll.config file. You
will need to make a file called
Excel.exe.config containing something like:

<configuration>
<startup useLegacyV2RuntimeActivationPolicy="true">
</configuration>

Copy the Excel.exe.config next to Excel.exe in c:\Program Files
\Microsoft Office\OfficeXX\
You can read more by Googling "useLegacyV2RuntimeActivationPolicy".

With Excel-DNA, the .dna file that corresponds to a .xll file defines
one add-in. That add-in loads one version of the runtime and creates a
single AppDomain where everything is loaded.
You can make multiple add-ins (.xll + .dna files) and these can target
different versions of the runtime, loaded into the same Excel instance
concurrently.

Best would still be to fix the .NET 2.0 runtime.
Am I right in understanding that the add-in runs fine in many places
and gives a problem only on this one PC?

Regards,
Govert

Govert van Drimmelen

unread,
Jul 15, 2011, 5:30:17 AM7/15/11
to Excel-DNA
Oh - and it's probably worth installing http://support.microsoft.com/kb/959209
after refreshing the .NET installation.

-G

Eric de Chavez

unread,
Jul 15, 2011, 10:07:06 AM7/15/11
to Excel-DNA
Thanks Govert,

I will get the .NET framework v2 re-installed on this machine. Yes,
the Add-in works perfectly except for this one machine. I will update
you if that resolved the issue.

Regards,
Eric

On Jul 15, 10:30 am, Govert van Drimmelen <gov...@icon.co.za> wrote:
> Oh - and it's probably worth installinghttp://support.microsoft.com/kb/959209

Eric de Chavez

unread,
Jul 20, 2011, 10:52:35 AM7/20/11
to Excel-DNA
Hi Govert,

Re-installing .NET Framework solved the problem. Thanks very much for
all your suggestions.

Regards,
Eric
Reply all
Reply to author
Forward
0 new messages