Importing Accord package to c# in visual studio when customizing grasshopper component


I am using c# to develop plugins for grasshopper.
I have successfully built some plugins.

However, when the matrix operations (inverse, etc.) were needed, I imported Accord package to deal with this problem.
I have tried runing the code in visual studio, and the code ran as expectation.

When I import the gha file and access the component in grasshopper, an error messgae came out, saying: "1. Solution exception: failed to load the file or assembly “Accord.Math, Version=, Culture=neutral, PublicKeyToken=fa1a88e29555ccf7” or one of its dependencies. The system could not find the specified file. "

And I have tried importing Accord.dll into c# component in GH, but unsure about which version of Accord.dll I should import, hence failed to make it.

The codes that I have tried in visual studio is:

// use Accord.Math
protected override void SolveInstance(IGH_DataAccess DA)
            int numRow = 5;
            int numCol = 5;
            double[,] A = Accord.Math.Matrix.Random(numRow, numCol, 10.0, 100.0);

            DA.SetDataList(0, A);
// use Accord.Math

Any hints would be greatly appreciated.

Big Thanks!

Hi @Robin_HE,

Did you copy the Accord.Math assembly into the the same folder as your Grasshopper .GHA?

– Dale

Hi Dale,

Thank you for your kind reply!

I have copied the Accord.Math.dll to the same folder.
However, it still doesn’t work.

Thank you again! @dale


Hi @Robin_HE,

Is the source to you Grasshopper project available somewhere?

Also, RhinoCommon does have a Matrix class…

– Dale

Hi Dale,

Thank you for your reply, I really appreciate it, hopefully we can work it out.

I have uploaded my project on Github, the link is:

And thank you again for telling me the Matrix class in RhinoCommon, but I might need to do some matrix inverse operation later, and I wish I could customize the component so as to speed up the solving procedure.

Big thanks! @dale