ExcelDna packing tool Initialize Integration Failure

899 views
Skip to first unread message

Richard Todd

unread,
Jun 26, 2013, 9:58:20 AM6/26/13
to exce...@googlegroups.com
Hi all,

I've been using the packing tool for a while now and recently ported some F# code into a new project. When trying to pack this project using the ExcelDnaPack.exe tool I cannot seem to get the .XLL to load, I'm always getting the infamous Initialize Integration Failure message.

I have copy local on ExcelDna.Integration.dll set to False in visual studio and all my ExcelDna files are of the same version (0.30.22.1).

I've setup my folders with the .dna and .xll file in the root directory pointing to the path of my library. Here is a copy of my .dna file at present, I was playing around with referencing the ExcelDna.Integration.dll inside the .dna file and also FSharp.Core.dll but neither seem to have an impact. Of course I have the F# runtime and powerpack installed although my library has no dependency on the powerpack.

<DnaLibrary Name="Treaty" RuntimeVersion="v4.0">
<ExternalLibrary Path="EpLib4\bin\Release\EpLib4.dll" ExplicitExports="true" Pack="true" />
<ReferenceLibrary Path="EpLib4\bin\Release\zlib.net.dll" Pack="true" />
<ReferenceLibrary Path="EpLib4\bin\Release\MathNet.Numerics.dll" Pack="true" />
<ReferenceLibrary Path="EpLib4\bin\Release\FSharp.Core.dll" Pack="true" />
<ReferenceLibrary Path="ExcelDna.Integration.dll" Pack="true" />
</DnaLibrary>

The addin works perfectly without packing and the packing tool completes successfully.

Thanks
Rich

Govert van Drimmelen

unread,
Jun 26, 2013, 10:17:36 AM6/26/13
to exce...@googlegroups.com
Hi Richard,

I'm sorry this aspect is still so messy :-(

You need not pack the ExcelDna.Integration.dll yourself (just remove the corresponding Reference tag).
A mismatched version is still the most likely issue - copy fresh versions of the ExcelDna.xll, ExcelDna.Integration.dll and ExcelDnaPack.exe. The ExcelDnaPack.exe might be picking up the ExcelDna.Integration.dll next to it, which might be a different version.

Otherwise, I suggest you make a brand new F# Class Library, install the "Excel-DNA" NuGet package, copy the sample F# code from the displayed Readme.txt into your source file and compile.
That should make a packed .xll which works. From there, you can work your way back.

-Govert

Richard Todd

unread,
Jun 26, 2013, 2:26:32 PM6/26/13
to exce...@googlegroups.com
Hi Covert,
I can remove the exceldna.integration.DLL and it makes no difference. If I remove it from the folder where exceldnapack.exe is located then the pack tool does not work. Iv also tried the excel-dna nuget package and using this to pack the .xll also does not work.

In every combination above the normal unpacked version works fine in excel but the packed version returns the initialize integration error.

Richard Todd

unread,
Jun 26, 2013, 2:27:39 PM6/26/13
to exce...@googlegroups.com
I'm going to try on a clean machine and report back.

Govert van Drimmelen

unread,
Jun 26, 2013, 6:49:56 PM6/26/13
to exce...@googlegroups.com
Hi Richard,

If you attach a debugger to Excel, and then load your packed add-in, maybe something useful will pop out...

-Govert

Richard Todd

unread,
Jun 28, 2013, 11:58:38 AM6/28/13
to exce...@googlegroups.com
Hi Govert,
I discovered that if i took the packed XLL file and had all the DLLs in the same directory it worked. By process of elimination I've found that MathNet.Numerics.dll is the culprit. However, I'm neither sure how this is the case (since it's a compiled and standalone DLL) nor how to fix it, since my .dna file contains the correct reference.

Thanks

Govert van Drimmelen

unread,
Jun 28, 2013, 6:02:35 PM6/28/13
to exce...@googlegroups.com
Hi Richard,

Is MathNet.Numerics.dll a pure managed assembly, or is it a mixed assembly (with native code)?

The packing does not work with mixed assemblies, though I'm not sure that's the error I would expect.
(And I thought the regular MathNet.Numerics was managed code.)

Maybe they're doing something funny during the loading, like probing for other assemblies in some way, and because of the .NET load context into which it gets loaded from the packing something goes wrong.
Have you tried to run under a debugger? That might give a clue about the error.

Regards,
Govert

charl...@gmail.com

unread,
Jul 1, 2013, 1:18:36 AM7/1/13
to exce...@googlegroups.com
before run ExcelDnaPack.exe ,you should stop antivirus software,such as avira ...


在 2013年6月26日星期三UTC+8下午9时58分20秒,Richard Todd写道:

Richard Todd

unread,
Jul 2, 2013, 7:11:48 AM7/2/13
to exce...@googlegroups.com
Hi Govert, it's a pure managed assemby and debugging mode doesn't throw up anything at all.
I'm continuing to work on this issue to ensure a smooth install for users and will report back soon.

Thanks for your help
Rich

Mark Buchmoyer

unread,
Feb 7, 2014, 11:53:44 AM2/7/14
to exce...@googlegroups.com
Have you found any information for fixing this? I have run into a similar issue with fastJSON.dll

For now I am just distributing fastJSON.dll with my packed .xll file.

Govert van Drimmelen

unread,
Feb 9, 2014, 3:03:06 PM2/9/14
to exce...@googlegroups.com
Hi Mark (and Richard),

I've tested the Excel-DNA packing with both MathNet.Numerics and the fastJSON library, and everything seemed to work well.

My test was created as follows:
* New C# Class Library project (in VS 2012, targeting .NET 4)
* PM> Install-Package Excel-DNA
* PM> Install-Package MathNet.Numerics
* PM> Install-Package fastJSon

* Edit the .dna file as follows:
  <DnaLibrary Name="PackTest Add-In" RuntimeVersion="v4.0">
      <Reference Path="MathNet.Numerics.dll" Pack="true" />
      <Reference Path="fastJSON.dll" Pack="true" />
      <ExternalLibrary Path="PackTest.dll" LoadFromBytes="true" Pack="true" />
  </DnaLibrary>


* Edit the source code file as follows:
    using ExcelDna.Integration;
    using MathNet.Numerics.Distributions;
    using fastJSON;

    public static class MyFunctions
    {
        static Bernoulli _bernoulli;
        static MyFunctions()
        {
            _bernoulli = new Bernoulli(0.2);
        }

        [ExcelFunction(Description = "My first .NET function")]
        public static string HelloDna(string name)
        {
            return "Hello " + name;
        }

        public static object dnaMathNetSample()
        {
            return _bernoulli.Sample();
        }

        public static string dnaFastJSON()
        {
            var stuff = new MyStuff { AString = "Hello World!", ANumber = 42 };
            return JSON.Instance.ToJSON(stuff);
        }

        public struct MyStuff
        {
            public string AString;
            public double ANumber;
        }
    }

* Compile and run in Excel (mine is Excel 2013) - test the two functions
    =dnaFastJSON()
    =dnaMathNetSample()

* Back in VS, rebuild the Release version. Then go to the bin\Release output directory, and copy the packed file (PackTest-AddIn-packed.xll - 499 KB) to an empty directory.
Double-click to open in Excel and test the functions again - all worked fine for me.

So I can't reproduce the problems you report.
Please go through the steps above, and let me know whether if works the same way for you, or whether you see anything different.

Regards,
Govert

Mark Buchmoyer

unread,
Feb 12, 2014, 12:57:36 PM2/12/14
to exce...@googlegroups.com
Hey Govert,

I was originally building fastJSON from the source, I changed it to be using it from the Install-Package as you did (though this shouldn't really make a difference).

I also changed my <ReferenceReference Path="fastJSON.dll" Pack="true" /> to be your <Reference Path="fastJSON.dll" Pack="true" /> and it seems to be working now.

Thanks!
Reply all
Reply to author
Forward
0 new messages