Welcome!

PowerBuilder Authors: Ian Thain, Chris Pollach, Arthur Hefti, Dan Joe Barry, Maureen O'Gara

Related Topics: PowerBuilder

PowerBuilder: Article

PowerBuilder 11's .NET Interoperability

Creating and consuming .NET resources

PowerBuilder 11 deploys entire applications as .NET Windows Form or Web Form applications and deploys individual components as .NET Assemblies and as .NET Web Services. Version 11 consumes resources of the default .NET framework as well as resources of custom developer-defined .NET resources. Non-PowerBuilder .NET solutions can interoperate with, and take advantage of, the unparalleled productivity of PowerBuilder’s data access and data manipulation capabilities. In short, PowerBuilder 11 creates as well as consumes .NET resources.

Once PowerBuilder 11 has deployed an application or a component as .NET, the developer can begin taking advantage of external .NET resources on a scripted basis through PowerScript enhancements. The scripted .NET interoperability in PowerBuilder 11 is predicated on a new conditional compilation feature. Conditional compilation allows declarations, references and calls, etc. that are meant for .NET interop to be declared within preprocessor blocks of code. These preprocessor blocks are constructs similar to IF statements. If the developer specifies that these #IF/THEN/#ELSE/#ELSEIF blocks are only for .NET runtime execution, they’re ignored by PowerBuilder’s Win32 compiler.

Conditional Compilation
The developer doesn’t need to commit the syntax of the new constructs to memory or lose his or her train of thought switching from the IDE to a help file. A productive addition to the PowerScript editor enables the developer to quickly paste in the desired flavor of .NET #IF statement (see Figure 1).

The preprocessor variants allow the developer to provide for a blanket .NET deployment condition and, if they wish, to drill down to specific flavors of that deployment like WinForms, WebForm, Web Services, etc. (see Table 1).

Establishing a Reference to the .NET Assembly
Once the developer has identified a .NET resource of which they wish to take advantage, the .NET Assembly in question needs to be brought into the scope of the PowerBuilder .NET target so that script references to it may be made. Whether your PowerBuilder .NET target is for WinForm, WebForm, a .NET Assembly, or a .NET Web Service, right-mouse button-click on that target in the PowerBuilder System Tree and choose “Properties...” from the popup menu (see Figure 2). In the Target Properties window, select the “.NET Assemblies” tab page and click on the button that will allow you to browse for your Assembly. Select your Assembly, then click OK to close the Target Properties window.

For the purposes of this tutorial, I’ve chosen an Assembly that is part of the default .NET framework, MSCORLIB.DLL (see Figure 3). If you wish, expand the Assembly’s node in the System Tree to browse what’s available in the Assembly’s public interface.

More Stories By John Strano

John Strano is a Sybase Technology Evangelist and is a charter member of TeamSybase. He has been using PowerBuilder since 1991 and has authored articles for multiple industry periodicals. John has been a Sybase Certified Instructor and has presented Sybase tools on an international basis since 1997. Over the last 17 years John has developed a variety of PowerBuilder applications from single-user scaling up to enterprise-class, web-based projects.

Comments (1) View Comments

Share your thoughts on this story.

Add your comment
You must be signed in to add a comment. Sign-in | Register

In accordance with our Comment Policy, we encourage comments that are on topic, relevant and to-the-point. We will remove comments that include profanity, personal attacks, racial slurs, threats of violence, or other inappropriate material that violates our Terms and Conditions, and will block users who make repeated violations. We ask all readers to expect diversity of opinion and to treat one another with dignity and respect.


Most Recent Comments
Jerry 07/01/08 11:03:10 AM EDT

Anybody have an example that copies a .NET arraylist to a Powerbuilder datawindow or Listview?