I'm currently in the unfortunate position of having to call a VBA macro from C#, via the COM Interop. The macro returns an array of strings and looks something like:
Public Function Foo() As String()
which I'm then trying to cast to an array of strings in C# like this:
var result = (string[])xlApp.Run("Foo", ... missing args ...)
which then results in the runtime error:
Unable to cast object of type 'System.String[*]' to type 'System.String[]'.
Does anyone know what a String[*] is, and do you have any idea of how to cast it to a C# string[]? This cast works in a simple test case I've created. The only difference I can see, is that in the simple case, my array in VBA is of type string(0 to 5) whereas in the more complex case, it's of type string(1 to 6). Could this be the reason and if so, my VBA is rather rusty - how do I fix it?
Many thanks,
Jon