The second parameter should be used for indexers, which is not what you
want to use, a property that exposes an array of strings is a regular
property, not an indexer. You should not use this overload. What is the
COM signature of the property?
- Nicholas Paldino [.NET/C# MVP]
"Lars Nielsen" <lnNOpentiaSPAM.dk> wrote in message
news:uCXFOy8SDHA.2256TK2MSFTNGP11.phx.gbl...asked> Hi everybody,
> I've run into a problem when using the reflection assembly on COM objects
> and been browsing around the net for some while. Apparently a few hasgladly> the same question though no answer has ever occoured.
> This is what I'm trying to do:
> I wish to build a function that crawls any COM object (interop). I did
> shortly examine the serializer until I realized it's used for translation
> and not reflection). Until now it work's quite fine until it returns an
> array of strings:
> Public Function ReturnAbstractObject(ByVal o As Object) As XmlDoent
> Dim type As System.Type
> type = o.GetType()
> Dim propertyinfo As System.Reflection.PropertyInfo
> For Each propertyinfo In type.GetProperties()
> If propertyinfo.PropertyType.FullName = "System.String" Then
> Dim s As String
> s = propertyinfo.GetValue(o, Nothing).ToString() ' HERE IT GOES
> End If
> End Function
> When returning an array of strings (mind you, the
> propertyinfo.GetType().IsArray returns false) I get the following error:
> "Parameter count mismatch".
> It's the propertyinfo.GetValue(o, Nothing) that raises an error. I cannot
> find an example (that works) where the second parameter are used (this is
> the Index parameter). I may be wrong in the entire approch, and would> receive any help you guys may offer.
> In advance thanks,
> Lars Nielsen
> (If mailing the answer, - please remove the CAPS from the email)