1. Don Olliver
  2. PowerBuilder
  3. Thursday, 14 June 2018 16:07 PM UTC

Should PB 2017 .NET assemblies be able to connect to ActiveX controls using ConnectToNewObject?

We are in the process of migrating PB 11.5 COM components to PB 2017 R2 .NET assemblies. One of these components integrates with an ActiveX control from Amyuni, which we use to open, manipulate and save PDF documents.

Our code In PB 11.5 COM:

oleobject ole_pdf
ole_pdf = create OLEObject
li_rc = ole_pdf.ConnectToNewObject("PDFCreactiveX.PDFCreactiveX.5.5")
 
try
// Attempt to open PDF
if aole_pdf.openex(as_filename, "") then
// Success
else
// Unable to open the PDF
end if
catch (oleruntimeerror err_pdfopenex)
lb_error = True
end try
 

In the .NET assembly target, li_rc is zero (no errors). But, the oleobject call to open the PDF fails. The CATCH is not executed, so there is no runtimeerror. Do we need some type of interop for communication with non-.NET libraries?

Thanks,
Don Olliver 

Daryl Foster Accepted Answer Pending Moderation
  1. Friday, 15 June 2018 02:29 AM UTC
  2. PowerBuilder
  3. # 1

Hi Don,

We are migrating our PB 10.5 COM Component over to a .Net assembly target in PB 2017.  Our PB 10.5 COM Component uses ConnectToNewObject to connect to another one of our COM objects.  The COM object we are connecting to is actually a .Net Assembly we wrote in C# and exposed with COM interop, but as far as PB is concerned it is connecting to a COM object.  That code migrated to the PB 2017 .Net assembly without any change so it looks like it is possible for the .Net assemblies to use ConnectToNewObject.

Are you sure li_rc is returning 0 in your code?  There is no check for its value, although I guess it would raise an exception by calling aole_pdf.openex if the object wasn't valid.  Have you tried calling any other methods on aole_pdf to see if they are working?  Debugging the deployed .Net assemblies is a bit of a pain, I had to resort to adding MessageBoxes to debug other issues I had with our .Net assembly.

 

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.