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