RegisterMethods In EXCEL2003 error

Nov 5, 2012 at 10:41 AM


some code like this:

  MethodInfo[] ff = typeof(Gildata.EXCEL.FuncAnalyse.FuncDeclare).GetMethods(BindingFlags.Static | BindingFlags.Public);

            List<MethodInfo> ms = new List<MethodInfo>();
            for (int i = 0; i < ff.Length; i++)



It's do fine in Excel2007,but in Excel2003 it will be breakdown.

In fact ,I has alter Dna Source Code Order use more then 1000 funtions.

I declare more then 3000 functions in my Gildata.EXCEL.FuncAnalyse.FuncDeclare Class.

I think it's a bug in Excel4v method.



Nov 5, 2012 at 10:49 AM


You are right that Excel-DNA only supports 1000 functions per add-in, but you can make a custom version that supports more.

One reason your registration might fail is if your functions have too many parameters. Under Excel 2003, a function can have at most 30 arguments, while the limit is 255 arguments under Excel 2007.

If this is not the reason for the problem, please make a small example that shows the problem, and I will be happy to take a closer look.


Nov 5, 2012 at 11:33 AM


My Step One by One:

1.Use DNA Source Code 0.30


// EXPORT_COUNT defines the size of the thunk table.
// Must match the number of functions exported in ExcelDna.cpp and JmpExports64.asm
//#define EXPORT_COUNT 250
#define EXPORT_COUNT 6000


// Declare the functions -- NOTE: list here must go from 0 to EXPORT_COUNT-1




Rebuild Project ,I will get ExcelDna.xll (532 KB)

4.In My Vs2008,New Project as ClassLibery,Named DnaAddIn1 (.net 2.0)

5.Add New Class ,Named Test.cs

 public class Test

 private static int i;

        public static int jishuqi()
            return i;
        public static object jishuqi0()
        { return jishuqi(); }
        public static object jishuqi1()
        { return jishuqi(); }


 public static object jishuqi5000()
{ return jishuqi(); }




using System.Collections.Generic;
using ExcelDna.Integration;
using System.Reflection;
using System.Diagnostics;

   public class MyAddIn : IExcelAddIn

  public void AutoOpen()
                delegate(object x)
                    return null;

            MethodInfo[] ff = typeof(Test).GetMethods(BindingFlags.Static | BindingFlags.Public);

            List<MethodInfo> ms = new List<MethodInfo>();

            Stopwatch sp = new Stopwatch();

        public void AutoClose()


7.It's Run in Excel2007 will be ok,but Excel2003 fail


Nov 5, 2012 at 11:50 AM


Is everything fine under Excel 2003 if you register a smaller number, say only 200 methods, or 1200 methods. Do you know what the limit is?


Nov 5, 2012 at 10:53 PM


OK, I've tried to recreate the problem in Excel 2002 using your details, but everything works as expected. I don't have easy access to an Excel 2003 installation. I noted that I had to add an ExplicitExports="true" attribute in the .dna file to prevent the functions from being registered automatically.

Can you describe what happens in the following cases?

* When you just have the functions public, and not registered by calling ExcelIntegration.RegisterMethods. (Removing the ExplicitExports="true" in the .dna file.)

* When you have fewer functions, but register them with ExcelIntegration.RegisterMethods. (Adding the ExplicitExports="true" in the .dna file again.) Is there a cut-off number where it works or fails?

In what I've tried so far, I could not recreate a problem with either way of registering - I had the 5000 different functions available on the sheet with no problems.

If you're able to check again and still have the problem, I suggest you mail me the project so that I can have a closer look.



Nov 8, 2012 at 1:08 AM


I removed function attribute [ExcelFunction(Description="测试方法")] in my Function Declare,I find it Will be Load Ok in Excel2003.