Syntax 1: for TransactionServer objects


Creates an instance of a component running on the COM+ server. This function is called from within a component instance running on COM+.

Applies to

TransactionServer objects


transactionserver.CreateInstance (objectvariable {, classname } )




Reference to the TransactionServer service instance.


A global, instance, or local variable whose datatype is the same class as the object being created or an ancestor of that class.

classname (optional)

A string whose value is the name of the class datatype to be created.

For COM+ components, you can optionally prepend a ProgID followed by a period to the class name (for example, "PowerBuilder.HTMLDataWindow".

Return value


Returns 0 if it succeeds and one of the following values if an error occurs:

50 -- Distributed service error

52 -- Distributed communications error

53 -- Requested server not active

54 -- Server not accepting requests

55 -- Request terminated abnormally

56 -- Response to request incomplete

57 -- Not connected

62 -- Server busy


The CreateInstance function on the TransactionServer context object allows you to access other COM+ components running on the current server. The created instance inherits all the transaction and security attributes of the current object.

The CreateInstance function on the TransactionServer context object uses the same user and password information that applies to the component from which it is called.

Before you can use the transaction context service, you need to declare a variable of type TransactionServer and call the GetContextService function to create an instance of the service.


This example shows the syntax for creating an instance of a COM component:

Integer rc
OleObject lole
TransactionServer lts

lole = create OleObjectrc = this.GetContextService("TransactionServer", lts)
IF rc <> 1 THEN
   return "Error from GetContextService " + String (rc)

// PBCOM is the ProgID, n_genapp is the class namerc = lts.CreateInstance(lole, "PBCOM.n_genapp")

IF rc <> 0 THEN
   return "Error from CreateInstance " + String (rc)
END IFiole.my_func ()

See also


IsInTransaction (obsolete)

IsTransactionAborted (obsolete)

Lookup (obsolete)




Syntax 2: for DotNetAssembly objects


Creates an instance of the .NET class and associates it with the DotNetObject object. The DotNetObject object must be instantiated first.

The instance of the class can be used to access the functions/properties in the corresponding .NET class.

Applies to

DotNetAssembly objects


objectname.CreateInstance ( readonly string classname, CSharpObjcet DotNetObject {, arg1, arg2,..., argn })




Reference to the DotNetAssembly object instance.


The name of the .NET class.

It must contain the namespace and the class name: [namespace].[class], for example, AppeonSample.StandardTest.


The name of the DotNetObject object.

{, arg1, arg2,..., argn } (optional)

The .NET constructor argument.

Constructor argument is optional. If no argument is passed in, the application will automatically call the constructor that takes no parameter; and if there is no such parameterless constructor, the instance will fail to create.

Return value


Returns values as follows. If the classname or DotNetObject argument's value is null, the method returns null.

1 -- Success.

-1 -- Unknown error.

-2 -- Could not find the assembly.

-6 -- Could not find the class name.


The class name is case insensitive. The application will ignore the case of the class name and find the first class in the order that matches.

If there is a nested class, you should use the plus sign ("+") instead of the dot (".") to access the nested class, in this format: [namespace].[class]+[nested-class], for example, AppeonSample.StandardTest+MathTest.

The value of the constructor argument can be of any standard data type. See the section called “Data types” in Application Techniques.

Passing parameters by reference to a constructor function is unsupported. The modified data cannot be returned.

For Char data type, it will be passed to .NET as String type by default; and if there is no constructor function that matches the type, the instance will fail to create.

If the instance failed to create, the exception message returned from .NET will be stored in the ErrorText property.


DotNetAssembly lcs_ass
DotNetObject lcs_obj
long ll_return

//Instantiates the objects
lcs_ass = create DotNetAssembly
lcs_obj = create DotNetObject

//Loads the DLL
ll_return = lcs_ass.LoadWithDotNetFramework ("Appeon.Simple.dll")
//ll_return = lcs_ass.LoadWithDotNetCore ("Appeon.Simple.dll")
if ll_return < 0 then
 messagebox ("Load Dll Failed", lcs_ass.errortext)
end if

//Creats the instance
ll_return = lcs_ass.createinstance ("Appeon.Simple.AppeonCase01", lcs_obj, "appeon123")
if ll_return < 0 then
 messagebox ("CreateInstance Failed", lcs_ass.errortext)
end if

See also