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
![]() | Returns a COM interface for a .NET object. |
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, |
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, Note:
|
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 One, you must first create a COM interface for the .NET object using the CreateInstance method. Then you pass that interface as the method argument.

The following example uses the CreateInstance method to create an instance of a blank Windows form object, display the form on screen, and then close it after two seconds.
Set var_CreateInstance = DotNetFactory.CreateInstance("System.Windows.Forms.Form", "System.Windows.Forms")
var_CreateInstance.Show
wait 2
var_CreateInstance.Close
The following example uses the CreateInstance method to create an instance of a system environment object, and to display a message box listing the current directory. In this example, there is no need to specify the optional arguments because the required assembly is already in memory.
Set var_CreateInstance = DotNetFactory.CreateInstance("System.Environment")
msgbox var_CreateInstance.CurrentDirectory
See also:
- Crypt Object
- DataTable Object
- Description Object
- DeviceReplay Object
- DotNetFactory Object
- DTParameter Object
- DTSheet Object
- Environment Object
- Extern Object
- Parameter Object
- JSON Object
- JsonUtil Object
- MercuryTimers Object (Collection)
- MercuryTimer Object
- NV Object
- OptionalStep Object
- ParallelUtil Object
- LocalParameter Object
- PasswordUtil Object
- PathFinder Object
- PDFUtil Object
- Properties Object (Collection)
- QCUtil Object
- RandomNumber Object
- Recovery Object
- Remote Connection Object
- Reporter Object
- RepositoriesCollection Object
- Repository Object
- Services Object
- Setting Object
- SystemMonitor Object
- TestArgs Object
- TextUtil Object
- UIAutomation Object
- VisualRelation Object
- VisualRelations Object
- VisualRelationsCollection Object
- WebUtil Object
- XMLUtil Object