cancel
Showing results for 
Search instead for 
Did you mean: 

Using PowerBuilder .NET Assembly in Classic PowerBuilder

Former Member
0 Kudos

I have a PB Classic 11.5 application for which I need to use REST Services.  I know very little about how to do this.  Bruce Armstrong's YouTube video published on Dec 7, 2012 (SAP D&T Academy - How to Use Non-Visual .NET Assemblies in PowerBuilder Classic Win32 Apps) was very helpful to me in creating the .NET assembly.  If I create a "WPF Window Application" in PB .NET 12.6, my REST Client Proxy works fine.

But when I create a PB .NET 12.6 Assembly project and try to use in with my PB Classic 11.5 application I am having issues. Specifically, I am getting error code -3: "Object could not be created" when using myOLEObject.ConnectToNewObject("my.class").  If I use myOLEObject.ConnectToObject("", "my.class"), I get error code -5: "Ca not connect to the currently active object."  I am assuming that "Ca not" is really "Cannot".  I used RegAsm to register the assemblies.  I have tried both placing the assemblies in the GAC with strong names for the DLLs and using the assemblies as local files without strong names, and many countless other things that I cannot even remember now.


I have spent several days doing Google searches.  Part of my problem may be not knowing the proper terminology to use for my searches.  I even found the same question being asked on the old Sybase Forums about 8 years ago, but no one provided a final answer.  I have also privately emailed Bruce requesting a link to his source code used in the video.  While I am waiting for his response, I continued doing Google searches and decided to ask the question here.


Thank you for your help.  (This is my first question on SAP community.)


Lane Poole



Accepted Solutions (0)

Answers (1)

Answers (1)

former_member190719
Active Contributor
0 Kudos

You want to post technical questions over in the .

I did get your email, but between the ISUG-TECH 2015 Conference and Easter I've been swamped.  I'll get to your question posted in the PowerBuilder Developer Center when I have time.

Former Member
0 Kudos

I have made some progress.

My ultimate goal is to not use the Registry or GAC, but to make sure the project is working, I used the Registry and GAC as an intermediate step.

Since I spent a week doing Google searches, I am listing my steps so far to possibly help someone else with the same issue. This project uses REST Services, so there are several DLLs involved.

What I have done so far is to:

1. Create the strong name (on the Sign tab of the project) without compiling.

2. Exit PB .dotNET to release locks on files.

3. Run the following two commands on each of the REST DLLs (but not the main project DLL)

     a. "C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\ildasm" /all /out=MyRest_aaa.il MyRest_aaa.dll

     b. ilasm /dll /key=myStrongNameFile.snk MyRest_aaa.il

4. Open PB .NET and click the toolbar button for "Full Build Project"

5. Copy the project DLL and all the REST DLLS (located in *.out\bin\debug or release) to your PB Classic deployment folder.

6. For each DLL copied (the main project DLL and the REST DLLS), run the GAC Utility:

     example: "C:\Program Files (x86)\Microsoft SDKs\Windows\v8.0A\bin\NETFX 4.0 Tools\gacutil.exe" /i MyProject.dll

7. Create a REG file by running REGASM only on the main project DLL

     "C:\Windows\Microsoft.NET\Framework\v4.0.30319\RegAsm.exe" MyProject.dll /regfile:MyProject.reg

8. Edit the file MyProject.reg

     a. Select all lines in the file.

     b. Copy all lines to clipboard.

     c. At the end of the file, paste the lines back in the file (now, every line in the file is duplicated).

     d. On the lines that were duplicated, replace "HKEY_CLASSES_ROOT\CLSID" with "HKEY_CLASSES_ROOT\Wow6432Node\CLSID"  (This step taken from Bruce Armstrong's comment in the SAP Community: )

     e. Save the file.

     f.  Doubleclick on file in Explorer to place entries in Registry.

8. Use following sample code in Classic PB application

     OLEObject lole_myOLE

     lole_myOLE = CREATE OLEObject

     li_return = lole_myOLE.ConnectToNewObject("myNamespace.MyInstanceNVO")

     my_return = lole_myOLE.myFunction(myInParameter, REF myOutParameter)

     lole_myOLE.disconnectobject( )

     DESTROY lole_myOLE

Hopefully, this can help someone else, but as I stated, I still am not done. I want to do this without using the Registry and GAC because of the number of machines my project will be deployed to.

I would still appreciate any help in how to do this without using the Registry and GAC.

Thanks,

Lane

Former Member
0 Kudos

Dear Lane, I have the same problem, I m trying to use a Asembly but not work, your solution is interesting, I'll try to use it.  I have only dubt, explicity that you mean Rest Services?

Former Member
0 Kudos

Franco,

REST is something I am just learning about myself.  It stands for Representional State Transfer. It is a way of executing HTTP urls. PB.NET can do the following through HTTP:

get: Similar to a SQL SELECT

put: Similar to a SQL UPDATE

post: Similar to a SQL INSERT

delete: Similar to a SQL DELETE.

It works with a Request and Response object. The objects can have formats such as JSON, XML, etc. This approaching the limits of my knowledge about REST. A fellow associate setup a REST Service for me to use and explained to me how to access it.  Hopefully someone else can give you a much better explaination of REST.

I have also discovered that Step 5 in my previous post is not necessary. That only becomes necessary if you figure out how to do it without using the GAC (which I also just started learning about.)

Hope this gives you a start.

Lane

Former Member
0 Kudos

Hello Lane, thank you very mucho for the information, I will try with it.

Regards,

Franco C.