Pub. Date:
Developing Applications with Visual Studio. NET

Developing Applications with Visual Studio. NET

by Richard Grimes


Current price is , Original price is $49.99. You
Select a Purchase Option
  • purchase options

Product Details

ISBN-13: 9780201708523
Publisher: Addison-Wesley
Publication date: 02/11/2002
Series: Developmentor Series
Pages: 832
Product dimensions: 7.50(w) x 9.25(h) x 1.75(d)

About the Author

Richard Grimes is an independent consultant specializing in COM, ATL, and .NET. He is the best-selling author of a number of books written for Wrox Press, including Professional Visual C++ MTS Programming (1999), Beginning ATL 3 COM Programming (1999), Professional ATL COM Programming (1998), and Beginning ATL COM Programming (1998).


Table of Contents

(NOTE: Each chapter concludes with a Summary.)



1. NET Runtime.

.NET Features.

.NET Languages.

Executing Code.


Garbage Collector.




Managed and Unmanaged C++ Classes.

Value Types.


Managed Arrays.

Member Access.

Common Language Specification.

Other .NET Features.


Metadata and Attributes.




Packaging and Deployment.

Assemblies and Modules.

Versioning before .NET.

Locating and Versioning .NET Assemblies.

Application Domains.

Administering Security.

2. Framework Class Library.

The Win32 API.

Memory Allocation.

Error Handling.

Framework Class Library.

The Core Library.

General-Purpose Classes.

System Classes.

Tracing and Debugging.




GDI+ and Windows.




Other Framework Class Library Classes.

Event Log.

Performance Counting.

Process Information.


Message Queuing.

3. Contexts and Remoting.


Context Bound and Context Agile.

Passing Parameters by Reference and by Value.

Marshaling Objects between Contexts.

Context Sink Chains.

Dynamic Properties and Sinks.

Tracking Handler s.


Serializing Objects.


Object Manager.

Custom Serialization.

MSMQ Serialization.


.NET Remoting.

.NET Remote Components.


Leases and Lifetime.

Message Sinks and Channels.


Extending the Remoting Framework.



Web Services.


Managed Web Services.

SOAP Invocation.

Web Service Clients.

ASP.NET Services334

Web Services and Security.

Asynchronous Programming.

Asynchronous Delegates.

Fire and Forget.

Delegates and Remoting.

4. Interoperation and COM+.


Interop with Native Code.

Calling DLLs.

Platform Invoke.

String Conversions.

Errors and Exceptions.

Data Flow Direction.


Arrays and Buffers.


Explicit Allocation of Buffers.

Unmanaged Exceptions.

Unsafe Code.

COM Interop.

Interop of COM and Managed Code.

COM Callable Wrapper.

Exporting Type Information.


Runtime Callable Wrapper.

COM Automation Types.

COM Interface Types.

COM Events.

COM Aggregation.

COM Interop and the CRT.

Component Services.

Serviced Components.

Assemblies and Applications.

COM+ Context.

Object Pooling.


COM+ Security.

Queued Components.

Loosely Coupled Events.

Catalog Configuration.

5. Visual Studio.NET Environment.

The Visual Studio Environment.

Menus, Commands, and Shortcut Keys.

Docking Windows and Toolbars.


Start Page.

Projects and Solutions.

Project Types.

Project Wizard Files.

Project Files.

Solution Configurations.

Project Configurations.

Project Properties.

Configuring Code.

Adding Items to C++ Projects.

Resource View.

Adding Items to C# Projects.

Adding References.

Class View.


C# Resources.

Editing Code.

The Text Editor.

HTML Editor.

XML Editor.



Binary Editor.

Searching and Browsing Code.

Find In Files.

Find In Project.

Command Window.

Incremental Searches.



Object Browser.


External Tools.

The Help System.


Clipboard Ring.

The Macro Explorer and Editor.

Add-In Manager.

The VS.NET Command Line.

6. Creating and Building Solutions.

C++ and C# Project Types.

ATL Projects.

MFC Projects.

Managed C++ Projects.

Other C++ Projects.

C++ Project Options.

C# Project Types.

C++ Classes.

Simple Object.

COM+ Component.


Performance Monitor.

C# Classes.

Components, Controls, and Forms.

Inherited Forms and Controls.


Enterprise Template Projects.

Enterprise Solutions.

Enterprise Template Files and Proxy Projects.

Policy File.

Server Explorer.

Data Connections.

Servers Node.

The Build Process.

Source Control.

Customizing Builds.

Building and Task List.

Deploying Solutions.

Deployment Solutions.

Visual Studio Analyzer.

7. Visual C++ .NET.


A Few New Keywords.

ATL Attributes.


ATL Object Map.

ATL Server Project and ATL Server Web Service.

Managed Extensions for C++.

Class Declaration.

Member Access.

Properties and Fields.

Compiling to IL.

.NET Pointers.

Managed C++ and Interfaces.

Multiple Interfaces.

Managed Arrays.

Managed Strings.



Global Methods.

Using Managed Code in Unmanaged Code.

Using Managed Types within Unmanaged Types.

Calling Managed Code.

8. Application Development.

Developing Components.

Developing Controls.

Developing a Sample Control.

Property Editor.


Toolbox Items.

Resources and Internationalization.

Resources and .NET.

Locales, Cultures, and Languages.

Creating Resources.

Managed C++ and Resources.

C# and Resources.

Forms and Localization.

Resource Classes.

Satellite Assemblies.

The Event Log, Again.

Win32 Resources.

9. Debugging.

IDE Tool Windows.

Setting Breakpoints.

Threads and Modules Windows.

Call Stack Window.

Watch Windows.

Memory Windows.

Using the Command Window.

Formatting Values.


Edit and Continue.

Using the Debugger.

Starting Debugging.

Start-up Options.



Compile-Time Checks.

Compiler Runtime Checks.

Remote Debugging.

Disassembly Window.

Debug Symbols.

Debugging ATL Server Projects.

CRT and ATL Memory Debugging.

ATL Interface Debugging.

Index. 0201708523T01242002


.NET is a whole new way to program. It has taken me a while to get used to using it, but now I feel that .NET is the future of developing code. The two main features that .NET brings are the runtime and the Framework Class Library. The runtime executes all .NET code and provides a secure environment. The Framework Class Library is available to all .NET code regardless of the language that is used to create that code. The library is a culmination of all the libraries that Win32 developers are accustomed to using, and some APIs are provided through a new paradigm, but others are mere mirrors of the Win32 APIs that they replace. The significant point is that all of the APIs are accessed in the same way, so the application developer no longer has to learn multiple ways to access libraries (DLL exported functions, class libraries, template libraries, COM). The intention is to put more focus on using the APIs than on accessing them.

I have spent a considerable amount of time determining how .NET works and how the various classes in the library are related. On occasion it was a joy to see how .NET had provided a new API that put more power in the hands of the developer, and on a few occasions I was frustrated to see that .NET had provided a solution that reduced the facilities offered to the developer. In this book I want to give you the benefit of my odyssey through .NET. I will enthuse when .NET does it right, and I will tell you straight when .NET does it wrong.

One thing is clear: .NET is here to stay. Expect in the future that Microsoft will put more and more emphasis on .NET. Your future as a developer will be intimately entwined with .NET, and by becoming familiar with .NET now, you'll ensure that you'll be ready for whatever Microsoft decides to release in the future.

Intended Audience

I have deliberately decided to target C++ Win32 developers. This book has no VB.NET code and only the barest minimum of ASP.NET. If you want to develop in VB.NET, or you want to develop Web applications with ASP.NET, there are other excellent books that will suit you better than this one.

I also make no excuses about the fact that this book is packed full of details, and in places it touches on tough concepts. I have worked hard to glean the information that I present in this book. I didn't have access to privileged knowledge. What you see here is the result of writing many hundreds of test applications, of pouring over IL generated with ILDASM, and of single-stepping through code with the .NET debuggers. Where I present code, you can be assured that what you see is code that I have written and tested. When I describe how an API works, you can be assured that I have determined that behavior by actually trying out the code. I have worked hard to write this book, and I expect you to work hard as you read through it. That way you'll have the enlightening learning experience that I had.

What to Expect

My intention when writing this book was to give you a grand tour of developing applications with Visual Studio.NET. As with all grand tours, you have to do a lot of preparation before you can start. For this reason the book is split into three parts: The first four chapters describe the .NET Framework, Chapters 5 through 7 describe the tools in Visual Studio.NET that you can use to develop applications, and Chapters 8 and 9 explain how to develop and debug applications.

The chapters follow a logical progression from a basic description of the .NET Runtime, through a description of the framework and the tools to develop .NET executables and libraries, to developing applications with the Visual Studio. NET design environment. I made a deliberate choice to leave an introduction of Visual Studio.NET until Chapter 5 because much of the development that you can do with .NET can be done with a simple text editor like Notepad (indeed, I urge you to use Notepad as you work through the first few chapters). However, at the point that your project grows larger than a handful of files, at the point that you move away from trivial resources and XML files to use more real-life files, you'll start to realize that you need a more accomplished editor and tools to help you develop your application.

It is at this point that you'll need to use Visual Studio.NET. If you use VS.NET before you've gone through the details of .NET's facilities, you won't appreciate the tools that VS.NET provides. I also want to give you the impression that there is a life beyond wizard-generated code.

The following is a brief description of what to expect in the chapters of this book.

Chapter 1: .NET Runtime

In this chapter I start exactly where I should: right at the beginning with a description of the .NET Runtime. The runtime executes all .NET code, so in this chapter I describe the basic concepts of the runtime and how it locates and runs code. I describe the languages that you can use and various .NET features used to generate events, to provide error information, and to access code outside of the current code module. Then I describe the .NET facilities for adding type information to a code module, and how you can add custom type information. Finally, I explain how code is packaged and the new mechanism for locating and loading that code.

Chapter 2: Framework Class Library

I use this chapter to give an overview of what I consider to be the "core" library. The framework library is available to all .NET languages and can be considered to be a culmination of the various APIs that Win32 developers are accustomed to using. The Framework Class Library contains many classes, and I have chosen to explain just a few. These are the classes that you are most likely to use--the classes without which you are unlikely to be able to do any .NET development.

I explain threading, basic input/output using streams to files and to the console, the debugging classes, and collection classes. Once I have made the foundation with the fundamental classes, I follow up with a description of the user interface classes to allow you to create windows and draw in those windows. Finally, I describe what I call the "other" classes. Strictly speaking, they are not core classes, but they are important for application development, so I give an overview of these classes and how to use them.

Chapter 3: Contexts and Remoting

.NET provides a new level of code isolation: application domains, which I introduced in Chapter 1. In this chapter I explain how code in one application domain can access code in another domain: .NET remoting. .NET defines an idea called context--domain membership is one property of a context--and .NET needs to take special action to allow calls to be made across contexts. I explain how cross-context calls are made and how you can change the way that .NET manages these calls.

This chapter explains in detail how .NET remoting works, the types of objects that can be accessed remotely, how long they live, and the security aspects of accessing those objects. Finally, the chapter has a description of asynchronous programming, including how exceptions and return values are handled when a call is made asynchronously.

Chapter 4: Interoperation and COM+

Interoperation is required to allow your .NET code to access native code. In this chapter I cover all aspects of interoperation from accessing DLLs, through Platform Invoke, to accessing COM and COM+ components. I start by describing how Platform Invoke works and contrast this to how you can access native C++ code from managed C++. I also explain marshaling non-simple types, how exceptions are handled, and "unsafe" code.

In the second half of the chapter I explain how interoperation with COM and COM+ is achieved. .NET provides tools to allow you to use COM objects in .NET code and to use .NET objects in COM code. I show you how to use these tools and describe how COM concepts like events, aggregation, and registration are achieved. The final part of the chapter explains the .NET classes that allow you to write COM+ classes.

Chapter 5: Visual Studio.NET Environment

By this point in the book you should have a good grounding in the facilities that .NET offers and the classes that you can use. In this chapter I introduce you to the facilities in Visual Studio.NET that you can use to develop .NET code. I start with a general description of the user interface: the various windows and toolbars that are provided. I then give a brief description of the code-generating wizards and the UI features of VS.NET that you can use to change the code that is generated.

In the latter half of the chapter I explain how to manage your code and the tools that you can use to search in your code and to get help. Finally, I explain the Toolbox and how to use external tools.

Chapter 6: Creating and Building Solutions

In this chapter I look in detail at how you create and build solutions. A solution is a collection of projects, and a project contains source files that are compiled to create an output. I start this chapter by explaining the various project types that you can add to a solution and the various classes that you can add to those projects. Following the general theme of this book, I explain only C++ and C# classes, but I do include a description of the C++ projects that create native code.

In the second half of the chapter I explain how to build and deploy solutions. I describe how to start a compilation, and how to customize it. I also explain how you can deploy the outputs from a solution and the various project types that are provided to do this.

Chapter 7: Visual C++.NET

C++ is the most flexible of the .NET languages. Visual C++ allows you to develop both native and managed code, as well as a mixture of the two. I start this chapter by describing the new features in ATL, beginning with a description of Visual C++ attributes and an explanation of how these help your development. Then I explain ATL Server, which is used to write ISAPI extensions for Web applications and Web Services.

The rest of the chapter is concerned with managed code, and I explain how managed C++ differs from native C++ in declaring classes and in handling interfaces, arrays, and strings.

Chapter 8: Application Development

This chapter is concerned with two main subjects: developing UI controls and forms, and localizing resources. In the first half of the chapter I explain components and controls and lead you through the process of developing a control that is integrated with the Visual Studio.NET Toolbox and Properties windows. In the second half of this chapter I describe .NET resources and how you can use the Visual Studio.NET tools to create localized resources.

Chapter 9: Debugging

After you have designed, written, and built your application, the next step will be to check that it does what it is designed to do, and to correct code that is in error. That is, you will have to debug your application. Visual Studio.NET allows you to debug both native and managed code, and even to step from the managed to the unmanaged world and vice versa. In this chapter I explain all the facilities that you can use to debug your code: how to set breakpoints, how to use the debugging windows, and how to debug more than one process.


Customer Reviews

Most Helpful Customer Reviews

See All Customer Reviews