reflection: properties get System.ArgumentException

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
 
M

Mattias Sjögren

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top