Share via


PrivateObject Constructor (Type, array<Object )

Initializes a new instance of the PrivateObject class that creates the wrapper for the specified object.

Namespace:  Microsoft.VisualStudio.TestTools.UnitTesting
Assembly:  Microsoft.VisualStudio.QualityTools.UnitTestFramework (in Microsoft.VisualStudio.QualityTools.UnitTestFramework.dll)

Syntax

'Declaration
Public Sub New ( _
    type As Type, _
    ParamArray args As Object() _
)
public PrivateObject(
    Type type,
    params Object[] args
)
public:
PrivateObject(
    Type^ type, 
    ... array<Object^>^ args
)
new : 
        type:Type * 
        args:Object[] -> PrivateObject
public function PrivateObject(
    type : Type, 
    ... args : Object[]
)

Parameters

  • type
    Type: Type

    The wrapped object type.

  • args
    Type: array<Object[]

    The arguments to define the object.

Exceptions

Exception Condition
ArgumentNullException

type is nulla null reference (Nothing in Visual Basic).

ArgumentException

type is not a RuntimeType.

NotSupportedException

type cannot be a TypeBuilder.

-or-

Creation of TypedReference, ArgIterator, and RuntimeArgumentHandle types is not supported.

TargetInvocationException

The constructor being called throws an exception.

COMException

type is a COM object but the class identifier used to obtain the type is invalid, or the identified class is not registered.

TypeLoadException

type is not a valid type.

MissingMethodException

No matching public constructor was found to match the type and args.

Remarks

An object is created by using the type and args.

The following table shows initial property values for an instance of the PrivateObject class instantiated with PrivateObject.

Property

Value

Target

The object created from type and args.

RealType

The wrapped object type

.NET Framework Security

See Also

Reference

PrivateObject Class

PrivateObject Overload

Microsoft.VisualStudio.TestTools.UnitTesting Namespace