Exforsys

VB.NET 2005

  1. VB.NET 2005 Free Training
  2. The .NET Framework Architecture Part 1
  3. The .NET Framework Architecture Part 2
  4. Application Class and Message Class
  5. Implementing Class Library Object
  6. Visual Studio.NET Namespaces
  7. .NET Assemblies
  8. Differences between VB.NET 1.0 and VB.NET 2.0
  9. Introducing VB.NET Windows Forms
  10. Visual Studio Windows Forms Designer
  11. Exploring the Forms Designer generated code
  12. Setting and Adding Properties to Windows Form
  13. Implementing Inheritance
  14. Event Handling In Visual Basic .NET
  15. Building Graphical Interface elements
  16. .NET Common Windows Forms Controls Part 1
  17. .NET Common Windows Forms Controls Part 2
  18. Common Controls and Handling Control Events
  19. DomainUpDown and NumericUpDown Controls
  20. Dialog Boxes in Visual Basic .NET
  21. Visual Studio Adding Controls to Windows Form
  22. VB.NET Validation Controls
  23. Working with Menu Controls
  24. VB.NET MDI Applications
  25. .NET Exceptions
  26. VB.NET Creating and Managing Components Part 1
  27. VB.NET Creating and Managing Components Part 2
  28. Simple Data Binding
  29. .NET Complex Data Binding
  30. .NET Data Form Wizard
  31. Data Manipulation with ADO.NET
  32. SQL Server Stored Procedures
  33. SQL Server Ad Hoc Queries
  34. Finding and Sorting Data in DataSets
  35. ADO.NET Object Model
  36. Working with DataSets
  37. Using XML Data
  38. Working with File System in .NET
  39. Creating Web Service
  40. Instantiating - Invoking Web Services, Creating Proxy Classes with WSDL
  41. Web Reference and Web Services
  42. Web Services - SOAP, WSDL, Disco and UDDI
  43. Web Application Testing in VB.NET 2005
  44. Web Application Tracing and Debugging
  45. Working with Legacy Code and COM Components
  46. ActiveX Controls and Legacy Code
  47. Windows Application Testing
  48. VB.NET Windows Application Testing
  49. Tracing VB.NET Windows Application
  50. Debugging Windows Applications In Visual Studio.NET 2005
  51. Deploying Windows Applications In Visual Studio.NET 2005
  52. Customizing Setup Project in Visual Studio.NET 2005
  53. Shared Assembly
  54. Microsoft .NET Creating Installation Components
  55. The Registry Editor in Visual Studio.NET 2005
  56. The File Types Editor

Ads


Home arrow Technical Training arrow VB.NET 2005

Working with Legacy Code and COM Components

Page 1 of 3
Author : Exforsys Inc.     Published on: 30th Jul 2005    |   Last Updated on: 24th Dec 2007

Working with Legacy Code - COM Components

In this tutorial you will learn to use COM Components, Understand Runtime Callable Wrappers, Type Library Importer (TLBIMP), Using COM Components Directly, Using COM+ Components and Creating Com+ Application.


Ads

Using COM Components

Component Object Model (COM) is a language-independent architecture that defines specifications for component interoperability. Each COM component is identified by a globally unique ID (GUID). It is a number that is unique across space and time. Implementation of COM is called ActiveX. COM objects can be compared with .NET components and ActiveX DLLs with Assemblies. This is because .NET components are more object-oriented.

.NET supports COM and ActiveX for backward compatibility. Let us see how this backward compatibility is achieved.

Understanding Runtime Callable Wrappers

Interoperability between COM objects that are run on unmanaged code and the .NET clients that run on managed code require a good deal of plumbing which is provided by the runtime callable wrapper (RCW). The CLR exposes the COM objects through RCW proxy. The RCW is primarily used to marshal calls between a .NET client and a COM object. The runtime creates RCW for each COM object, regardless of the number of references that exist on that object. Any number of managed clients can hold a reference to the COM objects. The runtime maintains a single RCW for each object.

The metadata derived from a type library can be used by the runtime to create both the COM object being called and a wrapper for that object. Thus each RCW maintains a cache of interface pointers on the COM object it wraps and releases its reference on the COM object when the RCW is no longer needed. So the RCW performs the garbage collection also.

We have already seen that RCW marshals’ data between managed and unmanaged code, on behalf of objects wrapped. It is particularly useful as the RCW marshals methods and method return values whenever the client and server have different representations of the data passed between them.

The wrapper enforces built-in marshaling rules. Thus it streamlines the communication between the server and client.

Using TLBIMP

The Type Library Importer converts the type definitions found within a COM type library into equivalent definitions in a CLR assembly. The TLBIMP.exe gives an output that is a binary file that contains runtime metadata for the types defined within original type library. The usage of the tool is given below:

Tlbimp tlbfile [options]

This file can be examined with Ildasm.exe

Some of the options that are used with TLBIMP are given below:






Option

Description

/asmversion:versionNumber

Specifies the version number of the assembly to produce. Specify versionNumber in the format major.minor.build.revision.

/delaysign

Specifies to Tlbimp.exe to sign the resulting assembly with a strong name using delayed signing.

/help

Displays command syntax and options for the tool

/keycontainer:containername

Signs the resulting assembly with a strong name using the public/private key pair found in the key container specified by containername.

/keyfile:filename

Signs the resulting assembly with a strong name using the publisher's official public/private key pair found in filename.

/namespace:namespace

Specifies the namespace in which to produce the assembly.

/noclassmembers

Prevents Tlbimp.exe from adding members to classes.

/nologo

Suppresses the Microsoft startup banner display.

/out:filename

Specifies the name of the output file, assembly, and namespace in which to write the metadata definitions.

/primary

Produces a primary interop assembly for the specified type library.

/publickey:filename

Specifies the file containing the public key to use to sign the resulting assembly.

/reference:filename

Specifies the assembly file to use to resolve references to types defined outside the current type library

/silent

Suppresses the display of success messages.

/strictref

Does not import a type library if the tool cannot resolve all references within the current assembly, the assemblies specified with the /reference option, or registered primary interop assemblies (PIAs).

/strictref:nopia

Same as /strictref, but ignores PIAs.

/sysarray

Specifies to the tool to import a COM style SafeArray as a managed

/tlbreference:filename

Specifies the type library file to use to resolve type library references without consulting the registry.

/transform:transformName

Transforms metadata as specified by the transformName parameter.

/unsafe

Produces interfaces without .NET Framework security checks. Calling a method that is exposed in this way might pose a security risk. You should not use this option unless you are aware of the risks of exposing such code.

/verbose

Specifies verbose mode; displays additional information about the imported type library.

/?

Displays command syntax and options for the tool.


Ads

Tlbimp.exe performs conversion on an entire type library collectively. Tlbimp.exe also has options for supplying the information necessary to generate strongly named assemblies. A resource ID can also be appended to a type library file when importing from a module containing multiple type libraries. Tlbimp.exe is able to locate this file if it is in the current directory or if you specify the full path.



 
This tutorial is part of a VB.NET 2005 tutorial series. Read it from the beginning and learn yourself.

VB.NET 2005

  1. VB.NET 2005 Free Training
  2. The .NET Framework Architecture Part 1
  3. The .NET Framework Architecture Part 2
  4. Application Class and Message Class
  5. Implementing Class Library Object
  6. Visual Studio.NET Namespaces
  7. .NET Assemblies
  8. Differences between VB.NET 1.0 and VB.NET 2.0
  9. Introducing VB.NET Windows Forms
  10. Visual Studio Windows Forms Designer
  11. Exploring the Forms Designer generated code
  12. Setting and Adding Properties to Windows Form
  13. Implementing Inheritance
  14. Event Handling In Visual Basic .NET
  15. Building Graphical Interface elements
  16. .NET Common Windows Forms Controls Part 1
  17. .NET Common Windows Forms Controls Part 2
  18. Common Controls and Handling Control Events
  19. DomainUpDown and NumericUpDown Controls
  20. Dialog Boxes in Visual Basic .NET
  21. Visual Studio Adding Controls to Windows Form
  22. VB.NET Validation Controls
  23. Working with Menu Controls
  24. VB.NET MDI Applications
  25. .NET Exceptions
  26. VB.NET Creating and Managing Components Part 1
  27. VB.NET Creating and Managing Components Part 2
  28. Simple Data Binding
  29. .NET Complex Data Binding
  30. .NET Data Form Wizard
  31. Data Manipulation with ADO.NET
  32. SQL Server Stored Procedures
  33. SQL Server Ad Hoc Queries
  34. Finding and Sorting Data in DataSets
  35. ADO.NET Object Model
  36. Working with DataSets
  37. Using XML Data
  38. Working with File System in .NET
  39. Creating Web Service
  40. Instantiating - Invoking Web Services, Creating Proxy Classes with WSDL
  41. Web Reference and Web Services
  42. Web Services - SOAP, WSDL, Disco and UDDI
  43. Web Application Testing in VB.NET 2005
  44. Web Application Tracing and Debugging
  45. Working with Legacy Code and COM Components
  46. ActiveX Controls and Legacy Code
  47. Windows Application Testing
  48. VB.NET Windows Application Testing
  49. Tracing VB.NET Windows Application
  50. Debugging Windows Applications In Visual Studio.NET 2005
  51. Deploying Windows Applications In Visual Studio.NET 2005
  52. Customizing Setup Project in Visual Studio.NET 2005
  53. Shared Assembly
  54. Microsoft .NET Creating Installation Components
  55. The Registry Editor in Visual Studio.NET 2005
  56. The File Types Editor
 

Comments