1. Josh Chalmers
  2. PowerBuilder
  3. Tuesday, 4 October 2022 18:05 PM UTC

I'm attempting to use PowerBuilder.RegistedObject.TriggerEvent() method in C# and PowerBuilder 2022. I've tried to do it with the simplest of examples.

I don't have any issues registering the assembly, creating the object and calling methods from the C# object.  I also am able to register and unregister the object without any issues.  Any time I call the TriggerEvent method in C# though, I get the error -52 - The objectname is not registered.

I've checked and double-checked the object name for spelling errors, and I know it is case sensative (w_testing is what I'm using)

Any suggestions on how I can debug this?  Is there a reason it is registered fine in PowerBuilder but not from my C# DLL.  When I UnRegister, I don't get errors unless I do something like UnRegister twice, which seems to sort of confirm that the register/unregister is working.  Is there somewhere I can look to "see" the registration?  Is there a chance the C# DLL is looking in the wrong place for the registered object?

Thanks!

 EDIT:  I was able to redo my example with .NET Framework 4.8 and the appropriate invoker dll.  It worked perfectly.  I now suspect it has to do with me probably not having the correct DLLs available for the .NET6 C# DLL.

 

Peter Piechutzki Accepted Answer Pending Moderation
  1. Wednesday, 20 March 2024 15:01 PM UTC
  2. PowerBuilder
  3. # 1

I now have a example demonstrating the problem.  The .net RegisteredObject.Triggerevent allways returns a -52 according to docs meaning "-52 -- The objectname is not registered."

To Check unzip attached to your development folder. Start either exe or in PB. .net class is refrenced via relative path, so it should work out of the box.

It would be nice if someone here comes up with a solution or has equal problems before i submit it as a bug.

 

Attachments (1)
Comment
  1. Peter Pang @Appeon
  2. Thursday, 21 March 2024 03:34 AM UTC
Hi Peter,



There is a slight issue with your registration code. Please change 'this' to 'parent' as follows:

st_2.text = string(ino_service.RegisterObject(parent.classname(),parent))



Additionally, ensure that there is no separate pbdotnetinvoker.dll file under the DLL and EXE directory. PowerBuilder will load the pbdotnetinvoker.dll from the Runtime directory and its associated DLLs.





Best Regards,

Peter

  1. Helpful 1
  1. Peter Piechutzki
  2. Thursday, 21 March 2024 11:38 AM UTC
Thanks Peter Pang! You saved my day!!! Of course, you are right. st_2.text = was a cut&paste from my first try in the open event of the window. But the real solution is removing pbdotnetinvoker.dll from the folder where my CSPBObj.dll is located so that the PB IDE uses the one from the current PB runtime directory. One thing to note is that after you get a .net error it is wise to restart PB IDE and Snapdevelop. Otherwise errors persist although you might have corrected your code.
  1. Helpful
There are no comments made yet.
Armeen Mazda @Appeon Accepted Answer Pending Moderation
  1. Wednesday, 13 March 2024 13:47 PM UTC
  2. PowerBuilder
  3. # 2

Hi Josh, Have you upgraded to PowerBuilder 2022 R3?  The base PowerBuilder 2022 doesn't support .NET 6.  We added .NET 6 support starting from revision 2: https://docs.appeon.com/pb/whats_new/dotNET_6_upgrade.html

Comment
There are no comments made yet.
Peter Piechutzki Accepted Answer Pending Moderation
  1. Wednesday, 13 March 2024 13:14 PM UTC
  2. PowerBuilder
  3. # 3

Thanks alot Josh for your description and the work around I've still got to test. I am having the exact same problems using .net 6.0. I've searching for solutions for hous now and there is no chance to successfully debug this matter nor find any other solutions on the Github Examples.  

regard peter

below simple code sample.

c# Code

 

public static class PBCSTest

{
    public int Tester()
        {

            string errstr = "";

            int err;

            err = RegisteredObject.TriggerEvent("w_sheet", "ue_callback", "Testmessage", ref errstr);

            return err;
        }
}

PB Code:

// Open scirpt of w_sheet
int li_reg = 0
int li_err = 0
boolean lb_created = false

ino_service = create nvo_pbcstest

lb_created = ino_service.of_createondemand( )
// returns true

li_reg = ino_service.RegisterObject("w_sheet",this)
// returns 1

li_err = ino_service.of_tester();
// returns -52

li_reg = ino_service.RegisterObject("w_sheet",this)
// returns -51

li_reg = ino_service.UnregisterObject("w_sheet")
// Returns 1

li_reg = ino_service.RegisterObject("w_sheet",this)
// returns 1

li_reg = ino_service.UnregisterObject("w_sheet")
// Returns 1

destroy ino_service

ue_callback

 

Comment
  1. Peter Piechutzki
  2. Thursday, 14 March 2024 06:51 AM UTC
Armeen, Sorry for misunderstandings, my incompetence and I revised the comment. Yes, I've previosly read all the Help and release notes. And already the System was updated to PB2022R3 3389. But the problem persists. RegisteredObject.TriggerEvent() allways returns -52; As I've seen today, the (out of the box working!) Appeon.Components examples also use .net 6. I'll gues I'll have to look more into the Appeon.ComponentsApp as soon as i find the time.
  1. Helpful
  1. Armeen Mazda @Appeon
  2. Thursday, 14 March 2024 17:00 PM UTC
Hi Peter, If you have a test case please open a support ticket kit so our team can investigate.
  1. Helpful
  1. Peter Piechutzki
  2. Tuesday, 19 March 2024 15:12 PM UTC
I've now checked Appeons great examples at https://github.com/Appeon/PowerBuilder-Components-Example. And what shall I say, whilst most of them is ported or newly created in .net 6.0 the example regarding callback functionality resides with.net 4.8. Namely the eventInvoker used for such callbacks to pb events: https://github.com/Appeon/PowerBuilder-Components-Example/blob/main/C%23%20Solution/PowerBuilderEventInvoker.DotNetFramework/Appeon.ComponentsApp.PowerBuilderEventInvoker.DotNetFramework.csproj

.

I wonder why, are the appeon programmers having the same problem as listed above? I can find absolutely not one single (easy) working example using .net 6 and calling back to a pb event from there. The thing is, i'm not a specialist in .net and am starting to learn as much as possible to interact c# .net with pb.



asap i will be glad return with simple (not working) example.



regards
  1. Helpful
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.
We use cookies which are necessary for the proper functioning of our websites. We also use cookies to analyze our traffic, improve your experience and provide social media features. If you continue to use this site, you consent to our use of cookies.