SlideShare a Scribd company logo
1 of 24
Creating Components


Objectives
    In this lesson, students will learn to:
         ā€¢ Identify the types of components
         ā€¢ Identify the various stages in the life cycle of a component
         ā€¢ Implement polymorphism in components
         ā€¢ Use .NET COM components in VB.NET
         ā€¢ Declare properties and methods for a component
         ā€¢ Create a reference of the Component from the User Interface
         ā€¢ Identify the role of assemblies in VB.NET




 Ā©NIIT        Creating and Managing Components              Lesson 1A / Slide 1 of 24
Creating Components


Getting Started with .NET
Components
    ā€¢    A component is a binary executable built from a .NET project.
    ā€¢    The component is referenced by applications seeking the services provided by
         the component.




 Ā©NIIT          Creating and Managing Components              Lesson 1A / Slide 2 of 24
Creating Components


Introducing Components
    ā€¢    You can create the component once and reuse it whenever necessary.
    ā€¢    You can also develop components as a third party provider.
    ā€¢    When you use the components, you are not inheriting a class but using a
         binary code in your applications.




 Ā©NIIT          Creating and Managing Components              Lesson 1A / Slide 3 of 24
Creating Components


Types of Components
    ā€¢    Components can be of three types:
          ā€¢ In-built Components
               ā€¢ The .NET class framework comes with in-built components, such as
                 Timer and ServiceController.
               ā€¢ You can use the components that come with the .NET class
                 framework in your applications.
          ā€¢ Component Classes
               ā€¢ A class becomes a component when it follows defined standards of
                 interaction.
               ā€¢ All components derive from the Component class.
          ā€¢ User Controls
               ā€¢ User Controls can be defined as bundles of standard controls.



 Ā©NIIT          Creating and Managing Components            Lesson 1A / Slide 4 of 24
Creating Components


Characteristics of a Component
    ā€¢    The name of a component class should be short and meaningful. It should be a
         combination of whole words with a capitalized initial character for each word.
    ā€¢    You can control the use of a component by using proper access level for the
         constructors.
    ā€¢    You can implement the IComponent interface to create a component.
    ā€¢    You should group related components together in separate namespaces.




 Ā©NIIT          Creating and Managing Components              Lesson 1A / Slide 5 of 24
Creating Components


Life Cycle of a Component
    ā€¢    Components are initialized by constructors.
    ā€¢    Initialization can be of two types:
           ā€¢ Type initialization
                  ā€¢ Type initialization is achieved by using a shared constructor.
                  ā€¢ Shared constructor is called only once in the lifetime of a Visual Basic
                     .NET application.
           ā€¢ Instance initialization.
                  ā€¢ Instance initialization can be achieved by using constructors, which
                     are not shared.




 Ā©NIIT           Creating and Managing Components                 Lesson 1A / Slide 6 of 24
Creating Components


Polymorphism in Components
    ā€¢    The ability of a class to implement functions with the same name that are
         performing different actions depending on how they are called is known as
         polymorphism.
    ā€¢    Polymorphism can be implemented by:
           ā€¢ Implementing an interface.
           ā€¢ Inheritance
           ā€¢ Using abstract classes.




 Ā©NIIT          Creating and Managing Components              Lesson 1A / Slide 7 of 24
Creating Components


Implementing Interfaces
    ā€¢    An   interface defines the behavior of a class.
    ā€¢    An   interface can declare properties, methods, and events.
    ā€¢    An   interface can be implemented by more than one class.
    ā€¢    An   interface can be declared as :
                    Interface interfacename
                           Sub functionname()
                    End Interface




 Ā©NIIT            Creating and Managing Components              Lesson 1A / Slide 8 of 24
Creating Components


Using .NET COM Components in
VB.NET
    ā€¢    Component Object Model (COM) was used in earlier versions of Visual Basic to
         create components.
    ā€¢    Implementation of COM is called ActiveX.
    ā€¢    The .NET supports COM and ActiveX objects for backward compatibility.
    ā€¢    A COM component from .NET can be called in the following ways:
           ā€¢ By converting the COM type library to a .NET assembly.
           ā€¢ Using COM components directly.




 Ā©NIIT          Creating and Managing Components              Lesson 1A / Slide 9 of 24
Creating Components


Converting COM Type Library to .NET
Assembly
    ā€¢    The tlbimp tool can be used to convert a COM type library to a .NET assembly.
    ā€¢    Following options can be used with tlbimp tool:
           ā€¢ out:FileName ā€“ specifies the name of the assembly to be produced.
           ā€¢ Namespace:NameSpace ā€“ Specifies the namespace of the assembly to be
              produced.
           ā€¢ AsmVersion:Version ā€“ Specifies version number of the assembly to be
              produced.
           ā€¢ reference:FileName ā€“ Specifies the file name to be used to resolve
              references.




 Ā©NIIT          Creating and Managing Components             Lesson 1A / Slide 10 of 24
Creating Components


Using COM Components Directly
    ā€¢    The Com components can be added directly through Solution Explorer in .NET.
    ā€¢    Internally, an Runtime Callable Wrapper (RCW) is used to access the COM
         components.




 Ā©NIIT          Creating and Managing Components            Lesson 1A / Slide 11 of 24
Creating Components


Using COM+ with VB.NET
    ā€¢    COM+ is the basic COM and a set of additional services.
    ā€¢    COM+ programming is based on the following assumptions:
           ā€¢ In COM+, clients program on the basis of Interfaces, not Classes.
           ā€¢ Code is not linked statically.
    ā€¢    Using Com+ components, you can focus on developing business logic.
    ā€¢    A .NET component that takes advantage of COM+ services needs to be derived
         from the .NET base class ServicedComponent.




 Ā©NIIT          Creating and Managing Components           Lesson 1A / Slide 12 of 24
Creating Components


Properties and Methods for a
Component
    ā€¢    To create a component in .NET, the user needs to identify:
           ā€¢ The type of component.
           ā€¢ Properties for the component.
           ā€¢ Methods for the component.




 Ā©NIIT           Creating and Managing Components            Lesson 1A / Slide 13 of 24
Creating Components


Using Constructors
    ā€¢    A component can have the following types of constructors:
           ā€¢ Public constructors.
           ā€¢ Friend constructors.
           ā€¢ Private constructors.




 Ā©NIIT          Creating and Managing Components             Lesson 1A / Slide 14 of 24
Creating Components


Adding properties
    ā€¢    Declaring a property allows you to control how a value is changed or read.
    ā€¢    Calculated values can be shown as properties even when they are not stored
         as actual data in the class.
    ā€¢    Property statement can also incorporate error handling.




 Ā©NIIT          Creating and Managing Components            Lesson 1A / Slide 15 of 24
Creating Components


Adding methods
    ā€¢    If a method is declared Private, only methods within the same class can call
         that method.
    ā€¢    A method in a class is a procedure that performs some sort of operation on the
         data within the class and may or may not return.
    ā€¢    A method is declared as:
              Public Function functionname() As Integer




 Ā©NIIT          Creating and Managing Components             Lesson 1A / Slide 16 of 24
Creating Components


Referencing the Component from the
User Interface
    ā€¢    A component can be tested only by referencing it from another application.
    ā€¢    A component can be referenced by using the Solution Explorer.




 Ā©NIIT          Creating and Managing Components             Lesson 1A / Slide 17 of 24
Creating Components


Role of Assemblies in VB.NET
    ā€¢    Concept of assemblies has been introduced in the .NET to counter the problems
         faced in DLL handling in previous versions.
    ā€¢    An assembly usually consists of:
            ā€¢ Manifest
                 ā€¢ This contains the information like name and version of the assembly.
                 ā€¢ Information about the files that the assembly uses, is also present in
                   it.
            ā€¢ Portable executable (PE)
                 ā€¢ This contains metadata, Intermediate Language (IL) and the type
                   information.




 Ā©NIIT           Creating and Managing Components              Lesson 1A / Slide 18 of 24
Creating Components




                  Demo
         Using .NET Components




 Ā©NIIT   Creating and Managing Components   Lesson 1A / Slide 19 of 24
Creating Components

Problem Statement
    ā€¢    Build a .NET DLL component ā€˜PickServerTimeā€™ which can get the current date
         and time from the host computer and then use the component in another
         VB.NET application named as ConsumerApplication which will display the
         information.




 Ā©NIIT        Creating and Managing Components            Lesson 1A / Slide 20 of 24
Creating Components


Solution
    ā€¢    To build and use the ā€˜PickServerTimeā€™ component in an application named as
         ā€˜ConsumerApplicationā€™ , you need to perform the following steps:
         1.   Create a project.
         2.   Add properties and functions to the component.
         3.   Build the component.
         4.   Create a user interface to test the component.




 Ā©NIIT        Creating and Managing Components            Lesson 1A / Slide 21 of 24
Creating Components


Summary
    In this lesson, you learned that:


    ā€¢    A component is a reusable piece of code in binary form that can be used
         along with the components from other vendors, with relatively little effort.
    ā€¢    Types of Components:
         ā€¢ In-built components.
         ā€¢ Component classes.
         ā€¢ User controls.
    ā€¢    A component goes through different stages once you deploy it. The
         constructors initialize components.
    ā€¢    Initialization can be of two types:
         ā€¢ Type initialization.
         ā€¢ Instance initialization.


 Ā©NIIT         Creating and Managing Components              Lesson 1A / Slide 22 of 24
Creating Components


Summary (Contd.)
    ā€¢    In .NET programming environment, COM components are called:
         ā€¢ By converting the COM type library to a .NET assembly.
         ā€¢ By using COM components directly.
    ā€¢    The tlbimp tool uses the metadata of a COM type library to do the
         conversion.
    ā€¢    To create a component in .NET, the user firstly needs to identify the type of
         component and also its properties and methods.
    ā€¢    In .NET programming environment, a component can have the following
         types of constructors:
         ā€¢ Public constructor.
         ā€¢ Friend constructor.
         ā€¢ Private constructor
    ā€¢    An assembly contains information about the files on which the component
         depends and the location of these files.
    ā€¢    An assembly consists of a manifest and the portable executables (PE).

 Ā©NIIT         Creating and Managing Components              Lesson 1A / Slide 23 of 24
Creating Components


Summary (Contd.)
    ā€¢    A manifest consists of information such as the name and version of the
         assembly.
    ā€¢    A portable executable consists of the IL code, type information, and
         metadata.




 Ā©NIIT         Creating and Managing Components            Lesson 1A / Slide 24 of 24

More Related Content

Similar to Create .NET Components

Vb.net session 10
Vb.net session 10Vb.net session 10
Vb.net session 10Niit Care
Ā 
Vb.net session 13
Vb.net session 13Vb.net session 13
Vb.net session 13Niit Care
Ā 
Vb.net session 01
Vb.net session 01Vb.net session 01
Vb.net session 01Niit Care
Ā 
Vb.net session 03
Vb.net session 03Vb.net session 03
Vb.net session 03Niit Care
Ā 
.net Based Component Technologies
.net Based Component Technologies.net Based Component Technologies
.net Based Component Technologiesprakashk453625
Ā 
Vb.net session 02
Vb.net session 02Vb.net session 02
Vb.net session 02Niit Care
Ā 
About .net
About .net About .net
About .net joeyparkker
Ā 
Building extensible application using MEF
Building extensible application using MEFBuilding extensible application using MEF
Building extensible application using MEFRonak Thakkar
Ā 
Vb net xp_13
Vb net xp_13Vb net xp_13
Vb net xp_13Niit Care
Ā 
Ajs 2 c
Ajs 2 cAjs 2 c
Ajs 2 cNiit Care
Ā 
UNIT IV DESIGN PATTERNS.pptx
UNIT IV DESIGN PATTERNS.pptxUNIT IV DESIGN PATTERNS.pptx
UNIT IV DESIGN PATTERNS.pptxanguraju1
Ā 
Modular PHP Development using CodeIgniter Bonfire
Modular PHP Development using CodeIgniter BonfireModular PHP Development using CodeIgniter Bonfire
Modular PHP Development using CodeIgniter BonfireJeff Fox
Ā 
10265 developing data access solutions with microsoft visual studio 2010
10265 developing data access solutions with microsoft visual studio 201010265 developing data access solutions with microsoft visual studio 2010
10265 developing data access solutions with microsoft visual studio 2010bestip
Ā 
Vb.net session 04
Vb.net session 04Vb.net session 04
Vb.net session 04Niit Care
Ā 
Jenkins_1679702972.pdf
Jenkins_1679702972.pdfJenkins_1679702972.pdf
Jenkins_1679702972.pdfMahmoudAlnmr1
Ā 
Dot net Online Training | .Net Training and Placement online
Dot net Online Training | .Net Training and Placement onlineDot net Online Training | .Net Training and Placement online
Dot net Online Training | .Net Training and Placement onlineGaruda Trainings
Ā 
08 gui 11
08 gui 1108 gui 11
08 gui 11Niit Care
Ā 
Koala component model (1)
Koala component model (1)Koala component model (1)
Koala component model (1)Saransh Garg
Ā 

Similar to Create .NET Components (20)

Vb.net session 10
Vb.net session 10Vb.net session 10
Vb.net session 10
Ā 
Vb.net session 13
Vb.net session 13Vb.net session 13
Vb.net session 13
Ā 
Vb.net session 01
Vb.net session 01Vb.net session 01
Vb.net session 01
Ā 
Vb.net session 03
Vb.net session 03Vb.net session 03
Vb.net session 03
Ā 
.net Based Component Technologies
.net Based Component Technologies.net Based Component Technologies
.net Based Component Technologies
Ā 
Vb.net session 02
Vb.net session 02Vb.net session 02
Vb.net session 02
Ā 
About .net
About .net About .net
About .net
Ā 
Building extensible application using MEF
Building extensible application using MEFBuilding extensible application using MEF
Building extensible application using MEF
Ā 
Component based software engineering
Component based software engineeringComponent based software engineering
Component based software engineering
Ā 
Vb net xp_13
Vb net xp_13Vb net xp_13
Vb net xp_13
Ā 
Ajs 2 c
Ajs 2 cAjs 2 c
Ajs 2 c
Ā 
UNIT IV DESIGN PATTERNS.pptx
UNIT IV DESIGN PATTERNS.pptxUNIT IV DESIGN PATTERNS.pptx
UNIT IV DESIGN PATTERNS.pptx
Ā 
Modular PHP Development using CodeIgniter Bonfire
Modular PHP Development using CodeIgniter BonfireModular PHP Development using CodeIgniter Bonfire
Modular PHP Development using CodeIgniter Bonfire
Ā 
10265 developing data access solutions with microsoft visual studio 2010
10265 developing data access solutions with microsoft visual studio 201010265 developing data access solutions with microsoft visual studio 2010
10265 developing data access solutions with microsoft visual studio 2010
Ā 
Vb.net session 04
Vb.net session 04Vb.net session 04
Vb.net session 04
Ā 
Jenkins_1679702972.pdf
Jenkins_1679702972.pdfJenkins_1679702972.pdf
Jenkins_1679702972.pdf
Ā 
jenkins.pdf
jenkins.pdfjenkins.pdf
jenkins.pdf
Ā 
Dot net Online Training | .Net Training and Placement online
Dot net Online Training | .Net Training and Placement onlineDot net Online Training | .Net Training and Placement online
Dot net Online Training | .Net Training and Placement online
Ā 
08 gui 11
08 gui 1108 gui 11
08 gui 11
Ā 
Koala component model (1)
Koala component model (1)Koala component model (1)
Koala component model (1)
Ā 

More from Niit Care

Ajs 1 b
Ajs 1 bAjs 1 b
Ajs 1 bNiit Care
Ā 
Ajs 4 b
Ajs 4 bAjs 4 b
Ajs 4 bNiit Care
Ā 
Ajs 4 a
Ajs 4 aAjs 4 a
Ajs 4 aNiit Care
Ā 
Ajs 4 c
Ajs 4 cAjs 4 c
Ajs 4 cNiit Care
Ā 
Ajs 3 b
Ajs 3 bAjs 3 b
Ajs 3 bNiit Care
Ā 
Ajs 3 a
Ajs 3 aAjs 3 a
Ajs 3 aNiit Care
Ā 
Ajs 3 c
Ajs 3 cAjs 3 c
Ajs 3 cNiit Care
Ā 
Ajs 2 b
Ajs 2 bAjs 2 b
Ajs 2 bNiit Care
Ā 
Ajs 2 a
Ajs 2 aAjs 2 a
Ajs 2 aNiit Care
Ā 
Ajs 1 a
Ajs 1 aAjs 1 a
Ajs 1 aNiit Care
Ā 
Ajs 1 c
Ajs 1 cAjs 1 c
Ajs 1 cNiit Care
Ā 
Dacj 4 2-a
Dacj 4 2-aDacj 4 2-a
Dacj 4 2-aNiit Care
Ā 
Dacj 4 1-a
Dacj 4 1-aDacj 4 1-a
Dacj 4 1-aNiit Care
Ā 
Dacj 1-2 b
Dacj 1-2 bDacj 1-2 b
Dacj 1-2 bNiit Care
Ā 
Dacj 1-3 c
Dacj 1-3 cDacj 1-3 c
Dacj 1-3 cNiit Care
Ā 
Dacj 1-3 b
Dacj 1-3 bDacj 1-3 b
Dacj 1-3 bNiit Care
Ā 
Dacj 1-3 a
Dacj 1-3 aDacj 1-3 a
Dacj 1-3 aNiit Care
Ā 
Dacj 1-2 c
Dacj 1-2 cDacj 1-2 c
Dacj 1-2 cNiit Care
Ā 
Dacj 1-2 a
Dacj 1-2 aDacj 1-2 a
Dacj 1-2 aNiit Care
Ā 
Dacj 1-1 c
Dacj 1-1 cDacj 1-1 c
Dacj 1-1 cNiit Care
Ā 

More from Niit Care (20)

Ajs 1 b
Ajs 1 bAjs 1 b
Ajs 1 b
Ā 
Ajs 4 b
Ajs 4 bAjs 4 b
Ajs 4 b
Ā 
Ajs 4 a
Ajs 4 aAjs 4 a
Ajs 4 a
Ā 
Ajs 4 c
Ajs 4 cAjs 4 c
Ajs 4 c
Ā 
Ajs 3 b
Ajs 3 bAjs 3 b
Ajs 3 b
Ā 
Ajs 3 a
Ajs 3 aAjs 3 a
Ajs 3 a
Ā 
Ajs 3 c
Ajs 3 cAjs 3 c
Ajs 3 c
Ā 
Ajs 2 b
Ajs 2 bAjs 2 b
Ajs 2 b
Ā 
Ajs 2 a
Ajs 2 aAjs 2 a
Ajs 2 a
Ā 
Ajs 1 a
Ajs 1 aAjs 1 a
Ajs 1 a
Ā 
Ajs 1 c
Ajs 1 cAjs 1 c
Ajs 1 c
Ā 
Dacj 4 2-a
Dacj 4 2-aDacj 4 2-a
Dacj 4 2-a
Ā 
Dacj 4 1-a
Dacj 4 1-aDacj 4 1-a
Dacj 4 1-a
Ā 
Dacj 1-2 b
Dacj 1-2 bDacj 1-2 b
Dacj 1-2 b
Ā 
Dacj 1-3 c
Dacj 1-3 cDacj 1-3 c
Dacj 1-3 c
Ā 
Dacj 1-3 b
Dacj 1-3 bDacj 1-3 b
Dacj 1-3 b
Ā 
Dacj 1-3 a
Dacj 1-3 aDacj 1-3 a
Dacj 1-3 a
Ā 
Dacj 1-2 c
Dacj 1-2 cDacj 1-2 c
Dacj 1-2 c
Ā 
Dacj 1-2 a
Dacj 1-2 aDacj 1-2 a
Dacj 1-2 a
Ā 
Dacj 1-1 c
Dacj 1-1 cDacj 1-1 c
Dacj 1-1 c
Ā 

Recently uploaded

Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
Ā 
FULL ENJOY šŸ” 8264348440 šŸ” Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY šŸ” 8264348440 šŸ” Call Girls in Diplomatic Enclave | DelhiFULL ENJOY šŸ” 8264348440 šŸ” Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY šŸ” 8264348440 šŸ” Call Girls in Diplomatic Enclave | Delhisoniya singh
Ā 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
Ā 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
Ā 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
Ā 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
Ā 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
Ā 
SIEMENS: RAPUNZEL ā€“ A Tale About Knowledge Graph
SIEMENS: RAPUNZEL ā€“ A Tale About Knowledge GraphSIEMENS: RAPUNZEL ā€“ A Tale About Knowledge Graph
SIEMENS: RAPUNZEL ā€“ A Tale About Knowledge GraphNeo4j
Ā 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptxLBM Solutions
Ā 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
Ā 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr LapshynFwdays
Ā 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
Ā 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions
Ā 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
Ā 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
Ā 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraDeakin University
Ā 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
Ā 
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxnull - The Open Security Community
Ā 
Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024Neo4j
Ā 

Recently uploaded (20)

Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
Ā 
FULL ENJOY šŸ” 8264348440 šŸ” Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY šŸ” 8264348440 šŸ” Call Girls in Diplomatic Enclave | DelhiFULL ENJOY šŸ” 8264348440 šŸ” Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY šŸ” 8264348440 šŸ” Call Girls in Diplomatic Enclave | Delhi
Ā 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
Ā 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
Ā 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
Ā 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Ā 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
Ā 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
Ā 
SIEMENS: RAPUNZEL ā€“ A Tale About Knowledge Graph
SIEMENS: RAPUNZEL ā€“ A Tale About Knowledge GraphSIEMENS: RAPUNZEL ā€“ A Tale About Knowledge Graph
SIEMENS: RAPUNZEL ā€“ A Tale About Knowledge Graph
Ā 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptx
Ā 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Ā 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
Ā 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
Ā 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping Elbows
Ā 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
Ā 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Ā 
Artificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning eraArtificial intelligence in the post-deep learning era
Artificial intelligence in the post-deep learning era
Ā 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
Ā 
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Ā 
Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024
Ā 

Create .NET Components

  • 1. Creating Components Objectives In this lesson, students will learn to: ā€¢ Identify the types of components ā€¢ Identify the various stages in the life cycle of a component ā€¢ Implement polymorphism in components ā€¢ Use .NET COM components in VB.NET ā€¢ Declare properties and methods for a component ā€¢ Create a reference of the Component from the User Interface ā€¢ Identify the role of assemblies in VB.NET Ā©NIIT Creating and Managing Components Lesson 1A / Slide 1 of 24
  • 2. Creating Components Getting Started with .NET Components ā€¢ A component is a binary executable built from a .NET project. ā€¢ The component is referenced by applications seeking the services provided by the component. Ā©NIIT Creating and Managing Components Lesson 1A / Slide 2 of 24
  • 3. Creating Components Introducing Components ā€¢ You can create the component once and reuse it whenever necessary. ā€¢ You can also develop components as a third party provider. ā€¢ When you use the components, you are not inheriting a class but using a binary code in your applications. Ā©NIIT Creating and Managing Components Lesson 1A / Slide 3 of 24
  • 4. Creating Components Types of Components ā€¢ Components can be of three types: ā€¢ In-built Components ā€¢ The .NET class framework comes with in-built components, such as Timer and ServiceController. ā€¢ You can use the components that come with the .NET class framework in your applications. ā€¢ Component Classes ā€¢ A class becomes a component when it follows defined standards of interaction. ā€¢ All components derive from the Component class. ā€¢ User Controls ā€¢ User Controls can be defined as bundles of standard controls. Ā©NIIT Creating and Managing Components Lesson 1A / Slide 4 of 24
  • 5. Creating Components Characteristics of a Component ā€¢ The name of a component class should be short and meaningful. It should be a combination of whole words with a capitalized initial character for each word. ā€¢ You can control the use of a component by using proper access level for the constructors. ā€¢ You can implement the IComponent interface to create a component. ā€¢ You should group related components together in separate namespaces. Ā©NIIT Creating and Managing Components Lesson 1A / Slide 5 of 24
  • 6. Creating Components Life Cycle of a Component ā€¢ Components are initialized by constructors. ā€¢ Initialization can be of two types: ā€¢ Type initialization ā€¢ Type initialization is achieved by using a shared constructor. ā€¢ Shared constructor is called only once in the lifetime of a Visual Basic .NET application. ā€¢ Instance initialization. ā€¢ Instance initialization can be achieved by using constructors, which are not shared. Ā©NIIT Creating and Managing Components Lesson 1A / Slide 6 of 24
  • 7. Creating Components Polymorphism in Components ā€¢ The ability of a class to implement functions with the same name that are performing different actions depending on how they are called is known as polymorphism. ā€¢ Polymorphism can be implemented by: ā€¢ Implementing an interface. ā€¢ Inheritance ā€¢ Using abstract classes. Ā©NIIT Creating and Managing Components Lesson 1A / Slide 7 of 24
  • 8. Creating Components Implementing Interfaces ā€¢ An interface defines the behavior of a class. ā€¢ An interface can declare properties, methods, and events. ā€¢ An interface can be implemented by more than one class. ā€¢ An interface can be declared as : Interface interfacename Sub functionname() End Interface Ā©NIIT Creating and Managing Components Lesson 1A / Slide 8 of 24
  • 9. Creating Components Using .NET COM Components in VB.NET ā€¢ Component Object Model (COM) was used in earlier versions of Visual Basic to create components. ā€¢ Implementation of COM is called ActiveX. ā€¢ The .NET supports COM and ActiveX objects for backward compatibility. ā€¢ A COM component from .NET can be called in the following ways: ā€¢ By converting the COM type library to a .NET assembly. ā€¢ Using COM components directly. Ā©NIIT Creating and Managing Components Lesson 1A / Slide 9 of 24
  • 10. Creating Components Converting COM Type Library to .NET Assembly ā€¢ The tlbimp tool can be used to convert a COM type library to a .NET assembly. ā€¢ Following options can be used with tlbimp tool: ā€¢ out:FileName ā€“ specifies the name of the assembly to be produced. ā€¢ Namespace:NameSpace ā€“ Specifies the namespace of the assembly to be produced. ā€¢ AsmVersion:Version ā€“ Specifies version number of the assembly to be produced. ā€¢ reference:FileName ā€“ Specifies the file name to be used to resolve references. Ā©NIIT Creating and Managing Components Lesson 1A / Slide 10 of 24
  • 11. Creating Components Using COM Components Directly ā€¢ The Com components can be added directly through Solution Explorer in .NET. ā€¢ Internally, an Runtime Callable Wrapper (RCW) is used to access the COM components. Ā©NIIT Creating and Managing Components Lesson 1A / Slide 11 of 24
  • 12. Creating Components Using COM+ with VB.NET ā€¢ COM+ is the basic COM and a set of additional services. ā€¢ COM+ programming is based on the following assumptions: ā€¢ In COM+, clients program on the basis of Interfaces, not Classes. ā€¢ Code is not linked statically. ā€¢ Using Com+ components, you can focus on developing business logic. ā€¢ A .NET component that takes advantage of COM+ services needs to be derived from the .NET base class ServicedComponent. Ā©NIIT Creating and Managing Components Lesson 1A / Slide 12 of 24
  • 13. Creating Components Properties and Methods for a Component ā€¢ To create a component in .NET, the user needs to identify: ā€¢ The type of component. ā€¢ Properties for the component. ā€¢ Methods for the component. Ā©NIIT Creating and Managing Components Lesson 1A / Slide 13 of 24
  • 14. Creating Components Using Constructors ā€¢ A component can have the following types of constructors: ā€¢ Public constructors. ā€¢ Friend constructors. ā€¢ Private constructors. Ā©NIIT Creating and Managing Components Lesson 1A / Slide 14 of 24
  • 15. Creating Components Adding properties ā€¢ Declaring a property allows you to control how a value is changed or read. ā€¢ Calculated values can be shown as properties even when they are not stored as actual data in the class. ā€¢ Property statement can also incorporate error handling. Ā©NIIT Creating and Managing Components Lesson 1A / Slide 15 of 24
  • 16. Creating Components Adding methods ā€¢ If a method is declared Private, only methods within the same class can call that method. ā€¢ A method in a class is a procedure that performs some sort of operation on the data within the class and may or may not return. ā€¢ A method is declared as: Public Function functionname() As Integer Ā©NIIT Creating and Managing Components Lesson 1A / Slide 16 of 24
  • 17. Creating Components Referencing the Component from the User Interface ā€¢ A component can be tested only by referencing it from another application. ā€¢ A component can be referenced by using the Solution Explorer. Ā©NIIT Creating and Managing Components Lesson 1A / Slide 17 of 24
  • 18. Creating Components Role of Assemblies in VB.NET ā€¢ Concept of assemblies has been introduced in the .NET to counter the problems faced in DLL handling in previous versions. ā€¢ An assembly usually consists of: ā€¢ Manifest ā€¢ This contains the information like name and version of the assembly. ā€¢ Information about the files that the assembly uses, is also present in it. ā€¢ Portable executable (PE) ā€¢ This contains metadata, Intermediate Language (IL) and the type information. Ā©NIIT Creating and Managing Components Lesson 1A / Slide 18 of 24
  • 19. Creating Components Demo Using .NET Components Ā©NIIT Creating and Managing Components Lesson 1A / Slide 19 of 24
  • 20. Creating Components Problem Statement ā€¢ Build a .NET DLL component ā€˜PickServerTimeā€™ which can get the current date and time from the host computer and then use the component in another VB.NET application named as ConsumerApplication which will display the information. Ā©NIIT Creating and Managing Components Lesson 1A / Slide 20 of 24
  • 21. Creating Components Solution ā€¢ To build and use the ā€˜PickServerTimeā€™ component in an application named as ā€˜ConsumerApplicationā€™ , you need to perform the following steps: 1. Create a project. 2. Add properties and functions to the component. 3. Build the component. 4. Create a user interface to test the component. Ā©NIIT Creating and Managing Components Lesson 1A / Slide 21 of 24
  • 22. Creating Components Summary In this lesson, you learned that: ā€¢ A component is a reusable piece of code in binary form that can be used along with the components from other vendors, with relatively little effort. ā€¢ Types of Components: ā€¢ In-built components. ā€¢ Component classes. ā€¢ User controls. ā€¢ A component goes through different stages once you deploy it. The constructors initialize components. ā€¢ Initialization can be of two types: ā€¢ Type initialization. ā€¢ Instance initialization. Ā©NIIT Creating and Managing Components Lesson 1A / Slide 22 of 24
  • 23. Creating Components Summary (Contd.) ā€¢ In .NET programming environment, COM components are called: ā€¢ By converting the COM type library to a .NET assembly. ā€¢ By using COM components directly. ā€¢ The tlbimp tool uses the metadata of a COM type library to do the conversion. ā€¢ To create a component in .NET, the user firstly needs to identify the type of component and also its properties and methods. ā€¢ In .NET programming environment, a component can have the following types of constructors: ā€¢ Public constructor. ā€¢ Friend constructor. ā€¢ Private constructor ā€¢ An assembly contains information about the files on which the component depends and the location of these files. ā€¢ An assembly consists of a manifest and the portable executables (PE). Ā©NIIT Creating and Managing Components Lesson 1A / Slide 23 of 24
  • 24. Creating Components Summary (Contd.) ā€¢ A manifest consists of information such as the name and version of the assembly. ā€¢ A portable executable consists of the IL code, type information, and metadata. Ā©NIIT Creating and Managing Components Lesson 1A / Slide 24 of 24