> However, I may be passing in objects with no public or
> parameterless constructors, which seems to be a problem for
> "Activator.CreateInstance".

I'm afraid you're out of luck on this one.  You can get various constructors
from the type, but you'll have to know the types of the parameters to get
the right constructor.  The non-public constructors aren't necessarily a
problem when the correct binding flags are used.

> Alternatively, how do I cast my object ("obj")
> to its type, which right now seems a more likely solution?

You can't "cast" it per se if you don't know a specific type at compile
time.  Assuming you have a method name and the right parameters, just use
reflection -- obj.GetType().InvokeMember().

You can read messages from the DOTNET archive, unsubscribe from DOTNET, or
subscribe to other DevelopMentor lists at http://discuss.develop.com.

Reply via email to