Object Model Reference for GUI Testing > Utility Objects > CreateInstance Method

DotNetFactory Object

Description

Enables you to create an instance of a .NET object, and access its methods and properties.

IMPORTANT

You can use this object to access the static methods and properties of a class that does not have an instance constructor, for example, System.Environment, as well as a class that does.

Methods

Method CreateInstance Returns a COM interface for a .NET object.

Back to top

CreateInstance Method

Description

Returns a COM interface for a .NET object.

Syntax

Set var_CreateInstance = DotNetFactory.CreateInstance (TypeName, [Assembly], [args])

Argument

Type

Description

TypeName

String

The full name of the object type, for example, System.Windows.Forms.Form.

Assembly

Any

Optional. If the assembly is preloaded in the registry, you do not need to enter it. Otherwise, you should enter the full path name, for example, System.Windows.Forms. If you want to create an instance of a type in the GAC (Global Assembly Cache), you can enter the short name, for example, Forms.

Note:

  • If you do not pass this argument, UFT assumes that the assembly is resident in memory. If UFT does not find the assembly, an error message is displayed during the run session.
  • Some assemblies are designed to depend on specific configuration information. To load such an assembly using DOTNetFactory.CreateInstance, you must add the configuration required by the assembly to the <UFT installation>/bin/uft.exe.config file before opening

args

Any

Optional. The required arguments, if any, for the specified TypeName and/or Assembly.

Return Value

A Variant value. Returns the defined instance of the .NET object.

IMPORTANT

If you want to use a .NET object as an argument for a method in UFT, you must first create a COM interface for the .NET object using the CreateInstance method. Then you pass that interface as the method argument.


Back to top

See also: