powerbuilder 11: windows forms and.net interoperability jim oneil principal systems consultant...

39
PowerBuilder 11: Windows Forms and .NET Interoperability Jim O’Neil Principal Systems Consultant Sybase, Inc. [email protected]

Upload: hayley-flynn

Post on 28-Mar-2015

239 views

Category:

Documents


5 download

TRANSCRIPT

Page 1: PowerBuilder 11: Windows Forms and.NET Interoperability Jim ONeil Principal Systems Consultant Sybase, Inc. joneil@sybase.com

PowerBuilder 11: Windows Forms and .NET Interoperability

Jim O’NeilPrincipal Systems ConsultantSybase, [email protected]

Page 2: PowerBuilder 11: Windows Forms and.NET Interoperability Jim ONeil Principal Systems Consultant Sybase, Inc. joneil@sybase.com

.NET Assemblies(presented Nov. 13, 2007)

Jim O’NeilSystems Consultant

.NET Assemblies(presented Nov. 13, 2007)

Jim O’NeilSystems Consultant

.NET Web Forms

Dec. 11, 2007

David FishEngineering Evangelist

.NET Web Forms

Dec. 11, 2007

David FishEngineering Evangelist

.NET Windows FormsAnd Interoperability

Dec. 4, 2007

Jim O’NeilSystems Consultant

.NET Windows FormsAnd Interoperability

Dec. 4, 2007

Jim O’NeilSystems Consultant

.NET Smart Client

Jan. 15, 2008

John StranoTechnology Evangelist

.NET Smart Client

Jan. 15, 2008

John StranoTechnology Evangelist

Web ServiceDataWindow

Feb. 5, 2008

David AveraStaff Software Engineer

Web ServiceDataWindow

Feb. 5, 2008

David AveraStaff Software Engineer

PowerBuilder 11 Overview

(presented Nov. 20, 2007)

Jim O’NeilSystems Consultant

PowerBuilder 11 Overview

(presented Nov. 20, 2007)

Jim O’NeilSystems Consultant

.NET Web Services

Jan. 29, 2008

David FishEngineering Evangelist

.NET Web Services

Jan. 29, 2008

David FishEngineering Evangelist

PowerBuilder 11.NET DeploymentWeb Casts

Page 3: PowerBuilder 11: Windows Forms and.NET Interoperability Jim ONeil Principal Systems Consultant Sybase, Inc. joneil@sybase.com

Agenda

• PowerBuilder roadmap

• Windows Forms overview

• Deploying Windows Forms applications

• Distributing Windows Forms applications

• .NET interoperability

Page 4: PowerBuilder 11: Windows Forms and.NET Interoperability Jim ONeil Principal Systems Consultant Sybase, Inc. joneil@sybase.com

PowerBuilder Roadmap

• Version 11 released in June 2007

• 11.1 Maintenance Release in November 2007

• Delivers on third-phase of PowerBuilder’s .NET initiative

Page 5: PowerBuilder 11: Windows Forms and.NET Interoperability Jim ONeil Principal Systems Consultant Sybase, Inc. joneil@sybase.com

Language Independence

ApplicationConnectivity

MultiplePlatformSupport

PowerAnd

Performance

2009PowerBuilder 12

• .NET in IDE• WPF/WCF support at

design and run-time• Fully managed code

at deployment• Complete .NET

interoperability

2008PowerBuilder 11.2

• AJAX support for Web Forms Applications

• EAServer .NET Client Support

• Miscellaneous fixes

2008PowerBuilder 11.5

• Core .NET enhancements

• Native DataWindow updates

• Updated database support

• Miscellaneous fixes

Page 6: PowerBuilder 11: Windows Forms and.NET Interoperability Jim ONeil Principal Systems Consultant Sybase, Inc. joneil@sybase.com

Windows Forms Overview

10

Page 7: PowerBuilder 11: Windows Forms and.NET Interoperability Jim ONeil Principal Systems Consultant Sybase, Inc. joneil@sybase.com

Windows Forms Definition (Microsoft)

• What is a Windows Forms application?“Windows Forms is for creating Microsoft Windows applications on the .NET Framework. This framework provides a modern, object-oriented, extensible set of classes that enable you to develop rich Windows-based applications. With Windows Forms, you are able to create a rich client application that can access a wide variety of data sources and provide data-display and data-editing facilities using Windows Forms controls.”

Win32 ApplicationWindows Forms Application

System.Windows.Forms

System.DrawingSystem.Windows.

Forms.VisualStyles

System.ComponentModel

KERNEL32.DLL USER32.DLLGDI32.DLL

GDIPLUS.DLL

MSCOREE.DLL (CLR)

KERNEL32.DLL USER32.DLL GDIPLUS.DLL

Page 8: PowerBuilder 11: Windows Forms and.NET Interoperability Jim ONeil Principal Systems Consultant Sybase, Inc. joneil@sybase.com

Windows Forms Definition (English)

• What is a Windows Forms application?

Windows Forms applications are an evolution of the Win32-based application development you know and love

• and, why should you care– Win32 will go away, eventually

– For PowerBuilder users, Windows Forms is a prerequisite for

• Smart Client capabilities

• .NET interoperability

Page 9: PowerBuilder 11: Windows Forms and.NET Interoperability Jim ONeil Principal Systems Consultant Sybase, Inc. joneil@sybase.com

Deploying Windows Forms Applications

10

Page 10: PowerBuilder 11: Windows Forms and.NET Interoperability Jim ONeil Principal Systems Consultant Sybase, Inc. joneil@sybase.com

Developing Windows Forms Applications

• Obvious relationship to traditional PowerBuilder applications generally means a smooth transition– Same UI paradigms

– Same event model

• New Windows Forms wizard quickly creates requisite project and target– New application

– Existing application leveragingsame code base

Page 11: PowerBuilder 11: Windows Forms and.NET Interoperability Jim ONeil Principal Systems Consultant Sybase, Inc. joneil@sybase.com

Windows Forms Project Object

11.1

Page 12: PowerBuilder 11: Windows Forms and.NET Interoperability Jim ONeil Principal Systems Consultant Sybase, Inc. joneil@sybase.com

.NET EXE orAssembly

CSC

PowerBuilder .NET Deployment

Syntax errors

save/build

C#translation

deploy

Unsupportedfeatures

PB2CS

PowerBuilder System LibraryFor .NET

(managed code)

DataWindow EngineDatabase Interfaces(unmanaged code)

PowerScriptSource

PBDs(DataWindow objects,

Pipelines, Queries)

Page 13: PowerBuilder 11: Windows Forms and.NET Interoperability Jim ONeil Principal Systems Consultant Sybase, Inc. joneil@sybase.com

Windows Forms Deployment

• Executable files and resources written to “Output path”

• Intermediate files written to .pbt_build directory

source code directory

.exe directory (Output path)

files supporting incremental rebuild

Page 14: PowerBuilder 11: Windows Forms and.NET Interoperability Jim ONeil Principal Systems Consultant Sybase, Inc. joneil@sybase.com

Unsupported Features

• “Native” PowerBuilder constructs unsupported in Windows Forms applications– PBNI extensions (excluding Web Services)

– Shared objects

– OLE automation server

– Tracing and profiling

– Dynamic Data Exchange (DDE)

– Garbage collection functions

– EAServer client support (coming in 11.2 with EAServer 6.1)

• Use of .NET visual classes

Page 15: PowerBuilder 11: Windows Forms and.NET Interoperability Jim ONeil Principal Systems Consultant Sybase, Inc. joneil@sybase.com

Partially Supported Features

• “Native” PowerBuilder constructs partially supported in Windows Forms applications– Rich Text and OLE DataWindow styles

– In-process OLE controls (ActiveX)

• Limited event support

• Requires wrapper class generated using .NET utility

– Non TrueType fonts replaced with TrueType fonts

• Font-substitution display impact

• Unexpected cursor display (e.g., invisible in EditMask control)

– ALL visual controls are supported to varying degrees with exception of

• Other event

• IMEMode property (Japanese version only!)

Page 16: PowerBuilder 11: Windows Forms and.NET Interoperability Jim ONeil Principal Systems Consultant Sybase, Inc. joneil@sybase.com

Language Construct Caveats

• Partially supported syntax– GOTO statement – disallowed when target label is out of ‘scope’

– Invoking an indirect ancestor event – results in unexpected behavior

IF y = 7 THEN GOTO aIF x = 10 THENy = 5

a: z = 2ELSEy = 8z = 3

END IF

w_1

w_2

w_3

w_1::EVENT foo()w_1::EVENT foo()

Win32 .NET

Page 17: PowerBuilder 11: Windows Forms and.NET Interoperability Jim ONeil Principal Systems Consultant Sybase, Inc. joneil@sybase.com

Language Construct Caveats

• Questionable practices allowed in “native” PowerBuilder applications but disallowed in .NET deployments– this keyword in global functions – RETURN statement in FINALLY clause

– Overloading event signatures

– Overriding function access scope

– Object casting outside of object hierarchy

Page 18: PowerBuilder 11: Windows Forms and.NET Interoperability Jim ONeil Principal Systems Consultant Sybase, Inc. joneil@sybase.com

Language Construct Caveats (concluded)

• External function calls– Generic STRUCTURE argument type unsupported

– Requirement to pass structure arguments by reference when argument is a const pointer

– Requirement to re-initialize reference string arguments for each invocation

Page 19: PowerBuilder 11: Windows Forms and.NET Interoperability Jim ONeil Principal Systems Consultant Sybase, Inc. joneil@sybase.com

Distributing Windows Forms Applications

10

Page 20: PowerBuilder 11: Windows Forms and.NET Interoperability Jim ONeil Principal Systems Consultant Sybase, Inc. joneil@sybase.com

Distributing Windows Forms Applications

• Required files

• Runtime packager

• Smart Client

Page 21: PowerBuilder 11: Windows Forms and.NET Interoperability Jim ONeil Principal Systems Consultant Sybase, Inc. joneil@sybase.com

Required Files

• .NET Framework 2.0

• Microsoft Runtime Files

• PowerBuilder System Library for .NET

• PowerBuilder Runtime Dynamic Link Libraries

• Application files

Page 22: PowerBuilder 11: Windows Forms and.NET Interoperability Jim ONeil Principal Systems Consultant Sybase, Inc. joneil@sybase.com

Required Files

• .NET Framework 2.0– Redistributable package (dotnetfx.exe)

– SDK not required

– .NET Framework 3.0 extended 2.0 with additional features so fulfills the requirement

Page 23: PowerBuilder 11: Windows Forms and.NET Interoperability Jim ONeil Principal Systems Consultant Sybase, Inc. joneil@sybase.com

Required Files

• Microsoft Runtime Files– msvcr71.dll – msvcp71.dll – atl71.dll

Page 24: PowerBuilder 11: Windows Forms and.NET Interoperability Jim ONeil Principal Systems Consultant Sybase, Inc. joneil@sybase.com

Required Files

• PowerBuilder System Library for .NET– Sybase.PowerBuilder assemblies

– Strongly-named so installable to Global Assembly Cache (GAC)

Sybase.PowerBuilder.Common.dll Sybase.PowerBuilder.Core.dll

Sybase.PowerBuilder.Interop.dll Sybase.PowerBuilder.Win.dll

All Windows Forms applications

Sybase.PowerBuilder.DataWindow.Win.dll Sybase.PowerBuilder.DataWindow.Interop.dll

Applications using DataWindows/DataStores

Sybase.PowerBuilder.Graph.Win.dll Sybase.PowerBuilder.Graph.Core.dll

Sybase.PowerBuilder.Graph.Interop.dll

Applications using graphs

…using EditMasks

…using RichText

…using Web Services

Page 25: PowerBuilder 11: Windows Forms and.NET Interoperability Jim ONeil Principal Systems Consultant Sybase, Inc. joneil@sybase.com

Required Files

• PowerBuilder Runtime Dynamic Link Libraries– Unmanaged code DLLs

• PBDWM110.DLL: DataWindow engine• PBSHR110.DLL: Utility and memory management routines• PBXERCES110.DLL: XML DataWindow import/export• PBxxx110.DLL: Database drivers• …

– Must reside on system path

Page 26: PowerBuilder 11: Windows Forms and.NET Interoperability Jim ONeil Principal Systems Consultant Sybase, Inc. joneil@sybase.com

Required Files

• Application files– Application executable assembly (.exe)

– Configuration file (.config)

– Manifest file (.manifest)

– DataWindow libraries (.pbd)

– Resource files (images, INI files, etc.)

– Referenced external libraries (DLLs, OCXs, etc.)

Page 27: PowerBuilder 11: Windows Forms and.NET Interoperability Jim ONeil Principal Systems Consultant Sybase, Inc. joneil@sybase.com

Runtime Packager

Page 28: PowerBuilder 11: Windows Forms and.NET Interoperability Jim ONeil Principal Systems Consultant Sybase, Inc. joneil@sybase.com

Runtime Packager

• Creates MSI file containing system files relating to selected functionality

• Registers self-registering DLLs

• Sets PATH variable

• Adds destination path to registry

• Adds PowerBuilder System assemblies to GAC

What’s missing?

1. .NET Framework 2.02. Application specific files

Page 29: PowerBuilder 11: Windows Forms and.NET Interoperability Jim ONeil Principal Systems Consultant Sybase, Inc. joneil@sybase.com

Smart Client

“Publish” application to a central locationAccess application from that locationApplication installs and runs locally

Details from John Strano on Jan. 15th!!

“Publish” application to a central locationAccess application from that locationApplication installs and runs locally

Details from John Strano on Jan. 15th!!

Page 30: PowerBuilder 11: Windows Forms and.NET Interoperability Jim ONeil Principal Systems Consultant Sybase, Inc. joneil@sybase.com

.NET Interoperability

10

Page 31: PowerBuilder 11: Windows Forms and.NET Interoperability Jim ONeil Principal Systems Consultant Sybase, Inc. joneil@sybase.com

.NET Interoperability

• Support for invocation of .NET non-visual classes in PowerBuilder .NET applications– Windows Forms

– Web Forms

– .NET Assemblies

– Web Services

String netVersionSystem.Reflection.Assembly assembly

assembly = System.Reflection.Assembly.GetCallingAssembly()netVersion = assembly.ImageRuntimeVersion

String netVersionSystem.Reflection.Assembly assembly

assembly = System.Reflection.Assembly.GetCallingAssembly()netVersion = assembly.ImageRuntimeVersion

Page 32: PowerBuilder 11: Windows Forms and.NET Interoperability Jim ONeil Principal Systems Consultant Sybase, Inc. joneil@sybase.com

Conditional Compilation Code Blocks

• New construct used to delineate .NET invocations– #IF DEFINED PBDOTNET…

– #IF DEFINED PBWEBFORM…

– #IF DEFINED PBWINFORM…

– #IF DEFINED PBWEBSERVICE…

• Code blocks can contain…– “Classic” PowerScript

– PowerScript extensions

• Code block contents examined only at deployment time– No syntax checking when saving object

– Non-applicable code blocks not compiled into target image

Page 33: PowerBuilder 11: Windows Forms and.NET Interoperability Jim ONeil Principal Systems Consultant Sybase, Inc. joneil@sybase.com

PowerScript Enhancements Supporting Interoperability

• Parameterized constructor syntax

• Static method invocation

• Bitwise operators (viz., AND, OR, NOT, XOR)

• Non-integral array indexers (e.g., population[“Argentina”] = 40500000)

• Capability to reference .NET constructs– Namespaces

– Interfaces

– Enumerations

Page 34: PowerBuilder 11: Windows Forms and.NET Interoperability Jim ONeil Principal Systems Consultant Sybase, Inc. joneil@sybase.com

Current .NET Interoperability Restrictions

• Only non-visual classes are supported

• Generic and nullable types not supported

• Method calls allowed only on classes

• .NET types converted to equivalent PowerBuilder base types, for example, following code will not compile in PowerBuilder

System.Int32 x

x = 5

MessageBox(“Value”, x.ToString())

• Array basis is 1 in PowerBuilder, 0 in .NET

• Limited IDE support

Page 35: PowerBuilder 11: Windows Forms and.NET Interoperability Jim ONeil Principal Systems Consultant Sybase, Inc. joneil@sybase.com

Adding .NET References

• Add references to .NET assemblies via Target Properties

Page 36: PowerBuilder 11: Windows Forms and.NET Interoperability Jim ONeil Principal Systems Consultant Sybase, Inc. joneil@sybase.com

.NET Assemblies in System Tree

Class and methodsClass and methods

EnumerationEnumeration

Page 37: PowerBuilder 11: Windows Forms and.NET Interoperability Jim ONeil Principal Systems Consultant Sybase, Inc. joneil@sybase.com

.NET Interoperability Code Snippet

#if defined PBDOTNET then

String netVersion

System.Reflection.Assembly assembly

assembly = System.Reflection.Assembly.GetCallingAssembly()

netVersion = assembly.ImageRuntimeVersion

st_netVersion.text = ".NET Version: " + Right(netVersion, Len(netVersion) - 1)

#if defined PBWEBFORM then

String browserVersion

System.Web.HttpRequest request

request = System.Web.HttpContext.Current.Request

browserVersion = request.Browser.Browser + " " + &

String(request.Browser.MajorVersion) + "." + &

String(request.Browser.MinorVersion)

st_browserVersion.text = "Client Browser: " + browserVersion

#end if

#end if

Page 38: PowerBuilder 11: Windows Forms and.NET Interoperability Jim ONeil Principal Systems Consultant Sybase, Inc. joneil@sybase.com

Upcoming PowerBuilder Events

• ISUG “Leveraging PowerBuilder in the .NET World”– Day-long, hands-on training event

– Multiple cities in North America through December

– Visit http://www.isug.com/pb11tour for details

• Sybase web casts– Web Forms (Dec 11th)

– Smart Client (Jan 15th)

– Web Services Deployment (Jan 29th)

– Web Services DataWindow (Feb 5th)

– Visit http://response.sybase.com/forms/pbregistration to sign-up!!

Final Week of Tour!Dec. 11 – OrlandoDec. 12 – DC (Dulles)Dec. 13 – Atlanta

Final Week of Tour!Dec. 11 – OrlandoDec. 12 – DC (Dulles)Dec. 13 – Atlanta

Page 39: PowerBuilder 11: Windows Forms and.NET Interoperability Jim ONeil Principal Systems Consultant Sybase, Inc. joneil@sybase.com

Q&A