So, since I've not used
TypeDescriptor
, I'm only guessing ... but I suspect that it won't tell you anything about
static
properties. From the little I've read, it exists to support people doing COM work, where parts of a type may not be statically known (i.e. known at compile time). But I'm not even sure of that.
The useful thing to infer from 'maybe its related to COM' is that a COM object / interface is related to an instance, so
public static anything ...
is unlikely to work because the
static
keyword makes the property (or field) a property of the type, not of an instance of the type.
- Do you need to use
TypeDescriptor.GetProperties(),
or can you use
Type.GetProperties()
? If you can use the latter you can discover both instance and static field and/or properties (and methods).
- If you must use
TypeDescriptor
, can you change your
Settings
object to be a singleton instance of a type, instead of being the static properties of a static type?
Re VB.Net vs C# - I doubt the problem is due to some intrinsice difference between VB.Net and C#, but to understanding how
TypeDesriptor
works ... I expect that when you get it to work you'' be able to make it work in both languages. Have you come across
Reflector[
^]? It's a free reverse-engineering tool for .Net assemblies. It generates C# (or VB.Net) source from the IL in an assembly. So, when you get your problem working in one language, you can use Reflector to see how it would look in the other.
In your 'What I should be doing' section, note that you're declaring
myprop
as an instance field, but
MyProp
as a static property: this will not compile because the static property doesn't know anything about the internals of instances.