Spring.NET 1.3.0 RC1 for .NET 2.0 API Reference

ObjectUtils.InstantiateType(Type) Method

Convenience method to instantiate a Type using its no-arg constructor.

[Visual Basic]
Public Overloads Shared Sub InstantiateType( _
   ByVal type As Type _
)
[C#]
public static object InstantiateType(
   Type type
);

Parameters

type
The Type to instantiate*

Return Value

A new instance of the Type.

Remarks

As this method doesn't try to instantiate Types by name, it should avoid Type loading issues.

Exceptions

Exception Type Condition
ArgumentNullException If the type is a null reference (Nothing in Visual Basic)
FatalReflectionException If the type is an abstract class, an interface, an open generic type or does not have a public no-argument constructor.

See Also

ObjectUtils Class | Spring.Util Namespace | ObjectUtils.InstantiateType Overload List