invalid Cast

  • Thread starter Thread starter Steph
  • Start date Start date
S

Steph

Hello,

I'm using COM object in an application. One method used give an object wich
type is object.
When I use a GetType on its, I have "System.String[*]".

I try to convert it to loop on the array of string but I have an exception
(Invalid Cast Exception)

Here is my code :


myFormule = new Formule(); //Formule is a COM object
object myTest = myFormule.GetElement;
txtInfo.AppendText("object type: " + myTest.GetType()); //<-- here I have a
System.String[*]

//convert
string[] myTbl = (string[])myTest; // <-- here I have an exception


....

What can I do to loop and get values from myTest ?

thanks for your help

Steph
 
Steph,

That looks odd, to say the least. Can you provide the IDL or the type
library (or the DLL itself) which has the definition of the interface with
this method on it? Looking at that, it would be easier to determine what it
is actually returning. One would expect the type of what is returned to be
"String[]".
 
Back
Top