tags:

views:

33

answers:

1

Hey all, I have a Loaded assembly and I need to define an instance from its type, I don't mean using the following:

object t = assembly.CreateInstance(...)

I need something like this:

typeof(assembly.CreateInstance(..).getType()) newObject

but this is wrong, how can I accomplish that?any fast suggestions??

+2  A: 

Do you mean declare newObject with the correct type at compile time so you can access methods on it? The compiler can't know what type that is, so that's not going to be possible.

If the object inherits from a standard interface (or shared interface in another assembly) you can cast it to that and run methods on the interface - otherwise you'll have to use reflection to access methods and properties.

Rup