1. appeon pb
  2. PowerBuilder
  3. 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

appeon pb Accepted Answer Pending Moderation
  1. Friday, 1 December 2023 02:17 AM UTC
  2. PowerBuilder
  3. # 1

Thank you Francisco, I compile .net DLL with fakes option  , and put pbdotnetcoreinvoker.22.0.0.0.Fakes.dll in my app path, and the problem solved.

Comment
  1. Armeen Mazda @Appeon
  2. Friday, 1 December 2023 03:12 AM UTC
Thanks for sharing the solution!
  1. Helpful
There are no comments made yet.
Francisco Martinez @Appeon Accepted Answer Pending Moderation
  1. Thursday, 30 November 2023 15:03 PM UTC
  2. PowerBuilder
  3. # 2

Hi,

Are you perhaps running the project inside the IDE? If so, make sure that alongside your .NET DLLs, you're not also including any pbdotnet{core,framework}invoker.dll file. The IDE provides its own pbdotnetinvoker.dll modules, so the one's you're registering onto might not be the same that are being called from.

Regards,
Francisco

Comment
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.