A
Angelos Karantzalis
Hi y'all ...
I've just come across a rather weird problem.
i'm using the following code to get the names of the public properties of an
object:
public static string[] GetPropertyNames(object instance){
Type objType = instance.GetType();
PropertyInfo[] props = objType.GetProperties();
string[] strPropNames = new string[props.Length];
for(int i=0; i<props.Length; i++)
strPropNames = props.Name;
return strPropNames;
}
... that worked fine on framework class instances, and it also worked on my
own classes, even after I'd loaded an assembly dynamically from the file
system.
HOWEVER, now I'm using it to query an instance of a class returned from a
web service. I know that the class has several public properties [duh! I
wrote it !], but the code above doesn't work. It returns a zero-length
string array. A similar function that returns the method names, returns the
classic "object" methods, which is again not correct [quering for the method
names should also return the "get_<public property name>" methods for each
public property ... ]
Does anyone have a clue on what might be happening here ??? Did i mention
that querying the Type name of the instance returns the class name in the
namespace created by VS for the Web Reference ? [ as it should ]
Cheers,
Angel
O:]
I've just come across a rather weird problem.
i'm using the following code to get the names of the public properties of an
object:
public static string[] GetPropertyNames(object instance){
Type objType = instance.GetType();
PropertyInfo[] props = objType.GetProperties();
string[] strPropNames = new string[props.Length];
for(int i=0; i<props.Length; i++)
strPropNames = props.Name;
return strPropNames;
}
... that worked fine on framework class instances, and it also worked on my
own classes, even after I'd loaded an assembly dynamically from the file
system.
HOWEVER, now I'm using it to query an instance of a class returned from a
web service. I know that the class has several public properties [duh! I
wrote it !], but the code above doesn't work. It returns a zero-length
string array. A similar function that returns the method names, returns the
classic "object" methods, which is again not correct [quering for the method
names should also return the "get_<public property name>" methods for each
public property ... ]
Does anyone have a clue on what might be happening here ??? Did i mention
that querying the Type name of the instance returns the class name in the
namespace created by VS for the Web Reference ? [ as it should ]
Cheers,
Angel
O:]