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 - 2

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

Working with Legacy Code and COM Components

.

.

.

Ads

Using COM Components Directly

A COM component can be used in a .NET application by adding a reference to the project. In such situations, metadata is created from the type library of the component that is being referenced. When the object is instantiated in the .NET application, it is treated as any other .NET class library. The code acts and looks the same. Underneath the CLR is creating the RCW for the COM object and the COM object itself is marshaling calls back and forth between the managed and unmanaged process.

The ActiveX component which may be a .dll file will have to be registered with the Regsvr32.exe command. In the solution explorer of the project that is being used, reference to the .dll file will have to be added.

This component can be consumed like any other .NET component. However DLL created cannot be placed in a Global Assembly Cache and hence it cannot be reused.

Using COM+ Components

Developing components using COM specifications are of prime importance in COM+. COM+ enhances and upgrades the MTS services viz., Transaction Services, Security Services, and Synchronization Services: This also helps us develop simple development environment for Server Components. With COM+ user’s can:

1. Design single-user, single threaded components

2. Incorporates threading, concurrency, process management, and deployment.

3. Easily deploy your application as an n-tier application

4. Install the components by dragging and dropping

The various COM+ Services and the description are given below:






COM+ Services

Description

Resources Management

Manages resources such as database connection, network connection, and memory

Just-in-Time Activation

Conserves Server memory

Role-Based security

Validates security permissions based on roles

Concurrency

Enables multiple processes to run simultaneously

Object pooling

Provides a pool of readymade objects

Automatic Transaction management

Enables you to configure classes at the design stage, which take part in the transaction at run time

Queued components

Provides asynchronous message queuing

COM+ Events

Stores event information from different publishers

Shared property manager

Shares state among multiple objects within a server process

Compensating resource manager

Applies atomicity and durability properties to non-transactional resources


In visual studio create a new class project and add the following code to the class.

Imports System
Namespace ComPlusDemo
.
Public Class Class1
.......Public Sub check(ByVal years As Integer)
..............If years > 10 Then
.....................Console.WriteLine("Additional Incentive Payable!")
..............Else
.....................Console.WriteLine("No Incentive payable!")
..............
End If
.......End Sub
End Class

End Namespace

After finishing this click the menu build and build the solution. The message Build Succeeded appears in the status bar. The class1 is created a component that accepts the number of years as an argument and returns a message so say if incentive is payable or not.

Now create a new VB project and select console application. Here we reference the class that was just created by right-clicking on the solution explorer and choosing the option Add Reference. In the module that is created add the following code.

Imports ComPlusDemo.ComPlusDemo
Namespace UseComp
.....Module Module1
.....

..........Sub Main()
...............' Uncomment the following line to set My.User to the currently logged on Windows user.
...............' My.User.InitializeWithWindowsUser
.
...............Dim years As Integer
...............Dim exp As String
...............Dim Eligibility As New Class1()
.....
...............Console.WriteLine("Enter the number of years!")
...............exp = Console.ReadLine()
...............years = Convert.ToInt16(exp)
...............Eligibility.check(years)
...............Console.ReadLine()
..........End Sub
.....
.....End Module
End Namespace

Now press F5 to execute the module, the result is shown below:

This demo shows the creation of .NET desktop console using components.

Creating Com+ Application:

From the Administrative tools choose component services. The component services window opens. Expand component services and MyComputer. Right click on the Com+ Application and choose new application as shown in the screenshot below:

This starts the wizard the first screen of which is shown below:

Ads



 
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