About .NET assembly

The .NET assembly supported by PowerBuilder must be developed on .NET Framework 4.0 or later or .NET Core 1.0 or later. And the assembly DLL file will require the corresponding version of .NET Framework, .NET Core, or .NET Standard to run, especially if the DLL file is a .NET Standard class library. Please check the Microsoft website or the following table for the compatible versions between .NET Standard, .NET Core, and .NET Framework. For an interactive table, see .NET Standard versions.

.NET Standard 1.0 1.1 1.2 1.3 1.4 1.5 1.6 2.0 2.1
.NET Core 1.0 1.0 1.0 1.0 1.0 1.0 1.0 2.0 3.0
.NET Framework 4.5 4.5 4.5.1 4.6 4.6.1 4.6.1 4.6.1 4.6.1 N/A

If the assembly DLL is created by PowerBuilder .NET, the dependent Sybase DLLs must be copied to the same folder as the assembly DLL.

The Sybase DLLs are originally located at %Appeon%\PowerBuilder 19.0\DotNET\bin.

Data types

The following table lists the data type mappings between PowerBuilder and .NET. Keep in mind that PowerBuilder and .NET data types may not have the same definitions even if the type name is the same or similar. For PowerBuilder data types, refer to Datatypes in PowerScript Reference. For .NET data types, refer to the Types and variables web page.

PowerBuilder char maps to .NET string, and PowerBuilder ref char maps to .NET char.

PowerBuilder blob[] maps to .NET byte[][]. PowerBuilder blob two-dimensional array is unsupported.

The index in PowerScript starts from 1, while the index in .NET starts from 0, therefore, PowerBuilder Array[1] maps to .NET Array[0].

When the .NET function is imported to the NVO, the two-dimensional array will be converted to Any data type when passed as arguments or return values, and the first-dimensional array will be converted to Any data type when passed as return values, because PowerBuilder does not support using the array argument as the return value of a function (the developer can use the corresponding array or any to receive the value).

For numeric data type, the mapping between PowerBuilder and .NET can be fuzzy. For example, even the .NET integer-type should be mapped to PowerBuilder long-type normally, the .NET function "public int Add(int parm1, int parm2)" can also be called by the integer-type parameter in PowerBuilder (instead of the long-type parameter).

For standard data type and array data type, PowerBuilder can map to the .NET nullable and non-nullable types, for example, PowerBuilder integer type can map to the .NET short and short? types.

For numeric array, PowerBuilder and .NET must be exactly mapped. For example, PowerBuilder integer-type array can only map to the .NET short-type array.

Date and Time can only be used in arguments and cannot be used in return values; when used in arguments, they are passed to .NET as DateTime; when passed by Ref, the value will be sync to the Date and Time variables; they cannot be used as return values to receive DateTime return values from .NET; and cannot set or receive DateTime property values from .NET.

When passing a PowerBuilder variable-length array to .NET, .NET can use list to process the data from the PowerBuilder variable-length array, and then assign the data to the PowerBuilder ref variable-length array or return the data directly. At the end of this section, there is a sample of PowerScript code that uses the variable-length array to receive the double-type data from .NET.

PowerBuilder

C#

Array (one and two dimension)

Reference

Generic Nullable<T>

int

short

Supported

Supported

Supported

uint

ushort

Supported

Supported

Supported

long

int

Supported

Supported

Supported

longptr

int32/int64

Supported

Supported

Supported

ulong

uint

Supported

Supported

Supported

longlong

long/Int64

Supported

Supported

Supported

boolean

bool

Supported

Supported

Supported

char

string/char

Supported

Supported

Supported

string

string

Supported

Supported

Unsupported

real

float

Supported

Supported

Supported

double

double

Supported

Supported

Supported

decimal

decimal

Supported

Supported

Supported

blob

byte[]

Supported

Supported

Supported

Date

DateTime

Supported

Supported

Supported

DateTime

DateTime

Supported

Supported

Supported

Time

DateTime

Supported

Supported

Supported


Supported return value data types

The following table lists the return value data type mappings between PowerBuilder and .NET.

PowerBuilder

C#

int

short

uint

ushort

long

int

longptr

int32/int64

ulong

uint

longlong

long/Int64

boolean

bool

char

char

string

string

real

float

double

double

decimal

decimal

blob

byte[]

DateTime

DateTime


Classes

.NET classes are supported, except for the following:

  • Interface

  • Struct

  • Abstract class

  • Static, Protected, Private, Internal, or Generic class

Nested class is supported, except that using the plus sign (“+”) instead of the dot (“.”) to access the nested class: [namespace].[class]+[nested-class].

Functions

.NET functions are supported, except for the following:

  • Private, Protected, Extension, or Generic function

Function parameters and return values are supported with the following exceptions:

  • Using a generic type, delegate, or class as the parameters or return value of a function

  • Passing parameters by reference is supported when the developer adds the keyword "ref" or "out" explicitly; however, passing parameters by reference to a constructor function is unsupported

  • The params keyword

  • The optional attribute of arguments

  • Object-type or Sbyte-type arguments

  • Transaction object array

  • Date and Time can only be used in arguments and cannot be used in return values.

Properties

Each property will have two functions imported (one for getting the property value and the other for setting). Read-only or write-only property will have only one function imported.

Getting or setting a property is supported, except for the following:

  • More than one-level dot notation for getting or setting a property. For example, the following is unsupported: Student.Informations.Name="Kit".

  • Using a generic type, delegate, or class as the value of a property.

  • Private or Protected property

  • Indexer

Fields

Data fields are unsupported.

Transaction Objects

Transaction Objects (specifically IAdoConnectionProxy) are only supported in .NET Framework, but not in .NET Core.

Transaction Objects from .NET do not support Oracle Data Provider for .NET (Oracle.DataAccess.Client or Oracle.ManagedDataAccess.Client).

Deploying the application

When the PowerBuilder application is deployed, the system DLLs such as PBDotNet190.dll, PBDotNetFrameworkInvoker190.dll, and PBDotNetCoreInvoker190.dll will be deployed automatically. However, you will need to make sure the .NET DLLs as well as any dependent DLLs are deployed in the same folder.

And also make sure the target machine have Universal CRT (C Runtime) and the required .NET Framework or .NET Core installed in order to run the .NET DLLs.