Download presentation
Presentation is loading. Please wait.
1
Bruce Armstrong TeamSybase bruce.armstrong@teamsybase.com
2
Techniques PowerBuilder 11 and beyond only Referencing.Net assemblies directly within Conditional Code blocks in PowerScript Any version of PowerBuilder.Net Interop via COM Callable Wrappers
3
Referencing.Net Assemblies Currently only non-visual assemblies Visual assemblies is a release milestone for PowerBuilder 12 Conditional Code blocks AutoScript is not supported (errors are reported at compile time) Syntax is neither PowerScript or C# but a mix of them (PowerScript#)
4
.Net Interop Runtime Callable Wrapper COM Callable Wrapper
5
Allows a.Net application to use a Win32 COM object Runtime Callable Wrapper COM Object Runtime Callable Wrapper.Net Application http://msdn.microsoft.com/en-us/library/8bwh56xe.aspx
6
Allows a Win32 application to use a.Net object via COM COM Callable Wrapper.Net Object COM Callable Wrapper Win32 Application http://msdn.microsoft.com/en-us/library/f07c8z1c.aspx
7
COM Callable Wrapper Assembly has to be COM-Visible Assembly can be marked such at compile time FxCop can be used to determine if marked ILSASM/ILASM can be used (in some cases) to change the marking
8
COM Callable Wrapper Marking the Assembly COM-Visible in Visual Studio
9
Using FxCop Examining the COM-Visible attribute using Microsoft’s FxCop http://msdn.microsoft.com/en-us/library/bb429476(VS.80).aspx
10
ILDASM ILASM (IL Assembler) is part of the.Net runtime Typical location: C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727 In the System Path ILDASM (IL Disassembler) is part of the.Net SDK Typical Location: C:\Program Files\Microsoft.NET\SDK\v2.0\Bin May not be in the System Path
11
Using ILDASM Examining the COM-Visible attribute in the disassembled IL
12
REGASM .Net Assembly Registration Utility Used to create COM registry entries for.Net component Syntax: RegAsm AssemblyName [Options] Options: /unregister /regfile[:FileName] /codebase
13
REGASM Output With regfile option but without codebase option
14
REGASM Output With regfile option and codebase option
15
Registry Free COM Not.Net specific, can be used for any COM components Supported on Windows version XP and later (e.g., 2003, Vista, 2008) http://msdn.microsoft.com/en- us/library/ms973913.aspx http://msdn.microsoft.com/en- us/library/ms973913.aspx
16
How Registry Free COM Works Client App Client App.Manifest Dependant Assembly (COM Component) Dependant Assembly.Manifest
17
GenMan32 Useful utility for generating manifest files for Registry Free COM Syntax: GenMan32 AssemblyName [Options] Options: /add /out:filename http://blogs.msdn.com/junfeng/archive/2007/04/14/genman32-a-tool-to- generate-sxs-manifest-for-managed-assembly-for-registration-free-com-net- interop.aspx http://blogs.msdn.com/junfeng/archive/2007/04/14/genman32-a-tool-to- generate-sxs-manifest-for-managed-assembly-for-registration-free-com-net- interop.aspx
18
GenMan32 Output
19
CCW Limitations Types, methods, properties, fields and events must all be public Methods must not be static Types must have a public default constructor Overloaded methods should be avoided Late binding clients can’t retrieve error information from.Net exceptions PowerBuilder Specific: Events
20
Avoid Overloaded Methods.Net Class foo ( int a ) foo ( string a ) foo ( long a ) COM Wrapper foo (int a ) foo_2 ( string a ) foo_3 ( long a )
21
Why error information gets lost PowerBuilder Client CCW.Net Assembly IDispatch Exception 3. Exception Thrown 4.SetErrorInfo 5. GetErrorInfo 1. COM Call 2..Net Call 6. Return from call
22
What we can do about it Managed Exception Logger Exception Publisher Event Log Debug Window Managed Exception Queue CCW IDispatch Exception
23
Further Reading Microsoft’s Exception Handling Application Block http://msdn.microsoft.com/en- us/library/cc511522.aspx Get Seamless.NET Exception Logging From COM Clients Without Modifying Your Code http://msdn.microsoft.com/en- us/magazine/cc188710.aspx
24
Interop Forms Toolkit 2.0 Not just forms, but controls as well http://msdn.microsoft.com/en- us/vbasic/bb419144.aspx http://msdn.microsoft.com/en- us/vbasic/bb419144.aspx Can be used in the Express versions of Visual Studio with some limitations C# implementation available on CodeProject http://www.codeproject.com/KB/dotnet/VB6_ -_C__Interop_Form.aspx http://www.codeproject.com/KB/dotnet/VB6_ -_C__Interop_Form.aspx
25
Supporting Events Create a Interface of type ComInterfaceType.InterfaceIsIDispatch with the defined events Provide a GUID for the interface Assign a unique DispID for each event Add a ComSourceInterfaces attribute to the control Define the events within the control Call those events from within the user control http://www.15seconds.com/issue/060309.htm
26
Event Declaration Interface
27
Implementing Events
28
Events exposed in PowerBuilder
29
Questions
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.