- Pavel Gregor
- PowerBuilder
- Friday, 19 January 2024 11:36 AM UTC
Problem description:
When using the RegisterObject command according to the sample example from Help, it reports
RegisterObject function reports error -5 - DotNetObject is not instantiated.
However, from the sample in the attachment, it is clear that the lcs_object variable is declared and has a valid handle.
On the other hand, the create command fails to create an instance of the PowerObject type for the variable w_dotnettest. The variable w_dotnettest has no handle! So the problem is in the declaration of the PowerObject variable.
The RegisterObject function is not functional even if it is used already an existing Powerbuilder object. For example, an existing window.
So how should the variable w_dotnettest be correctly declared to make attached script work? Thanks
Pavel Gregor
Script:
Long ll_return
PowerObject w_dotnettest
DotNetObject lcs_object
// Create object DotNetObject
lcs_object = create DotNetObject
// Create object PowerObject - doesnt work
w_dotnettest = create PowerObject
// object registration
ll_return = lcs_object.RegisterObject("w_dotnettest", w_dotnettest)
if ll_return = 1 then
MessageBox("User Object Registration", "Object w_dotnettest registered succesfully.",Information!)
else
MessageBox("User Object Registration", "Object registration failed w_dotnettest "+string(ll_return),Exclamation!)
end if
IF isvalid(lcs_object) THEN DESTROY lcs_object
IF isvalid(w_dotnettest) THEN DESTROY w_dotnettest
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.