Team Developer and.net

Similar documents
JNBridgePro Evaluation and Quick Start Guide

Using COM and COM+ in.net -P/invoke: The mechanism to call unmanaged functions in Win32 DLLs from.net

.NET CLR Framework. Unmanaged Hosts - Assembly Access

ASP/COM+ Web Development Using Team Developer

Introduction to C++/CLI 3. What C++/CLI can do for you 6 The rationale behind the new syntax Hello World in C++/CLI 13

Solution overview VISUAL COBOL BUSINESS CHALLENGE SOLUTION OVERVIEW BUSINESS BENEFIT

Introduction to.net Framework

Overview of the Microsoft.NET Framework

Department of Computer Applications

Authoring Installations for Microsoft s.net Framework

CHAPTER 7 COM and.net

Solutions Business Manager. Path to Production for Enterprises

A Component s Road. to.net. Any Chart, Anywhere! Chart FX Internet. Chart FX Client Server. Chart FX Financial. Image Toppings. WebBar FX.

Chapter 1:- Introduction to.net. Compiled By:- Ankit Shah Assistant Professor, SVBIT.

Kansas TRCC. Kansas ecitation Validation Engine Design

Learn to develop.net applications and master related technologies.

Windows 8. Rainer Stropek. System Architecture. System Architecture re of Windows Store Apps. Saves the day. software architects gmbh

Oracle Tuxedo. Using the Tuxedo.NET Workstation Client 12c Release 1 (12.1.1) June 2012

Introduction to.net Framework and Visual Studio 2013 IDE MIT 31043, Rapid Application Development By: S. Sabraz Nawaz

A NET Refresher

Chapter 12 Microsoft Assemblies. Software Architecture Microsoft Assemblies 1

.NET. Inf 5040, Outline. Gyrd Brændeland, Sharath Babu Musunoori, Åshild Grønstad Solheim

Microsoft.NET Programming (C#, ASP.NET,ADO.NET, VB.NET, Crystal Report, Sql Server) Goal: Make the learner proficient in the usage of MS Technologies

New programming language introduced by Microsoft contained in its.net technology Uses many of the best features of C++, Java, Visual Basic, and other

Developing Microsoft.NET Applications for Windows (Visual Basic.NET)

Brochure. Visual COBOL. Visual COBOL

Cookbook for using SQL Server DTS 2000 with.net

Introduction to.net Framework and Visual Studio 2013 IDE MIT 31043, Visual Programming By: S. Sabraz Nawaz

Team Developer. There are no good reasons to stay in legacy mode.

Optimizing Database Connection Performance

SUSE Linux Enterprise Mono Extension

Using the TekScope IVI-COM Driver from C#.NET

RingCentral for MINDBODY. User Guide

Introduction To Web Architecture

Part I: Programming Access Applications. Chapter 1: Overview of Programming for Access. Chapter 2: Extending Applications Using the Windows API

SilkPerformer NET Explorer Help

Developer Studio FREQUENTLY ASKED QUESTIONS

CTCopc CONTROL TECHNOLOGY CORPORATION. CTCopc Reference. CTCopc. Reference

COPYRIGHTED MATERIAL PART I. CHAPTER 1: Introducing C# CHAPTER 2: Writing a C# Program. CHAPTER 3: Variables and Expressions. CHAPTER 4: Flow Control

Microsoft Visual Basic 2005: Reloaded

Microsoft Visual Studio Add-In Users Guide

Extreme Installers: Slash The.NET Runtime Size in Half, Register Users Online

C++/CLI in Action NISHANT SIVAKUMAR MANNING. Greenwich (74 w. long.)

The C# Programming Language. Overview

Introduction to Mobile Development

Building Windows Applications with.net. Allan Laframboise Shelly Gill

IBM Rational Rose XDE Developer

.NET Assemblies in Gupta TD 6

OUTLINE DELPHI 2005 FOR.NET JUMP START

Walkthrough Using the New CLR Interop Feature of Microsoft Dynamics AX

Demo: Controlling.NET Windows Forms from a Java Application. Version 8.2

COM+ OVERVIEW OF MICROSOFTS COM, DCOM AND COM+ COMPONENT TECHNOLOGIES DCOM - COM+ Peter R. Egli peteregli.net. peteregli.net. 1/20 Rev. 1.

.Net Interview Questions

Appendix G: Writing Managed C++ Code for the.net Framework

Saikat Banerjee Page 1

Introducing Borland Delphi 8

Demo: Calling a.net Logging Package from Java. Version 8.2

Introduction to.net Framework Week 1. Tahir Nawaz

Oracle WebLogic Portal O R A C L E S T A T EM EN T O F D I R E C T IO N F E B R U A R Y 2016

Migrate Your Skills to Microsoft.NET Framework 2.0 and 3.0 using Visual Studio 2005 (C#)

Introducing SAP Enterprise Services Explorer for Microsoft.NET

Creating a Service Platform for.net. Clement Escoffier PhD Student University of Grenoble

JNBridgePro Users Guide

Analysis of the Benchmark while Extracting Data from Database or XML File for Different Platforms

2. A GUI A. uses buttons, menus, and icons B. should be easy for a user to manipulate C. both (a) and (b) D. stands for Graphic Use Interaction

Developing Microsoft.NET Applications for Windows (Visual C#.NET)

Server Technology Web Based Service Oriented Architecture for Mobile Augmented Reality System

vtuplanet.com C#Programming with.net C# Programming With.NET (06CS/IS761)

Demo: Calling a Java Logging Package from.net. Version 8.2

TEAM DEVELOPER. Report Builder EDP New & Changed Features. Product Version 6.3

BEATuxedo. Using the Tuxedo.NET Workstation Client

Introducing C# and the.net Framework

Getting Started Guide

Oracle WebCenter Suite Integrating Secure Enterprise Search

UNIT 1. Introduction to Microsoft.NET framework and Basics of VB.Net

Getting Started. 1 by Conner Irwin

Vision V sion o n I n n 1975 V sion o n T o T d o a d y A c o c m o pu p t u er e o n o n e v e e v r e y E po p w o er e p e p o e p o l p e

IBM WebSphere Message Broker for z/os V6.1 delivers the enterprise service bus built for connectivity and transformation

Introduction to.net. The path. The Distributed Group University of Seville Spain - España. Introduction The elements of.net. Assessments Conclusions

Introducing C# After this discussion, we'll move on to a simple description of C# itself, including its origins and similarities to C++.

Developing Microsoft.NET Applications for Windows (Visual Basic.NET)

Crystal Reports XI Release 2

Demo: Integrating a.net-based user interface with a Java back end. Version 8.2

To get started with Visual Basic 2005, I recommend that you jump right in

Go paperless by using OneNote 2013

TOPLink for WebLogic. Whitepaper. The Challenge: The Solution:

Developing Desktop Apps for Ultrabook Devices in Windows 8*: Getting Started

Unit 1: Visual Basic.NET and the.net Framework

Why bother / who cares?

Getting Started with the JNBridgePro Plug-ins for Visual Studio and Eclipse

Crystal Reports 10 and.net

Symantec Network Access Control Starter Edition

The C# Language PART I. CHAPTER 1: Introducing C# CHAPTER 2: Writing a C# Program. CHAPTER 3: Variables and Expressions. CHAPTER 4: Flow Control

A Look at Borland C#Builder from the Delphi Developers View

TD Mobile. New and Changed Features. Product Version 2.0.2

Programming in Visual Basic with Microsoft Visual Studio 2010

HPE.NET Add-in Extensibility

Managing Server Resources in ArcGIS

Creating a Course Web Site

Visual Studio.NET for AutoCAD Programmers

Transcription:

Team Developer and.net Unify Corporation

Table of Contents Abstract...3 PART I - Consuming Team Developer Code from VB.NET...6 PART II - Consuming a VB.NET Assembly from Team Developer...8 Conclusion...11 Requirements:...11 2

Abstract Within the next few years, most shops will run a lot of Team Developer code along with a growing amount of Microsoft.NET code. You can make these two code bases interoperate as well as possible, using the.net runtime s interoperability services. These let you write.net (like VB.NET) applications that use existing Team Developer COM Objects, and they allow you write Team Developer apps that use DLLs created with VB.NET. You can create.net applications that leverage your existing investment in COM components, and you can migrate a Team Developer DLL to VB.NET and still access its functionality from Team Developer apps. Performance Implications I will introduce some key concepts about how the system marshals data between COM and.net platforms, and how that can impact performance. When code on either platform calls a method on an object running on the other platform, the method call requires marshalling. In marshalling, the.net Interop services package up the method call, transfer it to the other platform, invoke the method, package up the results - then transfer them back to your original platform (see Figure 1). This causes a performance hit as the marshalling process moves the parameters from one platform to the other. Figure 1 This performance hit will vary depending on the data types of your parameters and result types. Performance is best when you re moving around simple numeric data, such as 32-bit integers. These are isomorphic data types, which are represented in memory the same way on both platforms. Consequently, Interop with them proceeds almost as quickly as regular method calls. You can simply copy, isomorphic data from COM memory to.net memory (or vice versa). 3

The Team Developer isomorphic data types are the Number and String. Onedimensional arrays of isomorphic types are isomorphic, as long as they comprise only isomorphic types. Other types of data require more work during the marshalling process because they aren t represented the same in.net and COM. Data types such as Boolean are nonisomorphic and might require conversion from one format to another and some extra cycles as they re copied from one platform to another. Marshalling The.NET Interop services provide four types of marshalling. Of these, only Type I marshalling is supported automatically by Interop services and Visual Studio.NET (VS.NET). If you need to convert from one data type to another, pass complex data as a single value (such as a Variant) or represent one type of object as a different object. You ll need to implement one of the other types of marshalling by hand by editing the Microsoft Intermediate Language (MSIL) code in Notepad, among other things. As long as you use data types supported by Type I marshalling, calling a Team Developer COM Object from a VB.NET application and vice versa is speedy and virtually transparent. So avoid using the Variant data type if you can, because that s typically where you run into issues. I ll show you how to use Type I marshalling because you ll most likely use this type in your applications. Differences Between.NET Framework and COM Framework The.NET framework object model and its workings are different from Component Object Model (COM) and its workings. For example, clients of.net components don t have to worry about the lifetime of the object. Common Language Runtime (CLR) manages things for them. In contrast, clients of COM objects must take care of the lifetime of the object. Similarly,.NET objects live in the memory space that is managed by CLR. CLR can move objects around in the memory for performance reasons and update the references of objects accordingly, but COM object clients have the actual address of the object and depend on the object to stay on the same memory location..net runtime provides many new features and constructs to managed components. For example,.net components can have parameterized constructors, functions of the components can have accessibility attributes (like public, protected, internal, and others) associated with them, and components can also have static methods. Apart from these features, there are many others. These include those that are not accessible to COM clients because standard implementation of COM does not recognize these features. Therefore.NET runtime must put something in between the two,.net server and COM client, to act as mediator. 4

The.NET And COM Mediator The.NET runtime provides COM Interoperability wrappers for overcoming the differences between.net and COM environments. For example, runtime creates an instance of COM Callable Wrapper (CCW) when a COM client accesses a.net component. In the same way, an instance of Runtime Callable Wrapper (RCW) is created when a.net client accesses a COM component. These wrappers abstract the differences and provide the seamless integration between the two environments. Figure 2 illustrates CCW and RCW. Figure 2 5

PART I Consuming Team Developer Code from VB.NET VS.NET lets you reference and use COM DLLs much as you reference and use.net DLLs. Start by creating a simple Team Developer COM DLL, as illustrated in Figure 3. Figure 3 When you build the project, you get a simple DLL that returns a text value. You can use this DLL transparently from.net because Type I marshalling supports both data types. Before you can use any DLL in VB.NET, you need to add a reference to it in your project. This holds true for both.net DLLs and COM DLLs, and VS.NET allows you to add references to both types of DLLs from the same dialog. In VS.NET, use the Project Add Reference menu option to bring up the Add Reference dialog. Click on the COM tab, which gives you a list of all the COM components registered currently on your system. Scroll down and select the COMObject entry (see Figure 4). 6

Figure 4 VS.NET creates a runtime callable wrapper (RCW) assembly automatically when you click on OK. This important step occurs behind the scenes. The RCW is a.net assembly that your.net code sees much like a COM DLL. When you write code that calls the COMObject component, your code is really calling the RCW, which then calls the underlying COM component on your behalf. The RCW takes care of the marshalling process, making the actual call from the.net platform over to the COM platform. It can also let you share COM components among many.net apps. Add a TextBox control and a Button control to the form, then double-click on the Button control to bring up the code window. Add this code within the Click event: This code creates an instance of the COMObject component, then calls the method on that object to populate the display. The code then calls Marshal.ReleaseComObject to release the reference to the underlying COM object. You do the same thing when you call Object.Release() in Team Developer because 7

COM objects are destroyed when they re released, and they expect to be released as soon as you re done using them. On the other hand, objects in VB.NET aren t destroyed until the.net garbage collection algorithm gets around to it. By calling ReleaseComObject, you force.net to more closely simulate the behaviour of COM always a good idea when working with COM objects. Before this code will work, you need to add an Imports statement to the top of the file: This provides the namespace where the Marshal class resides. Now you can run the application and click on the button. The form should then display the data retrieved from the Team Developer COM DLL (see Figure 5). Figure 5 PART II Consuming a VB.NET Assembly from Team Developer You ll find it nearly as easy to reverse the process. Of course, without your intervention, a COM-based client such as a Team Developer app won t be able to use a VB.NET DLL. This takes only a few steps to accomplish, though. In VS.NET, create a new Class Library project named ManagedClass. Remove the template code from the Class1.vb file and write this code, and then rename Class1.vb to ManagedClass.vb: 8

This code provides the same functionality as the COM DLL you created earlier to make it available to Team Developer. Use the <InterfaceTypeAttribute()> attribute to mark the managed INETInterface as IDispatch only when exposed to COM. Of course, COM relies on globally unique identifiers (GUIDs) to identify your class. If you don t specify them,.net will create some for you automatically. You must mark the project itself so VS.NET registers the DLL with COM. Rightclick on the ManagedClass project in the Solution Explorer and select Properties. Click on Configuration Properties and Build in the left-hand pane, and check the option named Register for COM Interop (see Figure 6). Figure 6 With this option checked, VS.NET creates a COM-callable wrapper (CCW) and a COM type library for your class the next time you build the solution. VS.NET also 9

registers the DLL in the Windows Registry, making it available to Team Developer. All this goes on under the hood the only visible indication is a line in the Output window. The CCW resembles the RCW that VS.NET created for you earlier. This assembly handles the marshalling and all the details that let a COM client app invoke your VB.NET object. Build the project to create the DLL, then open the Team Developer IDE. Save the project as.netclient.apt. Open the ActiveX Explorer and locate the ManagedClass component. You can generate the SAL proxy just as you would for any COM component (see Figure 7). Figure 7 Now add the Common Language Runtime Library.apl to the Libraries section. Create a new Form Window and add a Data Field and Pushbutton to the Form Window. Create an instance of INETInterface and add the following code to the Pushbutton: Finally, run the app and click on the button. The display should show the value retrieved from the VB.NET assembly (see Figure 8). 10

Figure 8 Conclusion This is what we need to do to access.net components from unmanaged code. If you want to develop some of your application components in.net, you should consider that many of the features of.net components are not exposed to COM clients. This will require some design-time decisions and may affect the way you design your object hierarchies (because inheritance hierarchy of.net components is flattened for COM clients)..net s Interop services deliver a useful and usually simple way to reuse existing Team Developer COM Objects from VB.NET, and to use VB.NET DLLs from Team Developer as you migrate your components over time. In most cases, Interop services do all the hard work for you, and VS.NET often automates the process. If you re creating multithreaded.net apps or passing complex data types through Variants, things can get complex and you ll need to do more work by hand. Requirements SQLWindows 2.1 or above The included Common Language Runtime Library.apl Visual Studio.NET 11

About Unify Unify is a global provider of software development technology and solutions that helps IT customers participate in Service-Oriented Architecture (SOA). Unify s productive and re-liable development tools, migration solutions and databases enable organizations to build and modernize business essential applications for SOA. Composer for Lotus Notes offers a complete, like for like, production to production migration solution for Lotus Notes applications. Unify s award-winning NXJ Developer enables IT teams to be extremely productive, learn new technologies fast and deliver Web services-based applications on time and on budget. The Team Developer, SQLBase, DataServer, ACCELL and VISION product families enable cross-platform rapid development on Java/J2EE, Linux or Windows. Unify has a rich heritage in delivering rich, cost-effective technologies to its thousands of IT customers and ISV, VAR and distributor partners. Unify is headquartered in Sacramento, Calif., and can be reached at (916) 928-6400 or by visiting www.unify.com. Unify Corporation 2101 Arena Blvd., Suite 100 Sacramento, CA 95834 USA Phone: 1.916.928.6400 Toll Free: 1.800.468.6439 Fax: 1.916.928.6404 Munich: +49 8 115 55430 United Kingdom: +44 (0)1753 245 510 France: +33 (0)1 34 58 28 30 COPYRIGHT 2007. UNIFY CORPORATION. All rights reserved. Unify, the Unify logo and Unify NXJ are registered trademarks of Unify Corporation. Composer is a trademark of Unify Corporation. Java and J2EE are the trademarks or registered trademarks of Sun Microsystems, Inc. in the United States and other countries. All other company or product names are trademarks of their respective owners. 12