Watch our 3-minute video to find out how you can learn Silverlight with a live instructor.
Additional Resources

Team Development Using Silverlight

In this lesson of the Silverlight tutorial, you will learn...
  1. About source control / version control
  2. About the source control products offered by Microsoft
  3. To manage source code by using Visual SourceSafe

This lesson will discuss source control options in a Microsoft development environment.

Source Control Overview

Developing an application is a huge task and normally involves multiple developers and designers. The multiple developers and designers that are involved will, undoubtedly, need to work on the same files that other developers and designers are working on or have worked on. Over the life of a development project, this scenario presents a concurrency issue.

A concurrency issue occurs whenever a shared resource may be modified by multiple users when the modifications made conflict with each other. The classic example of a concurrency conflict scenario occurs in a database environment where a single row of data may be modified by multiple users. For example, if a user begins updating the address of a customer and, while the modification is being made, another user modifies and updates the same customer address, should the modification made by the first user overwrite the modification made by the second user? In a scenario such as this, custom code is almost always required to resolve the conflict.

The same scenario comes into play when multiple developers and designers are working concurrently on the same application files. For example, if one developer modifies the code in a class file and a second developer also modifies the same code in the same class file, should the modification made by the second developers simply overwrite the modification made by the first developer? Should both modifications be logged in a modification history log? Should an attempt be made to merge the modifications made by both developers?

The common solution to resolving conflicts somewhat in the application development environment is to incorporate another piece of software that manages updates to source code for application components. This type of software is called source code control software or, just simply, source control. Source control software may also be referred to as version control software.

Microsoft Source Control Products

Source control software functions by converting source code files into text and then, upon each source code file being updated, logging an updated version of the file in a data repository. In order for source control software to track changes correctly, source code files must be able to be converted to text. Almost all source code files created using current Microsoft development technologies (the .NET Framework, SQL Server 2005, etc) can easily be converted to text and incorporated into a source control application.

There are several source control applications available on the market. Microsoft offers two source control applications: Visual SourceSafe and Team Foundation Server.

Visual SourceSafe

Visual SourceSafe (VSS) has been around for many years and is capable of managing source code for most Microsoft development products. VSS is currently in version 2005. VSS is designed for small teams and is even handy for single developers. Visual SourceSafe maintains each version of a source code file in a data repository and allows a developer to temporarily, or even permanently, rollback to an earlier version. For instance, it is not uncommon when modifying code that is functioning correctly, that modifications made to the code may cause it to stop functioning. In such a scenario, a developer can revert the source code file to an earlier version that was functioning correctly.

VSS was not significantly upgraded by Microsoft over the years and, as a result, lacks many of the more advanced features offered by competing products. Due to this, VSS is commonly the target of criticism by development teams. However, VSS is an affordable source control solution that is well suited to small teams and projects. VSS 2005 has been upgraded to include functionality for supporting XML file types and for upgrading to TFS. (see footnote)

Team Foundation Server

In an effort to meet developer needs and requests and offer a leading product in the source control market, Microsoft released Team Foundation Server (TFS). TFS is an enterprise-level source control product that fully manages application source control and the application development cycle. The TFS source control explorer is shown in the following figure.

TFS offers leading source control functionality as well as:

  • Issue tracking and management: issues include bugs found in an application, errors received, suggestions made by users, etc. Each issue can be tracked in the data repository and assigned to a developer for resolution. Each issue is referred to as a "work item". The following figure shows the TFS Work Items manager.
  • Application build control: multiple versions of an application can be scheduled for automatic build and deployed to differing target locations. For example, a development version of an application may be built overnight and deployed to a test environment while the test version may be built and deployed to a training environment in the same night.
  • Support for distributed development teams: It is a challenge to get a VSS data repository to be accessible over the Web due to performance issues. However, TFS is streamlined and optimized for distributed and remote access so that development teams can be easily comprised of members across the globe while all have access to the central TFS data repository.
  • Integration with management tools: Project managers can track all facets of application development by incorporating Microsoft Project into TFS. Furthermore, TFS integrates with Microsoft SharePoint Server and provides real-time status reports by using a SharePoint portal.
  • Integration with SQL Server 2005: TFS stores data related to a development project in SQL Server 2005 whereas VSS stores data in a proprietary data repository. Hence, performance is greatly increased in TFS and the product and data repository are even extensible.
  • Integration with Visual Studio 2008 Team System: When TFS is installed, a Team Explorer is available in Visual Studio that allows a developer to view and manage all aspects of all projects that the developer is involved in.
  • Granular security and permissions: TFS provides the ability to manage users, roles, and permissions at a very granular level.

More in-depth coverage of Team Foundation Server is beyond the scope of this course. (see footnote)

Configuring Visual Studio 2008 For Source Control

When Visual SourceSafe is started for the first time, a new data repository must be created by using the Add SourceSafe Database Wizard. If VSS does not detect an existing data repository, you will automatically be prompted with the wizard. The wizard is fairly straightforward with the following exceptions:

  • Team Version Control Model: This determines how source code files are managed by VSS. The Control Model page in the wizard is shown below.
    • Lock-Modify-Unlock Model: If you select the Lock-Modify-Unlock model, it is analogous to pessimistic database locking; there is a much smaller possibility of a modification conflict between development team members but, at the same time, the file will be locked while any other developer is making a modification to a file so that only one development team member at a time may modify a file.
    • Copy-Modify-Merge Model: If you select the Copy-Modify-Merge model, it is analogous to optimistic database locking; there is a greater possibility of a modification conflict between development team members but, at the same time, the file will be accessible to multiple developers simultaneously.

All Silverlight source code files are compatible with existing source control products. Silverlight projects can be added to Visual SourceSafe either directly through the VSS interface or through Visual Studio. Managing a Silverlight project through Visual Studio is typically easier and more intuitive for developers.

Once Visual SourceSafe is installed, projects can be managed by using Visual Studio either from the File menu or from the Solution Explorer. The figure below shows the File menu options.

Furthermore, when a new project is created in Visual Studio 2008, it can automatically be added to source control by selecting the Add to Source Control checkbox as shown in the following figure.

When a project is added to source control, the Visual SourceSafe login dialog is presented as shown below.

When a file needs to be modified, right-click the file in the Solution Explorer and select Check Out for Edit. The Check Out for Edit dialog allows you to enter comments to document why the file is being checked out.

When a modification is complete, a file can be checked back into source control as shown below.

Configuring Expression Blend For Source Control

The latest version of Expression Blend (2.5) does not offer integration with a source control provide although it is planned for a future release. However, as stated above, all Silverlight project files can be incorporated into source control and Visual Studio 2008 provides extensive source control integration support. Hence, until Expression Blend offers source control integration, simply use Visual Studio 2008 or the source control software interface to manage Silverlight application files.

Lab: Integrate Source Control

In this lab, you will integrate Visual SourceSafe with a Silverlight project and track modifications.

Exercise: Create a User Data Store and Validate User Credentials

Duration: 20 to 30 minutes.

In this exercise, you will create a new Silverlight project and manage it with Visual SourceSafe.

  1. Start or open Visual Studio 2008.
  2. Create a new Silverlight project and select the Add to Source Control option.
  3. When prompted with the Log On To Visual SourceSafe Database dialog, provide your credentials and select OK.
  4. When prompted with the Add to SourceSafe dialog, create a new project under the SourceSafe root to store the new project. Click OK and select Yes when prompted to create the new project.
  5. Right-click Page.xaml in the Solution Explorer and select Check Out for Edit.
  6. When prompted with the Check Out for Edit dialog, enter something like "Editing in Expression Blend." as the comment and select Check Out.
  7. Right-click Page.xaml in the Solution Explorer and select Open in Expression Blend.
  8. In Blend, resize the canvas to a smaller size, approximately 150 X 150.
  9. Drag an ellipse to the canvas and size it to approximately 134 X 134.
  10. Set the ellipse StrokeThickness to 20.
  11. Set the ellipse Stroke brush to a gradient.
  12. Select the dark side gradient marker and set its alpha value to 0.
  13. Select the light side gradient marker and set it to a bright color.
  14. In the Objects and Timeline pane, select the add icon to create a new storyboard. Name the storyboard "sbSpin".
  15. In the timeline tracker, add a marker at 2 seconds. Spin the ellipse twice.
  16. Click the timeline play button to preview the animation.
  17. Click the red circle at the top of the design window to turn off storyboard recording.
  18. Select the sbSpin storyboard and set the RepeatBehavior to "Forever".
  19. Save all changes and close Expression Blend.
  20. In Visual Studio 2008, right-click the Page.xaml file in the Solution Explorer and select Check In.
  21. When prompted with the Check In dialog, enter something like "Created animated spinner." as the comment and click Check In.
  22. Press F5 to test the application.
  23. The animation does not start due to an oversight (intentional for the purpose of the lab:)) to call the Begin() method on the storyboard.
  24. Right-click the Page.xaml file in the Solution Explorer and select Check Out for Edit.
  25. When prompted with the Check Out for Edit dialog, enter "Starting animation." for the comment and click Check Out.
  26. Double-click the Page.xaml code behind file in the Solution Explorer to open it.
  27. In the Page_Loaded method, add a call to sbSpin.Begin();.
  28. Save all changes.
  29. Right-click the Page.xaml file in the Solution Explorer and select Check In.
  30. Enter "Added call to sbSpin.Begin()." in the comment and click Check In.
  31. Press F5 to test the application.
  32. Right-click the Page.xaml file in the Solution Explorer and select Check Out for Edit. Enter "Changing color." in the comment and click Check Out.
  33. Right-click the Page.xaml file in the Solution Explorer and select Open in Expression Blend.
  34. In Blend, modify the ellipse Stroke brush by setting it to a different color.
  35. Save changes and close Blend.
  36. Right-click the Page.xaml file in the Solution Explorer and select Check In. Enter "Changed color." as the comment and select Check In.
  37. Press F5 to test the application.
  38. Right-click the Page.xaml file in the Solution Explorer and select View History. When prompted with the View History dialog, select OK.
  39. Three items should be displayed. Select the second item and click Pin. Click Close.
  40. Press F5 to test the application.
  41. Right-click the Page.xaml file in the Solution Explorer and select View History. When prompted with the View History dialog, select OK.
  42. Click Unpin and click Close.
  43. Press F5 to test the application.

Team Development Using Silverlight Conclusion

In this lesson of the Silverlight tutorial, you

  • Reviewed source control basics
  • Managed multiple versions of a XAML file by using Visual SourceSafe

Footnotes

  1. For more information about Visual SourceSafe 2005, visit the Visual SourceSafe Home page located at http://msdn2.microsoft.com/en-us/vstudio/aa718670.aspx.

  2. For more information about Team Foundation Server, visit the Team Foundation Server Team Center located at http://msdn2.microsoft.com/en-us/teamsystem/aa718934.aspx.

To continue to learn Silverlight go to the top of this page and click on the next lesson in this Silverlight Tutorial's Table of Contents.
Last updated on 2009-05-11

Use of http://www.learn-silverlight-tutorial.com (Website) implies agreement to the following:

Copyright Information

All pages and graphics on Website are the property of Webucator, Inc. unless otherwise specified.

None of the content on Website may be redistributed or reproduced in any way, shape, or form without written permission from Webucator, Inc.

No Printing or saving of pages or content on Website

This content may not be printed or saved. It is for online use only.


Linking to Website

You may link to any of the pages on Website; however, you may not include the content in a frame or iframe without written permission from Webucator, Inc.


Warranties

Website is provided without warranty of any kind. There are no guarantees that use of the site will not be subject to interruptions. All direct or indirect risk related to use of the site is borne entirely by the user. All code and explanations provided on this site are provided without warranties to correctness, performance, fitness, merchantability, and/or any other warranty (whether expressed or implied).


For individual private use only

You agree not to use this online manual to deliver or receive training. If you are delivering or attending a class that is making use of this online manual, you are in violation of our terms of service. Please report any abuse to courseware@webucator.com. If you would like to deliver or receive training using this manual, please fill out the form at http://www.webucator.com/Contact.cfm