Sams Teach Yourself .Net in 21 Days
- Table of Contents
- Copyright
- About the Author
- About the Technical Editor
- Acknowledgments
- We Want to Hear from You
- Introduction
- Week 1: At a Glance
- Day 1. Introduction to the Microsoft .NET Framework
- Day 2. Introduction to Visual Studio .NET
- Day 3. Writing Windows Forms Applications
- Day 4. Deploying Windows Forms Applications
- Day 5. Writing ASP.NET Applications
- Day 6. Deploying ASP.NET Applications
- Day 7. Exceptions, Debugging, and Tracing
- Week 1. In Review
- Week 2: At a Glance
- Day 8. Core Language Concepts in Visual Basic .NET and C#
- Day 9. Using Namespaces in .NET
- Day 10. Accessing Data with ADO.NET
- Day 11. Understanding Visual Database Tools
- Day 12. Accessing XML in .NET
- Day 13. XML Web Services in .NET
- Day 14. Components and .NET
- Week 2. In Review
- Week 3: At a Glance
- Day 15. Writing International Applications
- Day 16. Using Macros in Visual Studio .NET
- Day 17. Automating Visual Studio .NET
- Day 18. Using Crystal Reports
- Day 19. Understanding Microsoft Application Center Test
- Day 20. Using Visual SourceSafe
- Day 21. Object Role Modeling with Visio
- Week 3. In Review
Introduction to Components
Components mean different things to different people. To me, a component is code that's compiled into a dynamic link library (DLL) that can be shared across applications. Even if the DLL isn't shared across applications, it provides me with the ability to encapsulate my application logic into specific parts. I might have a data access component, a utility component, and a security component. By splitting apart the core functionality of my applications in separate DLLs, I can modify the behavior of the application without modifying the code in the user interface.
This type of development is especially effective in traditional Active Server Pages (ASP) applications. Because ASP is script, and not compiled, you could achieve performance gains by putting code in DLLs and having the ASP application call methods in the DLLs. Doing so avoids the overhead of Internet Information Server (IIS) having to process the thousands of lines of script code that would have existed inside the ASP page itself.
Writing components is done using the ActiveX DLL template in Visual Basic 6. By implementing methods, properties, and events in class modules, you can compile your code into a component object model (COM) DLL and use it anywhere you need it. You create reusable objects, as long as the DLL is registered correctly on that machine that's attempting to consume it.
In .NET, the concept of writing components is the same, but it's taken to the next level. Because the core of .NET is based on inheritance, you can inherit from specific classes to give your component the functionality you want. Depending on what type of component you need to write, you can inherit from different base classes to expose functionality to your component that you would have had to write if you were using Visual Basic 6.
Understanding the Component Types | Next Section

Account Sign In
View your cart