Sample Modules


This section explains how to use the sample .NET component and client that ships with the adapter.

Sample source code, written in C#, is provided in the \examples\CSharp directory of the adapter installation, and illustrates how the adapter can interoperate with C# code. Although the sample source code is written in C#, code can be written in any .NET CLS-compliant language (for example, Visual Basic .NET).

The examples\CSharp\Operation directory contains a C# class library project that defines a class Testobj1. The Testobj1 class is similar to the C++ Testobj1 class in the examples\Operation\Operation2 directory of the adapter installation.

The examples\CSharp\TestInterceptor directory contains a C# console application project that defines a client program. This TestInterceptor C# client is similar to the C++ client in the examples\testinterceptor directory of the adapter installation.

The SampleCSharp.dat available in the examples directory is a sample repository that contains:

To use the sample module
  1. Build the Operation project using Visual Studio .NET (VS .NET). Modify the path for the assembly key file in AssemblyInfo.cs to match the adapter installation.
  2. When you build the project, VS .NET will register the Testobj1 class for COM interoperability, generating a COM type library, Operation.tlb, in the tibco\adapter\adcom\5.3\examples\CSharp\Operation\bin\Debug directory, and will write most of the required entries into the Microsoft Windows registry.

    Before building the project, you can verify that VS .NET will register Testobj1 for COM interoperability. In the Solution Explorer window, right-click the Operation node and select Properties from the shortcut menu; select Configuration Properties > Build > Outputs and make sure Register for COM Interop is set to True.

    There is one required key that VS.NET does not write to the registry. This is the TypeLib key for the Testobj1 coclass. For successful .NET, COM, and adapter interoperability, the TypeLib key must be added to registry. The Testobj1 class has a method marked with the <ComRegisterFunction> attribute that adds the TypeLib key when VS .NET registers the COM coclass and a method marked with the <ComUnregisterFunction> that removes the TypeLib key when VS .NET unregisters the coclass. These methods are run automatically when VS.NET builds the project and you do not need to do anything for the Testobj1 class. However, any managed component that you develop on your own and that you want to use in conjunction with the COM and .NET interoperability, and the adapter must have this TypeLib key added. You can either use your own methods marked with the <ComRegisterFunction> and <ComUnregisterFunction> attributes, as illustrated in the Testobj1 class, or you can add the TypeLib key manually. The GUID's for the type library and the coclass are defined by GuidAttribute attributes (in the Assembly.cs and Class1.cs respectively).

  3. The SampleCSharp.dat already contains the type information from the Operation.tlb type library, but you must reimport this information after building the Operation project. To do so, import the type library from the Import Schema tab in TIBCO Designer. The Import Schema tab is available when you select the Advanced Services folder in the project panel:

    You must run the metadata import utility to import type information for any managed component you develop.

  4. Build the TestInterceptor project using Visual Studio .NET.
  5. Start the Service component of the adapter:
  6. TIBCOCOMService -system:repourl 
    <Install_Dir>\adapter\adcom\5.3\Samples\SampleCSharp.dat -system:configurl "Adapter 
    for COM/Service Instances/TIBCOCOMService1" 
    
  7. Run the TestInterceptor executable.

TIBCO Adapter™ for COM User’s Guide
Software Release 5.3, September 2005
Copyright © TIBCO Software Inc. All rights reserved
www.tibco.com