Reasons why ExcelDnaLoader might be throwing null object reference errors on registration all of a sudden?

78 views
Skip to first unread message

Bob Calco

unread,
Nov 30, 2021, 8:31:53 AM11/30/21
to Excel-DNA
Hi Govert,

I have been happily implementing my UDFs, but suddenly on running in Excel the ExcelDnaLoader is blowing up at registration time. I have put breakpoints on all my UDFs to see if they're getting called (for some reason) but the breakpoints are never hit.

This is what's blowing up:

    member this.AutoOpen () =
      // The overload selection and delegate conversions performed by F# are not intuitive.
      let paramConvertConfig = 
        ParameterConversionConfiguration()
          .AddParameterConversion( 
            Func<Type, ExcelParameterRegistration, LambdaExpression>
              (FsParameterConversions.FsOptionalParameterConversion),
            null)

      ExcelRegistration.GetExcelFunctions ()
      |> fun fns -> ParameterConversionRegistration.ProcessParameterConversions (fns, paramConvertConfig)
      |> FsAsyncRegistration.ProcessFsAsyncRegistrations
      |> AsyncRegistration.ProcessAsyncRegistrations
      |> MapArrayFunctionRegistration.ProcessMapArrayFunctions
      |> ParamsRegistration.ProcessParamsRegistrations
      |> ExcelRegistration.RegisterFunctions

Specifically, it's blowing up at the last line, ExcelRegistration.RegisterFunctions.

What can I do to troubleshoot this? This new behavior was unexpected.

Sincerely,

Bob

Bob Calco

unread,
Nov 30, 2021, 8:34:48 AM11/30/21
to Excel-DNA
Sorry, I meant also to include a copy of the exception:

System.NullReferenceException
  HResult=0x80004003
  Message=Object reference not set to an instance of an object.
  Source=ExcelDna.Loader
  StackTrace:
   at ExcelDna.Loader.XlMethodInfo.ConvertToXlMethodInfos(List`1 methods, List`1 targets, List`1 lambdaExpressions, List`1 methodAttributes, List`1 argumentAttributes)
   at ExcelDna.Loader.IntegrationHost.RegisterLambdaExpressionsWithAttributes(List`1 lambdaExpressions, List`1 functionAttributes, List`1 argumentAttributes)
   at ExcelDna.Registration.ExcelRegistration.RegisterFunctions(IEnumerable`1 registrationEntries)
   at VisualScheme.AddIn.AddInFunctions.ExcelDna.Integration.IExcelAddIn.AutoOpen() in <path-to-my-add-in>\AddInFunctions.fs:line 36

Any suggestions how to sleuth this appreciated.

Bob Calco

unread,
Nov 30, 2021, 8:54:46 AM11/30/21
to Excel-DNA
OK, it seems be one of the libraries I'm calling, which has exhibited this behavior before, but I thought was fixed. I am instantiating a singleton object that uses it, and it's throwing the error. When I comment out the code in my UDF that makes a reference to the singleton object, then it loads as it's supposed to. So, I have to take this up with someone else. :)

Greg Stevenson

unread,
Oct 12, 2022, 9:09:40 AM10/12/22
to Excel-DNA
Hi there, 
We are running into a similar issue as above. I see no other responses to these posts. Could you share what you did to fix this problem? Thanks!

Reply all
Reply to author
Forward
0 new messages