InvalidCastException after upgrading to 1.9.0 from 1.8.0

23 views
Skip to first unread message

Chris Rodwell

unread,
May 13, 2026, 3:46:20 AM (4 days ago) May 13
to Excel-DNA

Hi,

I've recently inherited the maintenance of a project using Excel-DNA and have encountered an issue after upgrading to 1.9.0 that I'm stuck with.

When I execute the formulas in a spreadsheet which worked when using 1.8.0 I am encountering a crash with very limited information as shown below. I'm not sure what call is triggering this, attaching the debugger and breaking on exceptions isn't throwing any light on it.

System.InvalidCastException
  HResult=0x80004002
  Message=Unable to cast object of type 'System.String' to type 'System.Object[,]
  Source=<Cannot evaluate exception source>
  StackTrace: <Cannot evaluate the exception stack trace>

The call stack in the threads window is simply showing [Lightweight Function]

Does anyone have any advice they could give me on how to find out more or have any ideas of what might have changed between 1.8.0 and 1.9.0 that may have caused this?

Thanks

Govert van Drimmelen

unread,
May 13, 2026, 5:53:25 AM (4 days ago) May 13
to exce...@googlegroups.com

Hi Chris,

 

From your error it looks like a generated function in your add-in (where ‘generated’ might be your code doing it, or the Excel-DNA registration process) has an argument of type object[,] and is getting a string. It’s going to be hard to track down without figuring out what the function is, and what its signature is, and what else you have in the add-in build configuration.

 

With version 1.9 we did refactor some of the function registration code. In particular, where previously we had a separate ExcelDna.Registration helper package for advanced registration scenarios, that whole library is not incorporated into the main ExcelDna package. It should not break anything, but if you were using some kind of registration rewriting or augmentation of your functions, maybe that has gone wrong.

 

I suggest pinning down the function and arguments causing the error. Then if the issue is not obvious, make a small new add-in with the same signature function, and grow it to look like your code until you get the same error.

 

Once you have a reproducible error in an add-in project you can share, we’d be happy to sort it out – either suggesting the right approach, a workaround or an Excel-DNA fix.

 

-Govert

--
You received this message because you are subscribed to the Google Groups "Excel-DNA" group.
To unsubscribe from this group and stop receiving emails from it, send an email to exceldna+u...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/exceldna/d0b50f1a-73e0-42f9-a26e-0fb168a4aef9n%40googlegroups.com.

Chris Rodwell

unread,
May 13, 2026, 8:14:15 AM (4 days ago) May 13
to Excel-DNA
Thanks for the reply, I'll take your pointers and try to figure out where the problem could be.
Chris
Reply all
Reply to author
Forward
0 new messages