Syntax 2: for DotNetAssembly objects
Description
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
Syntax
|
1 |
objectname.CreateInstance ( readonly string classname, CSharpObjcet DotNetObject {, arg1, arg2,..., argn }) |
|
Argument |
Description |
|---|---|
|
objectname |
Reference to the DotNetAssembly object instance. |
|
classname |
The name of the .NET class. It must contain the namespace and the class name: |
|
DotNetObject |
The name of the DotNetObject object. |
|
{, arg1, arg2,…, argn } (optional) |
The .NET constructor argument. Constructor argument is optional. If no argument is |
Return value
Integer.
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.
Usage
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.
Examples
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
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) return 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) return end if |
See also