reflection: properties get System.ArgumentException

  • Thread starter Thread starter Dan
  • Start date Start date
D

Dan

hi ng,

i want to invoke a dynamically created object with reflection, like:


public static object createInstance(string classname, string assemblyName)
{
object obj=null;
Assembly assembly= Assembly.LoadFile(assemblyName);
obj=assembly.CreateInstance(classname);
return obj;
}

what happens is that all the properties of the object show a

<error: an exception of type: {System.ArgumentException} occurred> string

in the debugger.
whereas the according private fields have the correct null value.
i thought that a property is like a pointer on the field that it is
wrapping.
what is wrong there?
i don't get it.

thank you very much for your help!

dan
 
i thought that a property is like a pointer on the field that it is
wrapping.

No, a property is just a grouping of accessor methods.

I wouldn't worry too much about what the debugger is showing as long
as your code works as expected.



Mattias
 
Back
Top