ActivatorUtilities.CreateInstance Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Overloads
CreateInstance(IServiceProvider, Type, Object[]) |
Instantiates a type with constructor arguments provided directly and/or from an IServiceProvider. |
CreateInstance<T>(IServiceProvider, Object[]) |
Instantiate a type with constructor arguments provided directly and/or from an IServiceProvider. |
CreateInstance(IServiceProvider, Type, Object[])
- Source:
- ActivatorUtilities.cs
- Source:
- ActivatorUtilities.cs
- Source:
- ActivatorUtilities.cs
Instantiates a type with constructor arguments provided directly and/or from an IServiceProvider.
public:
static System::Object ^ CreateInstance(IServiceProvider ^ provider, Type ^ instanceType, ... cli::array <System::Object ^> ^ parameters);
public static object CreateInstance (IServiceProvider provider, Type instanceType, params object[] parameters);
static member CreateInstance : IServiceProvider * Type * obj[] -> obj
Public Shared Function CreateInstance (provider As IServiceProvider, instanceType As Type, ParamArray parameters As Object()) As Object
Parameters
- provider
- IServiceProvider
The service provider used to resolve dependencies.
- instanceType
- Type
The type to activate.
- parameters
- Object[]
Constructor arguments not provided by the provider
.
Returns
An activated object of type instanceType.
Exceptions
.NET 8 and later only: provider
is null
.
Applies to
CreateInstance<T>(IServiceProvider, Object[])
- Source:
- ActivatorUtilities.cs
- Source:
- ActivatorUtilities.cs
- Source:
- ActivatorUtilities.cs
Instantiate a type with constructor arguments provided directly and/or from an IServiceProvider.
public:
generic <typename T>
static T CreateInstance(IServiceProvider ^ provider, ... cli::array <System::Object ^> ^ parameters);
public static T CreateInstance<T> (IServiceProvider provider, params object[] parameters);
static member CreateInstance : IServiceProvider * obj[] -> 'T
Public Shared Function CreateInstance(Of T) (provider As IServiceProvider, ParamArray parameters As Object()) As T
Type Parameters
- T
The type to activate
Parameters
- provider
- IServiceProvider
The service provider used to resolve dependencies
- parameters
- Object[]
Constructor arguments not provided by the provider
.
Returns
An activated object of type T
Exceptions
.NET 8 and later only: provider
is null
.