NGWS SDK Documentation  

This is preliminary documentation and subject to change.
To comment on this topic, please send us email at ngwssdk@microsoft.com. Thanks!

Activator.CreateInstance

The CreateInstance methods create an instance of the object with full binding support. Variations of the method will allow the activation call site attributes to be passed as an array of objects. The activation can potentially occur remotely. Once the object has been activated remotely the CreateInstance will return.

Overload List

Creates an instance using the name of the type and the assembly where it exists. This allows types to be created remotely without having to load the type locally. These will return an ObjectHandle that needs to be unwrapped in order to access the real object.

[Visual Basic] Overloads Public Shared Function CreateInstance(String, String) As ObjectHandle
[C#] public static ObjectHandle CreateInstance(String, String);
[C++] public: static ObjectHandle* CreateInstance(String*, String*);
[JScript] public static function CreateInstance(String, String) : ObjectHandle;

Calling this method is equivalent to calling the constructor on the class with no arguments (the default constructor). For example if the Type object represents the String class, calling CreateInstance() is equivalent to invoking the default String constructor. This would fail, however (a MissingMethodException would be thrown) because String does not have a default constructor.

Note: Access restrictions are ignored for fully trusted code. That is, private constructors, methods, fields, and properties can be accessed and invoked via Reflection whenever the code is fully trusted.

[Visual Basic] Overloads Public Shared Function CreateInstance(Type) As Object
[C#] public static object CreateInstance(Type);
[C++] public: static Object* CreateInstance(Type*);
[JScript] public static function CreateInstance(Type) : Object;

Creates an instance of a specified type using the specified constructor. The constructor that is to be invoked must be accessible and provide the most specific match with the specified argument list, under the constraints of the default binder.

[Visual Basic] Overloads Public Shared Function CreateInstance(Type, Object(), Object()) As Object
[C#] public static object CreateInstance(Type, Object[], Object[]);
[C++] public: static Object* CreateInstance(Type*, Object[], Object[]);
[JScript] public static function CreateInstance(Type, Object[], Object[]) : Object;

Creates an instance using the name of the type and the assembly where it exists. This allows types to be created remotely without having to load the type locally. These will return an ObjectHandle that needs to be unwrapped in order to access the real object.

[Visual Basic] Overloads Public Shared Function CreateInstance(String, String, Boolean, BindingFlags, Binder, Object(), CultureInfo, Boolean, Object(), Evidence) As ObjectHandle
[C#] public static ObjectHandle CreateInstance(String, String, bool, BindingFlags, Binder, Object[], CultureInfo, bool, Object[], Evidence);
[C++] public: static ObjectHandle* CreateInstance(String*, String*, bool, BindingFlags, Binder, Object[], CultureInfo, bool, Object[], Evidence);
[JScript] public static function CreateInstance(String, String, Boolean, BindingFlags, Binder, Object[], CultureInfo, Boolean, Object[], Evidence) : ObjectHandle;

Creates an instance using the name of the type and the assembly where it exists. This allows types to be created remotely without having to load the type locally. These will return an ObjectHandle that needs to be unwrapped in order to access the real object.

[Visual Basic] Overloads Public Shared Function CreateInstance(String, String, Boolean, Object()) As ObjectHandle
[C#] public static ObjectHandle CreateInstance(String, String, bool, Object[]);
[C++] public: static ObjectHandle* CreateInstance(String*, String*, bool, Object[]);
[JScript] public static function CreateInstance(String, String, Boolean, Object[]) : ObjectHandle;

Creates a handle to an object using the name of the type and the assembly where it exists. This allows types to be created remotely without having to load the type locally. These will return an ObjectHandle that needs to be unwrapped in order to access the real object.

[Visual Basic] Overloads Public Shared Function CreateInstance(String, String, Boolean) As ObjectHandle
[C#] public static ObjectHandle CreateInstance(String, String, bool);
[C++] public: static ObjectHandle* CreateInstance(String*, String*, bool);
[JScript] public static function CreateInstance(String, String, Boolean) : ObjectHandle;

Creates an instance of a specified type using the specified constructor. The constructor that is to be invoked must be accessible and provide the most specific match with the specified argument list, under the constraints of the default binder.

[Visual Basic] Overloads Public Shared Function CreateInstance(Type, Object()) As Object
[C#] public static object CreateInstance(Type, Object[]);
[C++] public: static Object* CreateInstance(Type*, Object[]);
[JScript] public static function CreateInstance(Type, Object[]) : Object;

Creates an instance of the specified type using the specified constructor. The constructor that is to be invoked must be accessible and provide the most specific match with the specified argument list, under the constraints of the specified binder and binding attributes.

[Visual Basic] Overloads Public Shared Function CreateInstance(Type, BindingFlags, Binder, Object(), CultureInfo) As Object
[C#] public static object CreateInstance(Type, BindingFlags, Binder, Object[], CultureInfo);
[C++] public: static Object* CreateInstance(Type*, BindingFlags, Binder, Object[], CultureInfo);
[JScript] public static function CreateInstance(Type, BindingFlags, Binder, Object[], CultureInfo) : Object;

Creates an instance of the specified type using the specified constructor. The constructor that is to be invoked must be accessible and provide the most specific match with the specified argument list, under the constraints of the specified binder and binding attributes.

[Visual Basic] Overloads Public Shared Function CreateInstance(Type, BindingFlags, Binder, Object(), CultureInfo, Object()) As Object
[C#] public static object CreateInstance(Type, BindingFlags, Binder, Object[], CultureInfo, Object[]);
[C++] public: static Object* CreateInstance(Type*, BindingFlags, Binder, Object[], CultureInfo, Object[]);
[JScript] public static function CreateInstance(Type, BindingFlags, Binder, Object[], CultureInfo, Object[]) : Object;

See Also

Activator Class | Activator Members | System Namespace