Issue "Could not load file or assembly 'ExcelDna.Loader'" reproduced on two x64 machines

2,354 views
Skip to first unread message

Alexander L

unread,
Nov 3, 2013, 10:36:08 AM11/3/13
to exce...@googlegroups.com
I have two add-ins
1. Simple test addin created with ExcelDna 0.30.3, has only one function Test() returning 'test' and used for 64-bit excel (TestAddin)
2. Large add-in which is currently uses ExcelDna 0.30.3, but used to use 0.29.0.12, initially used for 32-bit excel (RealAddin)

I have two machines
1. Win8 x64 /w Excel 2013 x64 (M1)
2. Win7 x64 /w Excel 2010 x32 (M2)

I started with the following two working:
TestAddin running on M1 (with x64 excel 2013)
RealAddin running on M2 (with x32 excel 2010)

My next step was to get my RealAddin to work on x64 Excel.

To do this, I tried to compile RealAddin on M1 machine (x64 Excel), and adjusted post-build events as described here

After I launched RealAddin in VS debug, I got error "Could not load file or assembly 'ExcelDna.Loader' or one of its dependencies. The system cannot find the file specified."

After this, TestAddin stopped compiling even though nothing in that project changed.

To replicate this behavior on M2, I did the following:
1. Removed Excel 2010 x32 (since it is not possible to have x32 and x64 excel on the same machine)
2. Installed Excel 2013 x64
3. Compiled and ran TestAddin and it worked fine.
4. Adjusted RealAddin's post-build events to make a 64-bit xll per google topic above.
5. Tried to compile it and got "Could not load file or assembly 'ExcelDna.Loader' or one of its dependencies. The system cannot find the file specified."
6. Tried to compile TestAddin again - and got the same error.

I have tried the following to get TestAddin to compile again:
1. Uninstalled and removed all pre-saved ExcelDna packages, and let NuGet auto-download them on the first build
2. Cleared VisualStudio NuGet cache
3. Repaired and reinstalled .NET Framework
4. Reinstalled Excel 2013 x64
5. Uninstalled Excel 2013 x64 and installed Excel 2010 x32
6. Ran *.xll without Visual Studio debug
7. Reverted all changes in RealAddin.
8. Got latest source code from codeplex, built ExcelDna.Loader.dll (with manually changed version to match ExcelDna.Integration from nuget) and placed it to output dir.

I still got the same "Could not load file or assembly 'ExcelDna.Loader' or one of its dependencies. The system cannot find the file specified." in TestAddin.

The versions of RealAddin (and TestAddin) that were built before I compiled RealAddin with 64-bit changes run fine, so I assume this is something related to the build process and not Excel.  But I have no idea what changed.

Would appreciate any help,

Thanks,
Alex

Govert van Drimmelen

unread,
Nov 3, 2013, 11:39:19 AM11/3/13
to exce...@googlegroups.com
Hi Alex,

This sounds strange and frustrating.

Where do you see the message "Could not load file or assembly 'ExcelDna.Loader' or one of its dependencies."? 
Is this an error that appears when you are compiling, or when running?
Could you add an screen snip  of where you see the message?

(When loading Excel-DNA, there is an exception at runtime on the first attempt to load ExcelDna.Loader. The first-chance exception is correctly handled by the Excel-DNA native code loader and the assembly is loaded from resources instead. So such a message might be a false alarm, depending on your excetpion settings.)

If you download the Excel-DNA v 0.30 distribution from CodePlex, unzip somewhere and just double-click the Distribution\ExcelDna64.xll file, does that add-in load and does the =AddThem(2,3) function work?

It sounds like machine M2 now has 32-bit Excel on.
If you make a new C# "Class Library" project, then "Install-Package Excel-DNA", and copy to sample code from the readme.txt file, you should have a working add-in. 
Press F5 - What happens?

Regards,
Govert

Alexander L

unread,
Nov 4, 2013, 3:56:43 PM11/4/13
to exce...@googlegroups.com
Hi Govert,
Thank you for quick answer, and sorry for being frustrating.
You were completely right about false alarm.
I forgot to mention, that exceptions were handled.
Turns out that only thing which confuses me was that excel didn't open an empty workbook like before, but this was the only setting corrupted.
So, TestAddin as well as Distribution\ExcelDna64.xll file loads and adds necessary function.

But the RealAddin - fails when I build it for x64

In debug mode, after I click "enable this addin..." in excel, I have the following in my output window:
EXCEL.EXE' (Managed (v4.0.30319)): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_64\mscorlib\v4.0_4.0.0.0__b77a5c561934e089\mscorlib.dll', Symbols loaded.
A first chance exception of type 'System.IO.FileNotFoundException' occurred in mscorlib.dll
'EXCEL.EXE' (Managed (v4.0.30319)): Loaded 'ExcelDna.Loader'
A first chance exception of type 'System.IO.FileNotFoundException' occurred in mscorlib.dll
'EXCEL.EXE' (Managed (v4.0.30319)): Loaded 'ExcelDna.Loader'
'EXCEL.EXE' (Managed (v4.0.30319)): Loaded 'D:\output\AddIn\ExcelDna.Integration.dll'
A first chance exception of type 'System.NullReferenceException' occurred in ExcelDna.Loader

And stack trace for that is only
"at ExcelDna.Loader.XlAddIn.LoadIntegration()"

This exception is also handled, but AddIn is not loaded, I don't have neither functions, nor my additional tab on the ribbon.
Is there any way to get more detailed information about this NullReferenceException?
Or, since it is handled, it also should not affect addin loading?

Thanks,
Alex

воскресенье, 3 ноября 2013 г., 18:39:19 UTC+2 пользователь Govert van Drimmelen написал:

Govert van Drimmelen

unread,
Nov 4, 2013, 4:47:59 PM11/4/13
to exce...@googlegroups.com
Hi Alex,

Is your library compiled targeting AnyCPU or x64?
What references do you have?
Could it be that you are referencing some mixed code assembly?

Regards,
Govert

Alexander L

unread,
Nov 4, 2013, 5:14:39 PM11/4/13
to exce...@googlegroups.com
Hi Govert,

It's AnyCPU
Below are my references (except System.*)


понедельник, 4 ноября 2013 г., 23:47:59 UTC+2 пользователь Govert van Drimmelen написал:

Govert van Drimmelen

unread,
Nov 4, 2013, 5:24:28 PM11/4/13
to exce...@googlegroups.com
Hi Alex,

The ExcelDna.Contrib is quite old (what do you use from there?).
I think Ionic.Zip is pure managed code. NLog too?

Otherwise I'm not sure  - you might have to start with the working TestAddIn, and systematically migrate everything in so that you can see when it breaks.

-Govert

Alexander L

unread,
Nov 4, 2013, 6:39:51 PM11/4/13
to exce...@googlegroups.com
Thanks for the hint, Govert. I guess I'll start with references only.

вторник, 5 ноября 2013 г., 0:24:28 UTC+2 пользователь Govert van Drimmelen написал:

ohmyg...@gmail.com

unread,
Sep 19, 2018, 9:47:30 AM9/19/18
to Excel-DNA
Hi Govert when i try to resolve
IExcelAddIn I use nuggets to include your exceldna.integration

But this is v.0.35.4-beta4

When I have plugged in the addin and then restart Excel

I get an exception

Could not load file of assembly 'ExcelDna.loader' or one of its dependencies.

When I add the addin after this popup again
The addin works it executes the
AutoOpen method of the addin like it should be .

I close the Excel I have the same load exception
Need to add the addin again and then ok

And do one ...

Any ideas ??

Govert van Drimmelen

unread,
Sep 19, 2018, 9:57:11 AM9/19/18
to exce...@googlegroups.com
I'm not sure exactly how you've set up your project. Maybe something is wrong there.
Also, I've not tested the new version much with 64-bit, though I don't think that's the problem.

You can't just install ExcelDna.Integration and use the add-in from there.
You need to install ExcelDna.AddIn, which should set everything up automatically.

You should make a new project following the Getting Started instructions from here: https://excel-dna.net/
Does that work on your machine?

-Govert

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Excel-DNA: Free and easy .NET for Excel
Develop Excel Conference - London, 18 October 2018
https://developexcel.wordpress.com/
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
--
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 https://groups.google.com/group/exceldna.
For more options, visit https://groups.google.com/d/optout.

ohmyg...@gmail.com

unread,
Sep 19, 2018, 10:26:51 AM9/19/18
to Excel-DNA
I have the following nuggets
Excel DNA addin 0.34.6
Integration 0.34.6
Interop 14.0.1
Excel-DNA.Lib 0.34.6
Registration 0.34.7
Registration.visualbadic 0.34.7
Excel-DNA-Wrapper 0.32.0.2

Microsoft.offuce.interop.excel 15....
Microsoft.Vusualbasic 10.3.0

Framework .net 4.6.1

Exit code 1 from Exceldnapack.exe

ohmyg...@gmail.com

unread,
Sep 20, 2018, 2:59:08 AM9/20/18
to Excel-DNA
Yes I followed that path
But then was facing another problem
I could not assign values to ranges

The Excel dom accessibility is not supported was indicated by Add-In Express support and they advised me to do a comaddin

In my quest I encountered the IExcelAddIn interface supported by your nuggets

I cleaned up the package s but I am forced to use a beta version

And the class is able to access the range

I am here with a little conflict

I will try further today
I apparently need your beta nuggets

ohmyg...@gmail.com

unread,
Sep 20, 2018, 5:10:57 AM9/20/18
to Excel-DNA
The moment I open an Excel sheet
I have the following in the implementation in class MainAddin which implements interface IExcelAddIn

In AutoOpen()

Try
{
ObjApp=System.Runtime.InteropServices.Marshal.GetActiveObject
("Excel.Application") as Microsoft.Office.Interop.Excel.Application;
}
catch (Exception ex)
{
Message of.Show ...
}

I could try to put this code somewhere else ( another class ) until the moment
The worksheet has loaded and all its addins

And then execute this code at a strategic moment.

But I am not proficient enough to determine the best strategic moment to call this
THIS COULD BE
+++++++++++++
After the work book has been loaded
and all its addins But what event is that

An event that gives me the possibility to give me the application object

The rest is like you described in the document I have an xll and so an excel-dna addin
If I exclude this MainAddin class no problem ( obvious he is not looking for its own Excel application instance )

Hope you can help
Thanks

ohmyg...@gmail.com

unread,
Sep 20, 2018, 8:12:08 AM9/20/18
to Excel-DNA
I sent my project to GitHub
Excel-dna #75

Govert van Drimmelen

unread,
Sep 21, 2018, 3:12:30 AM9/21/18
to exce...@googlegroups.com
Using Marshal.GetActiveObject in your Excel-DNA add-in will make a mess.

Do you have a basic Excel-DNA add-in with a simple function working?
What are you then trying to do which is not working?

-Govert

________________________________________
From: exce...@googlegroups.com [exce...@googlegroups.com] on behalf of ohmyg...@gmail.com [ohmyg...@gmail.com]
Sent: 20 September 2018 11:10 AM
To: Excel-DNA
Subject: RE: [ExcelDna] Re: Issue "Could not load file or assembly 'ExcelDna.Loader'" reproduced on two x64 machines

In AutoOpen()

--

ohmyg...@gmail.com

unread,
Sep 24, 2018, 2:58:43 AM9/24/18
to Excel-DNA
Yes u have an example where I only use Excel-dna.
I where I can show what goes wrong
But how do I send you the solution
And the screenshots ?

ohmyg...@gmail.com

unread,
Sep 24, 2018, 3:01:02 AM9/24/18
to Excel-DNA
Sorry yes I have an example how do I get it to you ?
I have to work from my GSM
The blog is blocked by security

ohmyg...@gmail.com

unread,
Sep 24, 2018, 3:27:24 AM9/24/18
to Excel-DNA
Assigning a value gives an exception
For example
FirstCellRange="first range value"

Gives an exception

My purpose was to read from db , populate a cell range and create a validating combobox
Which seems not possible in excel-dna.

Regards

How do I get the code to you

Govert van Drimmelen

unread,
Sep 24, 2018, 8:59:45 AM9/24/18
to exce...@googlegroups.com
Excel does not normally support setting cell values from a UDF.
(This is to protect the sheet calculation integrity.)

For your scenario you would make a ribbon button or macro with shortcut key, and in there you can access to the full object model like in VBA. Use "ExcelDnaUtil.Application" to get hold of the root Application object.

-Govert

________________________________________
From: exce...@googlegroups.com [exce...@googlegroups.com] on behalf of ohmyg...@gmail.com [ohmyg...@gmail.com]

Sent: 24 September 2018 09:27 AM


To: Excel-DNA
Subject: RE: [ExcelDna] Re: Issue "Could not load file or assembly 'ExcelDna.Loader'" reproduced on two x64 machines

Assigning a value gives an exception

Gives an exception

Regards

--

Oh My God Oui

unread,
Sep 24, 2018, 10:06:11 AM9/24/18
to exce...@googlegroups.com
Ok thanks Govert

I will have a look at that 
Reply all
Reply to author
Forward
0 new messages