L
Lars Nielsen
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 has asked
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 XmlDocument
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
WRONG
End If
Next
:
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 gladly
receive any help you guys may offer.
In advance thanks,
Lars Nielsen
(e-mail address removed)
(If mailing the answer, - please remove the CAPS from the email)
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 has asked
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 XmlDocument
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
WRONG
End If
Next
:
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 gladly
receive any help you guys may offer.
In advance thanks,
Lars Nielsen
(e-mail address removed)
(If mailing the answer, - please remove the CAPS from the email)