Smart Client Deployment with ClickOnce: Deploying Windows Forms Applications with ClickOnce

Smart Client Deployment with ClickOnce: Deploying Windows Forms Applications with ClickOnce

Paperback

$42.57 $49.99 Save 15% Current price is $42.57, Original price is $49.99. You Save 15%.
View All Available Formats & Editions
Choose Expedited Shipping at checkout for guaranteed delivery by Wednesday, December 11

Overview

“ClickOnce demos may look simple, but those techniques only work for simple applications. Brian Noyes gives us the information we need to use ClickOnce in the real world, and he does it with a comprehensive and organized presentation. If you expect your smart client application to move very far beyond ‘Hello,World,’ you’ll want this book to help you deploy it.”
Billy Hollis, president/owner, Elysian Consulting, Microsoft Regional Director
“Once again Brian has outdone himself. As a writer, I tend to be very critical of all technical publications, including my own . . . and it is such a pleasure to read anything Brian writes because he studies his topics well, resulting in an accurate, thorough, yet concise piece of work. ClickOnce being a new technology that deals with the pains we all have with application deployment, versioning, and security, it is important to have a text that will guide you through the learning process, give you sound advice for adopting the technology, and explain why you should even care. Brian gives his readers all of that.”
Michele Leroux Bustamante, chief architect, IDesign, Microsoft Regional Director
“ClickOnce is the key to Windows and smart client deployment. Brian’s book is the key to successfully using ClickOnce. This book walks you through using ClickOnce, from the basics to advanced scenarios. It is an excellent resource.”
Rockford Lhotka, principal technology evangelist, Magenic Technologies, Microsoft Regional Director
“Brian covers ClickOnce with a view to real-world deployment issues, which isobviously based on real-world experience. In and of itself, that is enough forme to buy the book. However, it is an even better investment by virtue of thefact that ClickOnce is a core part of the .NET Framework for Windows Forms2.0 now, and Windows Presentation Foundation in the future.”
Michael Weinhardt, SDK programmer/writer, Application Model,Windows Presentation Foundation, Microsoft
“This book covers the most important ingredient needed for the success of asmart client application—deployment. The author’s unassuming writing style,combined with his in-depth coverage of the topic, makes this book an invaluableresource for all serious smart client developers.”
Vishwas Lele, principal architect, Applied Information Sciences,Microsoft Regional Director

Microsoft’s new ClickOnce auto-updating technology can radically simplify application deployment. Using it, .NET developers and architects can deliver a powerful, smart client experience along with the easy maintenance of today’s best Web applications.

Microsoft Regional Director and MVP Brian Noyes has unsurpassed experience previewing and teaching ClickOnce to professional developers. In Smart Client Deployment with ClickOnce, Noyes demonstrates exactly how to make the most of ClickOnce in your real-world enterprise applications. Noyes covers ClickOnce design, architecture, security, installation, updates, and Bootstrapping—each with a full case study and detailed sample code.

This focused, concise book explains how to

  • Design client applications for efficient deployment and auto-updating
  • Perform application deployments and automatic updates quickly and easily
  • Deliver “on-demand” client application updates
  • Deploy prerequisites with the Visual Studio 2005 Bootstrapper
  • Take full control of ClickOnce’s powerful publishing, update, and security options
  • Leverage the Visual Studio 2005 and .NET 2.0 platform features that make ClickOnce possible
  • Understand how your application will behave in the ClickOnce runtime environment

The book’s sample code is available for download at www.softinsight.com/clickoncebook.

Product Details

ISBN-13: 9780321197696
Publisher: Addison-Wesley
Publication date: 01/10/2007
Series: Microsoft Windows Development Series
Pages: 298
Product dimensions: 6.92(w) x 9.26(h) x 0.84(d)

About the Author

Brian Noyes is a software architect, trainer, writer, and speaker with IDesign, Inc. (www.idesign.net), a premier .NET architecture and design consulting and training company. He is a Microsoft Regional Director (www.microsoft.com/rd) and Microsoft Most Valuable Professional (MVP), and has been developing software systems for more than sixteen years. He speaks at many major software conferences around the world, and writes for a variety of software journals and magazines. He lives in Alexandria, Virginia, but is a Southern California surf bum at heart, having grown up there. Prior to becoming a full-time software developer, Brian flew F-14 Tomcats in the U.S. Navy and graduated from the Navy Fighter Weapons School (TopGun) and the U.S. Naval Test Pilot School. Brian has a master’s degree in computer science from the University of Colorado, Boulder, a master’s degree in aerospace engineering from the Naval Postgraduate School, and a bachelor’s degree in aerospace engineering from the U.S. Naval Academy.

Read an Excerpt

Deployment has been a thorn in most developers’ sides for a long time. Developing complex distributed applications is challenging enough just from a design and implementation perspective. Failing to plan for deployment or having the deployed environment change on you can kill an application quickly, no matter how well you plan for it. ClickOnce does not solve this problem, but it definitely takes a big step in the right direction for streamlining deployment of smart client applications.

I was first exposed to ClickOnce more than three years ago at an early adopter lab on the Microsoft campus in Redmond. At the time, I was just starting to get immersed in smart client technology and beginning to think about how to address all aspects of the application lifecycle as an architect. Having experienced a fair amount of deployment pain myself in the past, I instantly fell in love with ClickOnce as a technology. I quickly saw the potential for ClickOnce to be a key enabler for the broad adoption of smart client architectures because without a way to get those smart client applications in your users’ hands, you might as well not build them.

The most common question that I got as I was working on this book was, “How can you write a whole book on ClickOnce?” This usually came from someone who had seen demos of ClickOnce but had not yet tried to use it for something real. ClickOnce is incredibly powerful, yet it seems simple on the surface. It takes only five to ten minutes to run an end-to-end demo of what ClickOnce can do for you. When people have seen this kind of presentation of ClickOnce, they do not realize that ClickOnce addresses a lot more than a singlecommon deployment scenario. However, whenever you try to provide flexibility and power, a fair amount of complexity also comes along with it.

I think the ClickOnce team did a really good job of making the simple, straightforward use of ClickOnce as easy as possible. If you are building a new smart client application from scratch with ClickOnce in mind, using ClickOnce to deploy it requires minimal effort for both your administrators and your users. However, real applications are rarely simple and straightforward (even though, because of poor architecture, the complexity is often unnecessary or disproportionate to what the applications are designed to do). ClickOnce has many variations and options that let you address a broad range of scenarios to deal with those complexities. And once you start getting into those capabilities, you dive into the deep end of the ClickOnce pool and really need to understand a lot more about what is going on under the covers; what the effects are of setting publishing, update, and security options different from the defaults; how your application is going to behave in the ClickOnce runtime environment; and so on.Who Should Read This Book?

This book is written for those developers and architects who need to understand the full range of capabilities of ClickOnce so that they can make educated decisions early in the development lifecycle and put those decisions into practice when the product is getting close to complete. You will need this understanding to make sure you can get your smart client applications deployed through ClickOnce and to address the complexities of real-world applications in that environment. It is primarily written for intermediate to advanced developers or architects, but IT professionals who are responsible for deploying and maintaining ClickOnce applications can also get a lot out of most of the chapters as well.

This is not a book about programming, although there are aspects of ClickOnce covered in several of the chapters that require coding to use. ClickOnce is mainly driven through Visual Studio project configuration, tools, and processes, not through code. So a fair percentage of the book will describe these aspects, and only a small portion will discuss code directly.

There is a programmatic API that is discussed in several chapters, and there are other coding practices that are important from within your application that can affect the deployment and execution of a ClickOnce application. For the sections that cover coding, I expect that readers already know how to code .NET applications. I will point out appropriate references when necessary for complex topics, but to understand the code samples, you need to have some experience developing Windows Forms applications in .NET.1 Conventions

Deploying ClickOnce applications is mostly about tools and less about code. However, there are a number of code samples in this book, and to help make things easier, I have adopted some common conventions.

First, any time I refer to classes, variables, namespaces, and other artifacts that manifest themselves in code, I will use a monospace font to make it clear if I am talking about an instance of the

ApplicationDeployment class as opposed to talking about a coding construct in a conceptual way. Short code listings will be presented inline within the text using a monospaced font as well.

Longer listings will use a similar font, but will be broken out into labeled listings that can be referred to throughout the text (based on listing numbers). Within code listings, I will sometimes set in

bold particularly relevant portions of the code, especially to highlight “evolving code.” I may remove details that are not relevant to a discussion, and if so will insert a comment that indicates that there are more details, identifiable by a comment with an ellipses (

//...). What this means is that more code is needed to complete the example or that there exists more code generated by the designer, but you don’t need it to understand the concept. On occasion, I will add explanatory comments to code in order to show context. System Requirements

This book was written using the released version of Visual Studio 2005 and the .NET Framework 2.0. ClickOnce capabilities are available in all versions of Visual Studio, including Visual C# 2005 Express and Visual Basic 2005 Express. You do not need Visual Studio to use ClickOnce because it is a core capability of the .NET Framework, but to use ClickOnce for any serious project, you will need Visual Studio to do the initial publishing. Throughout the book, I will refer to Visual Studio instead of Visual Studio 2005 for brevity, but you can always infer that I mean Visual Studio 2005 or one of the Express versions (even though they do not have “Studio” in their official names).

If you plan to run the samples available from the download site or the walkthroughs and code listings in this book, you will need a version of Visual Studio 2005, Visual C# 2005 Express, or Visual Basic 2005 Express installed on your machine. One of the samples uses a SQL Server 2005 Compact Edition database to provide sample data to the application, but it includes the libraries needed to run that. One sample uses the Northwind database to provide sample data. Because the particular functionality of the application is not important to the topic being covered (how to deploy and update these applications with ClickOnce), don’t get wrapped up in trying to get these samples running if you don’t already have the databases available; just create an empty Windows Forms application and use it. Choice of Language

I chose to present the code samples in this book in C#. The downloadable code is available in both C# and Visual Basic. It is a fact of life that there will continue to be a mix of C# and Visual Basic available in articles, books, and code samples for a long time to come. Even though I prefer C# myself, that is just a preference, and I feel that Visual Basic is a solid choice for developers who have a strong background in earlier versions of Visual Basic.

I firmly believe that to be an effective .NET developer, you need to be able to read code from either language, even if you spend most of your time with one. If you are not already comfortable reading C# code, I encourage you to use this opportunity to get comfortable with reading C#. It will expand your horizons in terms of the amount of reference material that is available to you, it may help you in your job, and it will give you bragging rights over the many silly and close-minded C# developers who can’t or won’t read Visual Basic.Chapter Overview

This book steps you progressively through all of the concepts you will need to master to use ClickOnce to deploy real-world smart client applications. It starts with the basics in the first chapter, giving you a high-level view of ClickOnce and the surrounding context of smart client applications. Then it steps through deploying and updating applications, with all the associated options. It then focuses on more of the infrastructure for ClickOnce deployment, including how to manage application files, security, prerequisites, and advanced capabilities. It ends with an appendix that tells you what is different with respect to Windows Presentation Foundation application deployment (not much).

Here is a quick breakdown of the contents of each chapter.

Chapter 1: Introduction to ClickOnce. This chapter sets the context for the rest of the book. It starts by describing what a smart client application is and what deployment challenges ClickOnce was designed to address. It describes the high-level features of ClickOnce, and then walks you through a sample deployment and update of a client application using ClickOnce. This chapter wraps up describing the system requirements for ClickOnce, how it relates to other deployment technologies, when to use it and when not to, and a quick discussion of smart client architecture.

Chapter 2: Initial Deployment with ClickOnce. This chapter covers the process of publishing an initial version of an application and deploying it to clients. It discusses all of the publishing options that you have available for getting your applications placed on the deployment server and what that process involves using Visual Studio. It describes what happens when the user deploys the application to the client machine using ClickOnce from an end user’s perspective, and what is going on under the covers. It finishes by describing the process of manually publishing your application using the SDK Mage tools for an environment where Visual Studio cannot access the production servers.

Chapter 3: Automatic Application Updates. This chapter covers the capabilities of ClickOnce for automatically deploying application updates to users. The publishing for updates is discussed briefly because it is effectively the same as for initial deployment. Then the deployment process is detailed, showing what the experience is for users and what the options are. The chapter describes all of the options you have for configuring when and how updates occur. It discusses what happens behind the scenes on the deployment server as well as on the client machine when an update is detected and deployed. It also covers how to manage rolling back an update either from the client or the server side.

Chapter 4: On-Demand Updates. This chapter builds on Chapter 3, showing how to use the programmatic API for ClickOnce to trigger updates from your application code. It discusses performing synchronous and asynchronous updates, detecting updates, and pulling them down when desired using the API. It covers several strategies for doing the updates asynchronously to avoid blocking the client application. It also describes other functionality exposed through the API, including the ability to check detailed update information and find out about the version of the application that is currently deployed on the client machine.

Chapter 5: Application and Data File Management. This chapter discusses in detail managing the files that your application is composed of. It describes how ClickOnce treats those files, how to select and control what files get deployed with your application, and where they will end up on the client machine. It discusses download groups, which provide a way to download portions of your application files on demand. It discusses managing application data files, and how those files are migrated by ClickOnce when an application update occurs. It covers using plug-in DLLs in a ClickOnce application to enhance your application’s functionality with individual optional modules. The chapter closes by covering how to manage the application files that get published using the SDK Mage tools.

Chapter 6: ClickOnce Security. This chapter discusses the security features and protections of ClickOnce in detail. It covers the deployment time and runtime protections for the client machine, and discusses the tamper protections for the application files both on the server and client sides. The chapter describes how to configure and control what permissions the application requires, and how those permissions are evaluated and granted on the client machine. It discusses how user prompting can be used for permission elevation, and how to use the Trusted Publisher mechanism to automatically elevate permissions based on an administrator’s predeployed publisher certificate. It covers managing the ClickOnce manifest digital signature with publisher certificates. Finally, the chapter covers how to protect sections of your application from malicious code and includes a quick introduction to using role-based security in .NET to restrict permissions in the client application based on user roles.

Chapter 7: Prerequisite Deployment with the Bootstrapper. This chapter covers how to get things preinstalled on the client machine that cannot be deployed through ClickOnce. It discusses the Bootstrapper’s features for wrapping multiple installer packages and running them through a single launch experience on the client machine. It describes creating and configuring Bootstrapper manifest files, and what the runtime experience is when deploying prerequisites. The chapter steps through several scenarios of types of files you might want to deploy with the Bootstrapper.

Chapter 8: Advanced ClickOnce Topics. This chapter covers a variety of additional questions that often come up for ClickOnce applications to address specialized scenarios. The chapter discusses using command line parameters, debugging ClickOnce applications, deploying non-.NET applications with ClickOnce, working with the Firefox Web browser, and deploying COM components with your application, to name a few.

Appendix A: ClickOnce Deployment of WPF Applications. The appendix covers the differences in using ClickOnce with Windows Presentation Foundation (WPF) applications. For the most part ClickOnce works the same with WPF, but there are some subtle differences. The appendix covers the Web Browser Application model, what you need to do differently when creating and publishing the project, and how the application deploys and runs on the client machine.Book’s Web Site and Sample Download Code

The Web site for this book is at www.softinsight.com/clickoncebook. All of the sample code in this book is available for download on that site. Links are available on the site to other ClickOnce-related resources, including the author’s blog (www.softinsight.com/bnoyes/). Note:

1. Windows Forms 2.0 Programming by Chris Sells and Michael Weinhardt (Addison-Wesley, 2006) is the best overall reference and tutorial for learning all aspects of Windows Forms programming. My other book in this series, Data Binding with Windows Forms 2.0 (Addison-Wesley, 2006), will give you a deep dive on how to present data in your applications. Programming .NET Components, Second Edition, by Juval Löwy (O’Reilly & Associates, 2005) is an excellent deep dive on overall .NET programming, and many of the topics covered in that book are prerequisites for the more advanced code samples in this book.

Table of Contents

Figures xv

Foreword xxi

Preface xxiii

Acknowledgments xxxi

About the Author xxxiii

Chapter 1: Introduction to ClickOnce 1

What Is a Smart Client Application? 2

Why Choose Smart Clients? 6

Smart Client Deployment Challenges 7

Design Goals of ClickOnce 8

ClickOnce Features 9

Terminology 10

ClickOnce Deployment Modes 12

ClickOnce Deployment Architecture 14

ClickOnce Deployment Process Overview 16

First ClickOnce Deployment: ClickOnce Hello World 17

Software Requirements for ClickOnce 26

What to Deploy (and What Not to Deploy) with ClickOnce 28

ClickOnce Versus Other Deployment Technologies 30

Smart Client Architecture Overview 32

Where Are We? 34

Chapter 2: Initial Deployment with ClickOnce 37

Publishing an Application with Visual Studio 2005 38

ClickOnce Publishing Options 38

Visual Studio Publishing Step by Step 50

ClickOnce Application Initial Deployment Step by Step 64

Moving an Application to Production 76

Moving an Application into Production with Mage 77

Where Are We? 80

Chapter 3: Automatic Application Updates 83

Automatic Update Walkthrough 84

ClickOnce Update Options 91

Behind the Scenes on the Deployment Server 99

Behind the Scenes of an Update on the Client Machine 100

Removing or Restoring Applications on the Client 104

Restoring an Application Version from the Deployment Server 105

Republishing a Previous Version 105

Where Are We? 106

Chapter 4: On-Demand Updates 107

When Do On-Demand Updates Make Sense? 108

Introducing the ClickOnce API 109

Adding Synchronous On-Demand Updates 110

Performing Updates Asynchronously 114

Update Progress Notifications 122

Combining On-Demand Updates with Automatic Updates 123

Checking Detailed Update Information 125

Gathering Information about the Current Deployment 126

Where Are We? 128

Chapter 5: Application and Data File Management 131

Application Executable Deployment 132

Adding Application Files in Visual Studio 134

Configuring ClickOnce Application Files 135

Embedding Files in the Assembly 138

Localizing Your ClickOnce Deployment 141

Programmatic Download of Application Files 147

Deploying Extensible Plug-In Applications with ClickOnce 151

Managing Application Files with Mage 157

Managing Data Files Through Visual Studio 160

Dealing with Data Files on the Client 161

Data File Update Process 164

Deploying a Client Database with Your Application 167

Migrating SQL Compact Edition Database Files 168

Where Are We? 174

Chapter 6: ClickOnce Security 177

ClickOnce Security Overview 177

Internet Explorer Security Settings Affecting ClickOnce 188

Configuring ClickOnce Security Permissions 189

Understanding and Managing Publisher Certificates 197

Signing Application Updates 208

User Prompting 210

Trusted Applications’ User Security Policies 215

Trusted Publishers’ Permission Elevation 216

Adding Restricted Code Sections 219

Securing the Application Based on User Roles 221

Securing Access to ClickOnce Application Files on the Server 222

Where Are We? 223

Chapter 7: Prerequisite Deployment with the Bootstrapper 225

Bootstrapper Features 226

Bootstrapper and ClickOnce Sample Deployment 229

Adding Items to the Bootstrapper 234

Generating Bootstrapper Manifests 245

Where Are We? 248

Chapter 8: Advanced ClickOnce Topics 249

Using URL Query String Parameters 249

Executing Custom Install/Initialization Code 255

Debugging ClickOnce Applications 256

Deploying Unmanaged Applications with ClickOnce 261

Reg-Free COM 264

Deploying ClickOnce Applications with Firefox 266

Launching a ClickOnce Application Programmatically 267

Pushing ClickOnce Installations to the Client Machine 268

Web Server ClickOnce Configuration 272

MSBuild ClickOnce Publishing 273

Where Are We? 274

Appendix A: ClickOnce Deployment of WPF Applications 277

WPF Anatomy 101 278

ClickOnce Deployment of WPF Applications 280

Sample Web Browser Application Walkthrough 281

Where Are We? 284

Index 287

Preface

Deployment has been a thorn in most developers’ sides for a long time. Developing complex distributed applications is challenging enough just from a design and implementation perspective. Failing to plan for deployment or having the deployed environment change on you can kill an application quickly, no matter how well you plan for it. ClickOnce does not solve this problem, but it definitely takes a big step in the right direction for streamlining deployment of smart client applications.

I was first exposed to ClickOnce more than three years ago at an early adopter lab on the Microsoft campus in Redmond. At the time, I was just starting to get immersed in smart client technology and beginning to think about how to address all aspects of the application lifecycle as an architect. Having experienced a fair amount of deployment pain myself in the past, I instantly fell in love with ClickOnce as a technology. I quickly saw the potential for ClickOnce to be a key enabler for the broad adoption of smart client architectures because without a way to get those smart client applications in your users’ hands, you might as well not build them.

The most common question that I got as I was working on this book was, “How can you write a whole book on ClickOnce?” This usually came from someone who had seen demos of ClickOnce but had not yet tried to use it for something real. ClickOnce is incredibly powerful, yet it seems simple on the surface. It takes only five to ten minutes to run an end-to-end demo of what ClickOnce can do for you. When people have seen this kind of presentation of ClickOnce, they do not realize that ClickOnce addresses a lot more than a single common deployment scenario. However, whenever you try to provide flexibility and power, a fair amount of complexity also comes along with it.

I think the ClickOnce team did a really good job of making the simple, straightforward use of ClickOnce as easy as possible. If you are building a new smart client application from scratch with ClickOnce in mind, using ClickOnce to deploy it requires minimal effort for both your administrators and your users. However, real applications are rarely simple and straightforward (even though, because of poor architecture, the complexity is often unnecessary or disproportionate to what the applications are designed to do). ClickOnce has many variations and options that let you address a broad range of scenarios to deal with those complexities. And once you start getting into those capabilities, you dive into the deep end of the ClickOnce pool and really need to understand a lot more about what is going on under the covers; what the effects are of setting publishing, update, and security options different from the defaults; how your application is going to behave in the ClickOnce runtime environment; and so on.

Who Should Read This Book?

This book is written for those developers and architects who need to understand the full range of capabilities of ClickOnce so that they can make educated decisions early in the development lifecycle and put those decisions into practice when the product is getting close to complete. You will need this understanding to make sure you can get your smart client applications deployed through ClickOnce and to address the complexities of real-world applications in that environment. It is primarily written for intermediate to advanced developers or architects, but IT professionals who are responsible for deploying and maintaining ClickOnce applications can also get a lot out of most of the chapters as well.

This is not a book about programming, although there are aspects of ClickOnce covered in several of the chapters that require coding to use. ClickOnce is mainly driven through Visual Studio project configuration, tools, and processes, not through code. So a fair percentage of the book will describe these aspects, and only a small portion will discuss code directly.

There is a programmatic API that is discussed in several chapters, and there are other coding practices that are important from within your application that can affect the deployment and execution of a ClickOnce application. For the sections that cover coding, I expect that readers already know how to code .NET applications. I will point out appropriate references when necessary for complex topics, but to understand the code samples, you need to have some experience developing Windows Forms applications in .NET. 1

Conventions

Deploying ClickOnce applications is mostly about tools and less about code. However, there are a number of code samples in this book, and to help make things easier, I have adopted some common conventions.

First, any time I refer to classes, variables, namespaces, and other artifacts that manifest themselves in code, I will use a monospace font to make it clear if I am talking about an instance of the ApplicationDeployment class as opposed to talking about a coding construct in a conceptual way. Short code listings will be presented inline within the text using a monospaced font as well.

Longer listings will use a similar font, but will be broken out into labeled listings that can be referred to throughout the text (based on listing numbers). Within code listings, I will sometimes set in bold particularly relevant portions of the code, especially to highlight “evolving code.” I may remove details that are not relevant to a discussion, and if so will insert a comment that indicates that there are more details, identifiable by a comment with an ellipses (//...). What this means is that more code is needed to complete the example or that there exists more code generated by the designer, but you don’t need it to understand the concept. On occasion, I will add explanatory comments to code in order to show context.

System Requirements

This book was written using the released version of Visual Studio 2005 and the .NET Framework 2.0. ClickOnce capabilities are available in all versions of Visual Studio, including Visual C# 2005 Express and Visual Basic 2005 Express. You do not need Visual Studio to use ClickOnce because it is a core capability of the .NET Framework, but to use ClickOnce for any serious project, you will need Visual Studio to do the initial publishing. Throughout the book, I will refer to Visual Studio instead of Visual Studio 2005 for brevity, but you can always infer that I mean Visual Studio 2005 or one of the Express versions (even though they do not have “Studio” in their official names).

If you plan to run the samples available from the download site or the walkthroughs and code listings in this book, you will need a version of Visual Studio 2005, Visual C# 2005 Express, or Visual Basic 2005 Express installed on your machine. One of the samples uses a SQL Server 2005 Compact Edition database to provide sample data to the application, but it includes the libraries needed to run that. One sample uses the Northwind database to provide sample data. Because the particular functionality of the application is not important to the topic being covered (how to deploy and update these applications with ClickOnce), don’t get wrapped up in trying to get these samples running if you don’t already have the databases available; just create an empty Windows Forms application and use it.

Choice of Language

I chose to present the code samples in this book in C#. The downloadable code is available in both C# and Visual Basic. It is a fact of life that there will continue to be a mix of C# and Visual Basic available in articles, books, and code samples for a long time to come. Even though I prefer C# myself, that is just a preference, and I feel that Visual Basic is a solid choice for developers who have a strong background in earlier versions of Visual Basic.

I firmly believe that to be an effective .NET developer, you need to be able to read code from either language, even if you spend most of your time with one. If you are not already comfortable reading C# code, I encourage you to use this opportunity to get comfortable with reading C#. It will expand your horizons in terms of the amount of reference material that is available to you, it may help you in your job, and it will give you bragging rights over the many silly and close-minded C# developers who can’t or won’t read Visual Basic.

Chapter Overview

This book steps you progressively through all of the concepts you will need to master to use ClickOnce to deploy real-world smart client applications. It starts with the basics in the first chapter, giving you a high-level view of ClickOnce and the surrounding context of smart client applications. Then it steps through deploying and updating applications, with all the associated options. It then focuses on more of the infrastructure for ClickOnce deployment, including how to manage application files, security, prerequisites, and advanced capabilities. It ends with an appendix that tells you what is different with respect to Windows Presentation Foundation application deployment (not much).

Here is a quick breakdown of the contents of each chapter.

Chapter 1: Introduction to ClickOnce. This chapter sets the context for the rest of the book. It starts by describing what a smart client application is and what deployment challenges ClickOnce was designed to address. It describes the high-level features of ClickOnce, and then walks you through a sample deployment and update of a client application using ClickOnce. This chapter wraps up describing the system requirements for ClickOnce, how it relates to other deployment technologies, when to use it and when not to, and a quick discussion of smart client architecture.

Chapter 2: Initial Deployment with ClickOnce. This chapter covers the process of publishing an initial version of an application and deploying it to clients. It discusses all of the publishing options that you have available for getting your applications placed on the deployment server and what that process involves using Visual Studio. It describes what happens when the user deploys the application to the client machine using ClickOnce from an end user’s perspective, and what is going on under the covers. It finishes by describing the process of manually publishing your application using the SDK Mage tools for an environment where Visual Studio cannot access the production servers.

Chapter 3: Automatic Application Updates. This chapter covers the capabilities of ClickOnce for automatically deploying application updates to users. The publishing for updates is discussed briefly because it is effectively the same as for initial deployment. Then the deployment process is detailed, showing what the experience is for users and what the options are. The chapter describes all of the options you have for configuring when and how updates occur. It discusses what happens behind the scenes on the deployment server as well as on the client machine when an update is detected and deployed. It also covers how to manage rolling back an update either from the client or the server side.

Chapter 4: On-Demand Updates. This chapter builds on Chapter 3, showing how to use the programmatic API for ClickOnce to trigger updates from your application code. It discusses performing synchronous and asynchronous updates, detecting updates, and pulling them down when desired using the API. It covers several strategies for doing the updates asynchronously to avoid blocking the client application. It also describes other functionality exposed through the API, including the ability to check detailed update information and find out about the version of the application that is currently deployed on the client machine.

Chapter 5: Application and Data File Management. This chapter discusses in detail managing the files that your application is composed of. It describes how ClickOnce treats those files, how to select and control what files get deployed with your application, and where they will end up on the client machine. It discusses download groups, which provide a way to download portions of your application files on demand. It discusses managing application data files, and how those files are migrated by ClickOnce when an application update occurs. It covers using plug-in DLLs in a ClickOnce application to enhance your application’s functionality with individual optional modules. The chapter closes by covering how to manage the application files that get published using the SDK Mage tools.

Chapter 6: ClickOnce Security. This chapter discusses the security features and protections of ClickOnce in detail. It covers the deployment time and runtime protections for the client machine, and discusses the tamper protections for the application files both on the server and client sides. The chapter describes how to configure and control what permissions the application requires, and how those permissions are evaluated and granted on the client machine. It discusses how user prompting can be used for permission elevation, and how to use the Trusted Publisher mechanism to automatically elevate permissions based on an administrator’s predeployed publisher certificate. It covers managing the ClickOnce manifest digital signature with publisher certificates. Finally, the chapter covers how to protect sections of your application from malicious code and includes a quick introduction to using role-based security in .NET to restrict permissions in the client application based on user roles.

Chapter 7: Prerequisite Deployment with the Bootstrapper. This chapter covers how to get things preinstalled on the client machine that cannot be deployed through ClickOnce. It discusses the Bootstrapper’s features for wrapping multiple installer packages and running them through a single launch experience on the client machine. It describes creating and configuring Bootstrapper manifest files, and what the runtime experience is when deploying prerequisites. The chapter steps through several scenarios of types of files you might want to deploy with the Bootstrapper.

Chapter 8: Advanced ClickOnce Topics. This chapter covers a variety of additional questions that often come up for ClickOnce applications to address specialized scenarios. The chapter discusses using command line parameters, debugging ClickOnce applications, deploying non-.NET applications with ClickOnce, working with the Firefox Web browser, and deploying COM components with your application, to name a few.

Appendix A: ClickOnce Deployment of WPF Applications. The appendix covers the differences in using ClickOnce with Windows Presentation Foundation (WPF) applications. For the most part ClickOnce works the same with WPF, but there are some subtle differences. The appendix covers the Web Browser Application model, what you need to do differently when creating and publishing the project, and how the application deploys and runs on the client machine.

Book’s Web Site and Sample Download Code

The Web site for this book is at www.softinsight.com/clickoncebook. All of the sample code in this book is available for download on that site. Links are available on the site to other ClickOnce-related resources, including the author’s blog (www.softinsight.com/bnoyes/).

Note:

1. Windows Forms 2.0 Programming by Chris Sells and Michael Weinhardt (Addison-Wesley, 2006) is the best overall reference and tutorial for learning all aspects of Windows Forms programming. My other book in this series, Data Binding with Windows Forms 2.0 (Addison-Wesley, 2006), will give you a deep dive on how to present data in your applications. Programming .NET Components, Second Edition, by Juval Löwy (O’Reilly & Associates, 2005) is an excellent deep dive on overall .NET programming, and many of the topics covered in that book are prerequisites for the more advanced code samples in this book.

Customer Reviews

Most Helpful Customer Reviews

See All Customer Reviews