1. ts maniam
  2. PowerBuilder
  3. Friday, 12 August 2022 16:49 PM UTC

Dear experts,

As my first pbni attempt, created pbni nvo pbadd as given in pbni example. The object was created using win32 option in Visual studio 2019. The object could be imported as pb extension and it displays the function f_add(). If we click on it, the error message "Error creating PBNI Object" displayed. On clicking OK of the messagebox, possible causes are listed as given in error image 2. 

As given in the example, window w_add created and the object instance created and used. While running, the error message received. The screen shots have been uploaded. PB Version used 2021 build 1311 running on windows 11 os x64.

Not able to figure out what could be the issue. Can you please help me in this... 

Thanks in advance, with regards.

ts maniam

 

Attachments (4)
ts maniam Accepted Answer Pending Moderation
  1. Monday, 15 August 2022 17:26 PM UTC
  2. PowerBuilder
  3. # 1

Dear Roland Smith,

Greetings. The "pbadd" solution you have given works fine and noted improvements.

Thanks a lot and now bit more confident to try a new one.

Thank you very much and with regards, 

ts maniam

 

Comment
There are no comments made yet.
Roland Smith Accepted Answer Pending Moderation
  1. Friday, 12 August 2022 22:36 PM UTC
  2. PowerBuilder
  3. # 2

The attached has a Visual Studio 2019 solution of 'pbadd' and a PB 2021 application. The workspace file is in the root folder and the target/library files are in the debug folder.

Attachments (1)
Comment
  1. Charlie Shilling
  2. Friday, 22 November 2024 16:47 PM UTC
I know this is an old topic but I stumbled into here while also working through the pbadd tutorial and having similar issues as many others, so figured I'd reply in case it helps others in the future.



After comparing my non-working attempt to Roland's working solution, it appears that the key difference is that, in the PBX_CreateNonVisualObject function in dllmain.cpp, Appeon's documentation had the third argument as LPCSTR, where as Roland had it as LPCTSTR - subtle difference but from what I understand (not a C++ expert), it changes the datatype from "Long Pointer to a Constant String" to "Long Pointer to a Constant **TCHAR** String". Effectively, because it uses TCHAR, LPCTSTR adapts to the project's settings (effectively, it's either a 2-byte Unicode wchar_t* or a 1-byte ANSI char*) whereas LPCSTR is always a 1-byte ANIS char*. There were a couple other minor changes I had to make within the function for it to work with TCHAR - basically use _tcscmp in place of strcmp, and then wrap the hardcoded "pbadd" in the 2nd argument to _tcscmp with _T() so that it has the same flexibility as the LPCTSTR datatype.



I have created a support ticket to fix this in the documentation, as well as a few other doc issues - https://www.appeon.com/standardsupport/search/view?id=12941
  1. Helpful
There are no comments made yet.
John Fauss Accepted Answer Pending Moderation
  1. Friday, 12 August 2022 18:47 PM UTC
  2. PowerBuilder
  3. # 3

It took me a lot of trial and error to create a working PBNI solution in Visual Studio when I was experimenting with some time ago. As I recall, there were several settings/options in Visual Studio I had to change to get it to work.

really wish Appeon would update the PBNI documentation, particular the parts explaining how to configure the DLL project in Visual Studio, as all of that existing information is woefully out of date. Having obsolete and/or wrong information is worse than having no information.

Of the VS settings, make sure the C/C++ Calling Convention is set to __cdecl (/Gd). I also had better luck turning off Precompiled Headers.

I would definitely recommend you (re-)start by using any template/sample VS solution that Roland provides.

Best regards, John

Comment
  1. Roland Smith
  2. Saturday, 13 August 2022 02:54 AM UTC
You can only import the 32-bit PBX because the IDE is 32bit. At runtime, you use the 64bit pbx with a 64bit application and the 32bit pbx with a 32bit application.
  1. Helpful 3
  1. Miguel Leeuwe
  2. Tuesday, 16 August 2022 05:13 AM UTC
Hi John, I had a ticket and Appeon claims they improved the documentation. I couldn't do much to test it but maybe you'll be more lucky?

Please see https://www.appeon.com/standardsupport/search/view?id=8429

regards,

MiguelL
  1. Helpful 1
  1. John Fauss
  2. Tuesday, 16 August 2022 05:21 AM UTC
I'll take a look at it soon, Miguel. Thanks for letting me know about this and for supplying the URL to the ticket.
  1. Helpful
There are no comments made yet.
Roland Smith Accepted Answer Pending Moderation
  1. Friday, 12 August 2022 17:32 PM UTC
  2. PowerBuilder
  3. # 4

I've have several working PBNI projects on my home computer. I'll throw together a working project for you this evening.

 

Comment
  1. ts maniam
  2. Friday, 12 August 2022 23:54 PM UTC
Dear Roland Smith,



Greetings. I have been through the Winsock pbni before and during my trials. Really appreciate your efforts and thanks. Even in the example trial, the pbadd, the constructor, destructor and invoke parts of the script were in pbadd.cpp, whereas in winsock.cpp the approach was different. They formed part of Dllmain.cpp. Those changes were also tried. The .pbx file gets generated in both cases.



waiting for your support.

Thanks and regards,
  1. Helpful
  1. Roland Smith
  2. Saturday, 13 August 2022 02:52 AM UTC
Did you try my pbadd example UNCHANGED? Did it work okay? If not, what problems did you have?

I wrote Winsock a long time ago and I have since changed my preferred file layout and coding style.

It doesn't really matter what files the parts are in, as long as the compiler is okay with it.

  1. Helpful 1
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.