9.21.2012

Assembly.CreateInstance() vs Activator.CreateInstance()

Difference between Assembly.CreateInstance() and Activator.CreateInstance()
S.No
Assembly.CreateInstance()
Activator.CreateInstance()
1
Namespace:
Derives from System.Reflection namespace.
Namespace:
Derives from System namespace.
2
Meaning:
Locates a type from this assembly and creates an instance of it using the system activator.In simple terms, Assembly.CreateInstance looks for a type in a particular assembly.

Meaning:
Creates an instance of the type whose name is specified in the specified remote domain, using the named assembly and default constructor.In simple terms, Activator.CreateInstance can create an object of any type.
3
Does it have overload method to create objects in other app domains, or on another server ?
Assembly.CreateInstance Method does not have overload method to create objects in other app domains, or on another server using Remoting as like Activator.CreateInstance Method.
Does it have overload method to create objects in other app domains, or on another server ?
Activator.CreateInstance has overloads that Assembly.CreateInstance Method does not have;for instance, it can create objects in other app domains, or on another server using Remoting.

References:





1 comment: