1. Edmundo Buni
  2. PowerBuilder
  3. Wednesday, 29 July 2020 00:52 AM UTC

Hi,

I created a test PB app calling a single custom C# DLL function 'getName(jsonstring)' using OleObject and ConnectToNewObject( classname ) approach.

I had the app compiled as 32 bit.

The compiled exe is able to succesfully create/instantiate the OleObject, connect, call the function and get the return value.

But when i go into IDE debug and track thru the code, PB is not able to connectonewobject. It's returning -3 error: Object could not be created.

 

Here's the code...

long ll_return
string ls_return, ls_json = 'xyz'


OleObject lole_sm
lole_sm = Create OleObject
ll_return = lole_sm.ConnectToNewObject(is_className )

choose case ll_return
case 0
try
ls_return = lole_sm.GetName(ls_json)

catch(RunTimeError re)
ls_return ="Error "+string(ll_return)+ ": Failed secret call. " + re.text
end try
case -1
ls_return = 'Error -1: Invalid Call: the argument is the Object property of a control.'
case -2
ls_return = 'Error -2: Class name '+is_className+' not found'
case -3
ls_return = 'Error -3: Object could not be created'
case -4
ls_return = 'Error -4: Could not connect to object'
case -9
ls_return = 'Error -9: Other error'
case -15
ls_return = 'Error -15: COM+ is not loaded on this computer'
case -16
ls_return = 'Invalid Call: This function not applicable'
case else
ls_return = 'Unknown error'
end choose

destroy lole_sm

return ls_return

 

PB Version: 2017 R3 Build 1915

C# .Net registered using regasm.exe

 

Need help to understand why in IDE debug mode am getting an error while in exe compiled mode there is no error.

 

Thanks,

Edmundo

Armeen Mazda @Appeon Accepted Answer Pending Moderation
  1. Wednesday, 29 July 2020 00:58 AM UTC
  2. PowerBuilder
  3. # 1

Try the new .NET DLL importer of PowerBuilder 2019 R2: https://docs.appeon.com/pb2019r2/whats_new/ch01s03.html

Comment
  1. Edmundo Buni
  2. Wednesday, 29 July 2020 13:27 PM UTC
would it be possible to create a PB2019R2 PBD library that acts as wrapper to the C# DLL which a PB2017R3 built app can call?
  1. Helpful
  1. Chris Pollach @Appeon
  2. Wednesday, 29 July 2020 13:35 PM UTC
Hi Edmundo ... No that would not work as the 2019R2 PBD would be called within a 2017R3 thread and thus be incompatible with the 2017R3 PBVM.

Regards ... Chris
  1. Helpful
  1. Edmundo Buni
  2. Thursday, 30 July 2020 03:43 AM UTC
Thanks Chris.
  1. Helpful
There are no comments made yet.
Ricardo Jasso Accepted Answer Pending Moderation
  1. Wednesday, 29 July 2020 18:38 PM UTC
  2. PowerBuilder
  3. # 2

Maybe the EXE can find the .NET library and the IDE cannot. Is the .NET library in the same folder as the PBLs?

Comment
  1. Edmundo Buni
  2. Wednesday, 29 July 2020 21:57 PM UTC
I've placed the .Net Lib and it's dependencies in a folder which i added to system path. So it should be visible to apps.

Would it be maybe because the PB2017R3 is 64bit ?
  1. Helpful
  1. Edmundo Buni
  2. Wednesday, 29 July 2020 22:10 PM UTC
Got it to work and not have an error anymore.

i set the PB170.EXE to run on Windows 8 Compatibility mode.

Right click on PB170.exe, select "Compatibility" tab, and then checked the "Run this program in compatibility mode for: "Windows 8"
  1. Helpful
  1. Armeen Mazda @Appeon
  2. Thursday, 30 July 2020 05:25 AM UTC
Thanks for sharing the solution!
  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.