Read Microsoft Visual C# 2005 Express Edition: Build a Program Now! Online
Authors: Patrice Pelland
Tags: #General, #Computers, #C♯ (Computer program language), #Programming Languages, #C#, #Microsoft .NET Framework, #Computer Books: Languages, #Computer Graphics, #Application software, #C# (Computer program language), #Programming, #Microsoft Visual C# .NET, #Microsoft Visual C♯ .NET, #Electronic books, #Game Programming & Design, #Computing: Professional & Programming, #C (Computer program language), #Computers - Languages, #Programming Languages - C#, #Programming & scripting languages: general
■ Displays weather data for the current day, as well as a three-day forecast.
■ Includes an Options dialog box with many more controls and settings.
■ Uses a ZIP Code Web service, which allows a user to select from a list of ZIP codes.
■ Uses a State/Provinces Web service, which allows a user to search for a ZIP code by city.
■ Allows users to select temperature unit, Celcius or Fahrenheit.
■ Uses a Timer control to automatically refresh the weather data at regular intervals (e.g., every 10 minutes). The user can change this interval.
Now it’s time to learn how to distribute Weather Tracker or another application.
Chapter 9: Build Your Own Weather Tracker Application Now!
203
CSX_Chapter 9.indd 203
CSX_Chapter 9.indd 203
10/24/05 6:59:41 PM
10/24/05 6:59:41 PM
And Now, Just ClickOnce!
A new technology for deployment called ClickOnce is now available with .NET Framework 2.0. It’s a fantastic feature that let’s you customize how your tool gets onto other people’s machines. It’s very easy—almost as easy as deploying Web applications, which often only entails copying files onto a server. ClickOnce allows you, the developer, to distribute your application via a robust and reliable mechanism. You can deploy on Web servers, file servers, or onto a CD/DVD. You can add the .NET Framework to your distribution package along with SQL Server if your application needs it. ClickOnce handles rollback and uninstall well, and it’s a charm to push new updates. In your case, you’ll deploy to a CD/DVD.
TO PACKAGE AND PUBLISH YOUR APPLICATION
To ensure that all of the *.gif files representing the weather icons are included with the installation, 1 make sure the Build Action properties is set to
Content
for all of the *.gif images in the Solution Explorer. (This process was described earlier in the chapter.)
2 Rebuild the application completely by clicking
Rebuild Solution
on the Build menu.
Figure 9-13
In the Solution Explorer, right-click the
Weather Tracker
project and select
Properties
to open the 3
Publish tab in the Project Designer
Project Designer.
4 Click the
Publish
tab. You should see a screen that looks like the one shown in Figure 9-13.
Click the
Application Files
button to see the list of files that will 5 be included in the installation. All of the *.gif files should be listed. Click
OK
. You now want to select the prerequisites for your application. When
the installer runs on the user’s machine, it will check for the presence of these items. If they are not present, the installer will by default download them from Microsoft.com or another source that you have
configured.
204
Microsoft Visual C# 2005 Express Edition: Build a Program Now!
CSX_Chapter 9.indd 204
CSX_Chapter 9.indd 204
10/24/05 6:59:42 PM
10/24/05 6:59:42 PM
Click the
Prerequisites
button. In the Prerequisites dialog box, 6 select the
.NET Framework 2.0
and
Windows Installer 3.1
check boxes. Make sure the
Download Prerequisites From The
Component Vendor’s Web Site
option is selected. Click
OK
. 7 Click the
Publish Wizard
button.
The first page of the wizard appears, as shown in Figure 9-14, asking
you to specify a location to publish the application.
Click the
Browse
button. In the Open Web Site dialog box, select 8
File System
on the left, and then select a location on your computer where you want to publish your application. I suggest you create a new folder named
Weather Tracker
. You can use the Create New
Folder icon in the upper left to create a new folder. When finished, click the
Open
button and then click
Next
.
On the next page, select how the user will install the application. It 9 could be a Web site, a UNC share on a network, or a CD or DVD.
Select the
From A CD-ROM Or DVD-ROM
choice and click
Next
.
Figure 9-14
Publishing Wizard’s first page
10 The next page asks whether you want your application to look for updates every time it starts. Because you are deploying on a CD or DVD, you won’t have your application check for updates.
Select the default
The Application Will Not Check For Updates
choice and click
Next
to continue.
During the installation, if you get
an error message that the applica-
11 Click
Finish
to publish your application.
tion validation did not succeed
or another error message, try
re-publishing your application
After a few moments, setup files will be created at the folder location you selected earlier. To test the instal
and testing again.
lation, double-click the Setup.exe file. During the installation, a shortcut will be added to the Programs menu. To uninstall the application, use Add Or Remove Programs in the Control Panel.
Once the installation works as expected, you can deploy your application by simply burning the installation
Every time you publish your appli-
files onto a CD or DVD.
cation, the publish version number
(not the application version num-
ber) will be incremented—that
ClickOnce has more features, but this short demonstration can get you started creating
is, it will become version 1.0.0.0,
1.0.0.1, and so on.
your own installations.
Chapter 9: Build Your Own Weather Tracker Application Now!
205
CSX_Chapter 9.indd 205
CSX_Chapter 9.indd 205
10/24/05 6:59:43 PM
10/24/05 6:59:43 PM
In Summary...
Congratulations on getting this far! I hope you’ve learned a lot and had some fun developing applications using Visual C# 2005 Express Edition. If you like what you’ve learned (and I certainly hope so), then your education is just beginning. There’s so much more to see and try. This book provided a small sample of the types of applications you can create. My advice to you is to continue thinking of fun projects you can create! You’ll be surprised at how much you can accomplish. In my opinion, developing an application is one the greatest feelings of accomplishment. People are proud of their applications and you will be, too!
If you happen to create an application that’s useful to you, chances are that it could be useful for others as well. In the end, you might be helping people by providing them with the fruits of your labor. You can also join development projects for fun and help others in the process while learning a great deal. Visit GotDotNet Workspaces
(http://www.gotdotnet.com/
workspaces/)
for a sample of cool project examples.
In September 2005, I started writing a column on MSDN that will be devoted to programming for fun. The column is called Coding4Fun and can be found at
http://msdn.micro-
soft.com/coding4fun/
. Part of this column on MSDN pertains to improving the Weather Tracker application you created here, so be sure to look for this feature. You can also visit my blog at
http://blogs.msdn.com/ppelland/
. I haven’t updated my blog for a while because I’ve been busy writing this book as well as helping to ship Visual Studio 2005, but rest assured that in the near future, I will have some updates (I normally blog at least 4-5 times a week). You can use my site as another location to keep informed about cool stuff in the Express products line.
Until then, happy developing!
206
Microsoft Visual C# 2005 Express Edition: Build a Program Now!
CSX_Chapter 9.indd 206
CSX_Chapter 9.indd 206
10/24/05 6:59:44 PM
10/24/05 6:59:44 PM
GlossarY
databinding
An easy and transparent way to read/write
A
a link between a control on a Windows Form and a data
source from your application
argument
A variable that is passed to a subprogram
debugger
A computer program used to find the defects in
B
another program
black box testing
Functional testing of a computer pro
DLL (Dynamic Link Library)
A binary application library gram to see that it performs correctly
file format in Microsoft Windows
breakpoint
A pause or stopping place in a program, intenE
tionally inserted to help with debugging
encapsulation
Hides private methods of a class or object;
C
ensures that an object cannot be changed
class
The basic building block of OO programming; it
event
A software message that indicates something has
defines the fields, properties, methods, and events of an
happened in the program
object
execution engine
Development tool for executing pro
compiler
A computer program that translates the instrucgrams tions written in one computer language into output in
another computer language; compilers translate source code
F
into some type of machine language that can be executed
FCL (Framework Class Libraries)
A set of pre-written code
by a computer
for common programming tasks
console application
An application that is run from a comH
mand prompt with no Windows or Web interface
hyperlink
A reference in a hypertext document to another
context-sensitive menu
A menu that provides different
document or location
choices to the user depending on when it is accessed
I
controls
Components of a Graphical User Interface, such as
text boxes or buttons
icon
A small image or picture used to represent a program,
file, or other object
D
IDE (Integrated Development Environment)
Computer
data member
Data encapsulated within a class or object
software tools that help developers write computer pro
database
A collection of data that is stored in files using a grams
systematic structure
207
Z01622299.indd 207
Z01622299.indd 207
10/24/05 6:25:07 PM
10/24/05 6:25:07 PM
inherit
Objects are created that are specialized types of
splash screen
An image that appears on the screen while
existing objects and can share and extend their behavior
a program is loading; it provides information to the user
without having to re-implement it
about the loading process and disappears once the program