- appeon pb
- PowerBuilder
- Thursday, 30 November 2023 03:12 AM UTC
PB 2022 R2 2828
import from DotNet dll,and get a object like n_dotnethelper
n_dotnetHelper ln_hlp
ln_hlp = Create n_dotnetHelper
.....
int li_rtn
li_rtn = ln_hlp.RegisterObject('w_sub', w_sub) // success return 1
//c# invokePBevent
li_rtn = ln_hlp.invokepbevent('w_sub','ue_redis','test msg ') // always return -52 : The objectname is not registered.
C# PowerBuilder.RegisteredObject.TriggerEvent
//*--------------------------------------------------------------*/
//* PUBLIC of_createOnDemand( )
//* Return True: .NET object created
//* False: Failed to create .NET object
//* Loads .NET assembly and creates instance of .NET class.
//* Uses .NET when loading .NET assembly.
//* Signals error If an error occurs.
//* Resets any prior error when load + create succeeds.
//*--------------------------------------------------------------*/
This.of_ResetError( )
If This.ib_objectCreated Then Return True // Already created => DONE
Long ll_status
String ls_action
/* Load assembly using .NET */
ls_action = 'Load ' + This.is_AssemblyPath
DotNetAssembly lnv_assembly
lnv_assembly = Create DotNetAssembly
ll_status = lnv_assembly.LoadWithDotNet(This.is_AssemblyPath)
/* Abort when load fails */
If ll_status <> 1 Then
This.of_SetAssemblyError(This.LOAD_FAILURE, ls_action, ll_status, lnv_assembly.ErrorText)
This.of_SignalError( )
Return False // Load failed => ABORT
End If
/* Create .NET object */
ls_action = 'Create ' + This.is_ClassName
ll_status = lnv_assembly.CreateInstance(is_ClassName, This)
/* Abort when create fails */
If ll_status <> 1 Then
This.of_SetAssemblyError(This.CREATE_FAILURE, ls_action, ll_status, lnv_assembly.ErrorText)
This.of_SignalError( )
Return False // Load failed => ABORT
End If
This.ib_objectCreated = True
Return True
Find Questions by Tag
Helpful?
If a reply or comment is helpful for you, please don’t hesitate to click the Helpful button. This action is further confirmation of their invaluable contribution to the Appeon Community.