Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

TypeDescriptor.CreateInstance Method

Creates an object that can substitute for another data type.

Namespace:  System.ComponentModel
Assembly:  System (in System.dll)

public static Object CreateInstance(
	IServiceProvider provider,
	Type objectType,
	Type[] argTypes,
	Object[] args
)

Parameters

provider
Type: System.IServiceProvider

The service provider that provides a TypeDescriptionProvider service. This parameter can be null.

objectType
Type: System.Type

The Type of object to create.

argTypes
Type: System.Type[]

An optional array of parameter types to be passed to the object's constructor. This parameter can be null or an array of zero length.

args
Type: System.Object[]

An optional array of parameter values to pass to the object's constructor. If not null, the number of elements must be the same as argTypes.

Return Value

Type: System.Object
An instance of the substitute data type if an associated TypeDescriptionProvider is found; otherwise, null.

ExceptionCondition
ArgumentNullException

objectType is null, or args is null when argTypes is not null.

ArgumentException

argTypes and args have different number of elements.

The CreateInstance method will search for a TypeDescriptionProvider that is associated with the specified objectType data type. This method first tries to obtain a type description provider from the provider parameter. If this fails, it searches its own internal tables for a provider (these entries were created through previous calls to AddProvider). If it finds a provider, this method will delegate the creation call to that object.

Notes to Inheritors

If the derived class does not provide a substitute instance, this method should call the base implementation.

.NET Framework

Supported in: 4.5, 4, 3.5, 3.0, 2.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Show:
© 2014 Microsoft