what is the difference between Activator.CreateInstance() and assembly.CreateInstance() ?
which one used when. please discuss with sample code and situation if possible. thanks
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Manish Kumar ChoudharyRank #339 · 7.4K reputationPosted Mar 2, 2015, 10:25 PM EST
Jignesh TrivediRank #16 · 50.3K reputationPosted Mar 2, 2015, 10:28 PM EST
Hi,
'Assembly.CreateInstance' is just a convenience method for instantiating an object to the certain type (by passing type in a string) within a particular assembly. It calls 'Activator.CreateInstance' under the hood.
with 'Activator.CreateInstance', you have to pass both argument (name of assembly and type) in constructors where as Assembly.CreateInstance takes one argument that is only type.
hope this will help you.