0

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??

1
  • You need to be more clear about what you want and why CreateInstance() by itself isn't good enough. Commented Jun 30, 2010 at 23:56

1 Answer 1

2

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.