DotNet::Services.CreateObject Method

Syntax

dim Result as L = CreateObject(BYREF Instance as P, ClassName as C, OPTIONAL Assembly as DotNet::AssemblyReference = null_value(), PARAMS Args as A)

Arguments

InstancePointer

 

ClassNameCharacter

AssemblyDotNet::AssemblyReference

 

ArgsAny Type

 

Returns

ResultLogical

Returns .t. or .f. whether or not the operation succeeds. The DotNet::Services CallResult property will contain additional information about the error.

Description

CreateObject() creates an instance of an arbitrary .NET class without registering the assembly or class in the Xbasic type system.

Once the instance is destroyed, the assembly is still loaded in the Common Language Runtime (CLR), but Xbasic will retain no knowledge of the type.

Create an instance of a type registered in the .NET global assembly cache (GAC).

Dim Services as DotNet::Services
Dim Instance as P

' Create a StringBuilder instance with a capacity of 4096 chars.
If .not. Services.CreateObject(Instance, "System.Text.StringBuilder", \
        null_value((, 4096( 
    UI_Msg_Box("Error creating StringBuilder instance", \
        Services.CallResult.Text(
End If