VisualStudioMagazine.com

Silverlight Futures With HTML5 promising native support for video and animation, what can developers expect from Silverlight in the months ahead?

PLUS Programming with Silverlight, Windows Phone 7 and the Multi-Touch Thumb Improving ASP.NET Security with Visual Studio 2010 Code Analysis VSToolbox: Leading Data Tools Reviewed DECEMBER 2010 Volume 20, No. 12 Volume ...

...... Using Quince™, you and your team can collaborate on the user interface using wireframes, designs and examples.

...... Then use NetAdvantage® UI controls, like the map control used here, to bring the application to life quickly & easily.

Untitled-7 2 11/10/10 10:59 AM ...... From start to finish, Infragistics gives you the tools to create impressive user experiences that'll make end users happy!

...

SEE HOW WE USE THE TOOLS TO CREATE THIS KILLER APP AT INFRAGISTICS.COM/IMPRESS

Infragistics Sales 800 231 8588 • Infragistics Europe Sales +44 (0) 800 298 9055 • Infragistics India +91 80 4151 8042 • @infragistics

Untitled-7 3 11/10/10 10:59 AM Your best source for software development tools! ®

LEADTOOLS Document STOP OVERBUYING SOFTWARE TODAY! VMware vSphere Imaging v17.0: Eliminate Wasteful Software Essentials Kit Bundle vSphere Essentials provides an all-in-one by LEAD Technologies License Spend: LEADTOOLS Document Imaging has every solution for small offices to virtualize three component you need to develop powerful • Control your software physical servers for consolidating and image-enabled business applications including licensing costs managing applications to reduce hardware specialized bi-tonal image display and and operating costs with a low up-front • Stop paying for licenses investment. vSphere Essentials includes: processing, document clean up, annotation, you’re not using high-speed scanning, advanced compression • VMware ESXi and VMware ESX (CCITT G3/G4, JBIG2, MRC, ABC) and more. • Reduce your license spend (deployment-time choice) by $300+ per desktop user • VMware vStorage VMFS • Multi-threaded OCR/ICR/OMR/ for 3 hosts MICR/Barcodes (1D/2D) • Four-way virtual SMP Paradise # • Forms recognition/processing FREE 30-DAY • VMware vCenter Server Agent V55 85101C02 Paradise # • PDF and PDF/A PROOF OF CONCEPT • VMware vStorage /VCB L05 03301A01 • Win32/x64 binaries for /C++, .NET, $446.99 $ 99 Silverlight, WPF, WCF, & WF Learn more: • VMware vCenter Update Manager 2,007. programmers.com/LEAD programmers.com/eliminate-wasteful-license-spend • VMware vCenter Server for Essentials programmers.com/vSphere “Pragma SSH for Windows” InstallShield Professional for Best SSH/SFTP/SCP Servers Windows 2011 BUILD ON NEW and Clients for Windows by Flexera Software RELEASE! VMWARE ESXi by Pragma Systems ’s Installation Solution of AND VSPHERE Choice for Visual Studio 2010 applications. Get all in one easy to use high performance for Centralized Management, package. FIPS Certified and Certified for Windows. If your software targets Windows®, InstallShield® is your solution. It makes it easy to author Continuous Application • Certified for Windows Server 2008R2 high-quality reliable (MSI) Availability, and Maximum • Compatible with and InstallScript installations and App-V™ virtual Operational Efficiency in Your Certified • High-performance servers with Upg from any for Windows packages for Windows platforms, including Virtualized Datacenter. centralized management Windows 7. InstallShield, the industry standard Active IS Pro + 7/2008R2 Programmer’s Paradise invites you to take advantage • Active Directory & GSSAPI authentication for MSI installations, also supports the latest IS Pro Silver Mtn of this webinar series sponsored by our TechXtend • Supports over 1000 sessions Microsoft technologies including Visual Studio Paradise # solutions division. Paradise # • Hyper-V and PowerShell support 2010, .NET Framework 4.0, IIS7.0, SQL Server I21H02401B01 P35 04201A01 • Runs in Windows 2008R2/2008/2003/ 2008 SP1, and Windows Server 2008 R2 and $ 99 FREE VIRTUALIZATION WEBINAR SERIES: 7/Vista/XP/2000 Windows Installer 5, keeping your customers 1,384. $ 99 REGISTER TODAY! TechXtend.com/Webinars 550. programmers.com/pragma happy and your support costs down. programmers.com/flexera ActiveReports 6 TX Text Control 15.1 by GrapeCity Professional 2010 Word Processing Components New Service The de facto standard reporting tool for by Microsoft TX Text Control is royalty-free, Pack! robust and powerful word processing Microsoft Visual Studio.NET Microsoft Visual Studio 2010 Professional with MSDN Essentials Subscription is an integrated software in reusable component form. • Fast and Flexible reporting engine environment that simplifies creating, debugging • .NET WinForms control for VB.NET and C# • Flexible event-driven API to completely and deploying applications. Unleash your creativity • ActiveX for VB6, Delphi, VBScript/HTML, ASP control the rendering of reports and bring your vision to life with powerful design • Wide range of Export and Preview formats surfaces and innovative collaboration methods for • File formats DOCX, DOC, RTF, HTML, XML, TXT NEW including Windows Forms Viewer, Web developers and designers. Work within a personal- • PDF and PDF/A export, PDF text import Professional Edition VERSION Viewer, Adobe Flash and PDF ized environment, targeting a growing number of • Tables, headers & footers, text frames, Paradise # 6! with MSDN • XCopy deployment platforms, including Microsoft SharePoint and cloud bullets, structured numbered lists, multiple T79 02101A02 Paradise # Professional Ed. applications and accelerate the coding process by undo/redo, sections, merge fields, columns $ 99 • Royalty-Free Licensing for Web and using your existing skills. Integrated support for M47 40201A02 1,220. Paradise # Windows applications • Ready-to-use toolbars and dialog boxes D03 04301A01 Test-First Development and new debugging tools $ 99 let you find and fix bugs quickly and easily to 1,060. Download a demo today. $ 99 1,310. programmers.com/grapecity ensure high quality solutions. programmers.com/microsoft programmers.com/theimagingsource FREE WEBINAR SERIES: MAXIMIZING DATA QUALITY FOR VALUE AND ROI NEW! Intel® Data is a company’s greatest asset. Enterprises that can harness the power of their data will be strategically posi- Parallel Studio 2011 tioned for the next business evolution. But too often businesses get bogged down in defining a Data Management NEW by Intel RELEASE! process, awaiting some “magic bullet”, while the scope of their task grows larger and their data quality erodes. A comprehensive, all-in-one toolkit Regardless of how your eventual data management solution is implemented, there are processes that need to for Microsoft Visual Studio® C/C++ occur now to facilitate that process. In this new series, with a mixture of slides, demonstrations and Q&A sessions, developers, Intel® Parallel Studio we will discuss how to use your existing Data Modeling assets to build the foundations of strong data quality. 2011 simplifies the analysis, REGISTER TODAY! programmers.com/CA compiling, debugging, error-checking, and tuning of your serial and threaded apps. ® CA ERwin Data Modeler r7.3 – Product Plus 1 Year Enterprise Maintenance With Intel Parallel Studio, get Single User DVD CA ERwin Data Modeler is a data modeling solution that enables you to create and maintain everything you need to optimize Paradise # databases, data warehouses and enterprise data resource models. These models help you legacy serial code, exploit multicore, I23 63101E03 visualize data structures so that you can effectively organize, manage and moderate data Paradise # and scale for manycore. complexities, database technologies and the deployment environment. P26 04201E01 $753.99 $ 99 programmers.com/ca 3,931. programmers.com/intel 866-719-1528 programmersparadise.com Prices subject to change. Not responsible for typographical errors.

Untitled-9 1 11/2/10 11:42 AM { FRAMEWORKS }

16

Michael Desmond, Editor in Chief, Visual Studio Magazine Looking Forward If there’s one constant in the world of Visual Studio development, it’s change. Look no further than this month’s cover feature by VSM Executive Editor Kathleen Richards, which covers the evolving strategic direction of Silverlight in a post- HTML4 world (“Silverlight Futures,” p. 16). Silverlight, of course, has always been about what’s next. From its early run as a media playback vehicle to the rapid-fi re releases that advanced it into a capable target for cross-platform business application development, Silverlight has never stood still. Now it seems the December 2010 // Volume 20 // No. 12 emergence of HTML5 as a media-savvy target for cross-platform Web development has prompted Silverlight to go on the move once again. FEATURES Microsoft isn’t shy about changing up products and technologies in mid-fl ight. 16 Silverlight Futures Just look at the development of With HTML5 promising native support for video and animation, what can developers expect from Silverlight in the months to come? SharePoint over the years, or the BY KATHLEEN RICHARDS cart-before-horse evolution of Silverlight versus Windows Presentation Foundation— or even the changing relationship 28 Silverlight, Windows Phone 7 and the Multi-Touch Thumb BY CHARLES PETZOLD between and C#. In the case of Silverlight, Microsoft has presumably spent millions of dollars building and 34 Improving ASP.NET Security with Visual Studio 2010 Code Analysis promoting a platform for cross-platform BY SACHA FAUST development and delivery of .NET code. Where does that strategy go now, and DEPARTMENTS what becomes of developers’ investments 6 Letters to the Editor in the technology? Those are important questions, but I’d 8 DevDisasters The .NET Whistleblower be shocked if dev shops fi nd their BY MARK BOWYTZ (THEDAILYWTF.COM) investments in Silverlight wasted. Silverlight remains a technology of 10 DevInsight VSTOOLBOX, VSINSIDER strategic importance to Microsoft. It’s the VSToolbox: Designing Databases with ERwin Data Modeler 7.3 PAGE 10 engine for Windows Phone 7 development VSToolbox: Manage Database Design PAGE 12 and will continue to serve the spectrum of VSInsider: The HTML5 Factor PAGE 13 Windows platforms, as well as the Mac OS. What’s your take on Microsoft’s handling COLUMNS of Silverlight and the decision to aggressively support HTML5 in 9? E-mail 3 Frameworks BY MICHAEL DESMOND me at [email protected]. VSM 40 Redmond Review BY ANDREW BRUST

VisualStudioMagazine.com · December 2010 · VISUAL STUDIO MAGAZINE 3 Online Contents

Get the complete picture —the latest dev news, analysis and REDDEVNEWS.COM ADTMAG.COM

how-to content—at RDN Express: Microsoft Under Fire Apache, Oracle Battle over Future of Java VisualStudioMagazine.com BY KATHLEEN RICHARDS BY JOHN K. WATERS Kathleen Richards surveys Web The Apache Software Foundation said it will and our partner sites in development experts and stake holders in quit the Java Community Process if Oracle the Redmond order to fi nd out just how viable HTML5 doesn’t lift the usage restrictions that it has will be to dev shops that today are using imposed on Java and truly support the open Developer Network. Flash, Silverlight and other rich Internet source status of the technology. application platforms. ADTmag.com/Waters1210A EASY FINDIT RedDevNews.com/Richards1210A What we once called FindIT codes are now easy App Creators Talk App Engine URLs. You’ll see these embedded Redmond Diary: Microsoft VertiPaq BY JOHN K. WATERS throughout Visual Studio Magazine so you can BY ANDREW BRUST Google App Engine is a suite of tools and access any additional information quickly. The Microsoft VertiPaq columnar, in-memory services for building and scaling Web Simply type in VisualStudioMagazine.com/ business intelligence (IMBI) engine won’t apps on the company’s infrastructure. followed by the FindIT code into your URL be limited to personal and departmental BI Applications developed using the App address field. (Note that all URLs do not have any spaces, and they are not case-sensitive.) solutions that live in Excel and SharePoint— Engine Software Development Kit can be it’ll be available for enterprise BI uploaded and hosted by Google, and those implementations, too. The next version of apps can then utilize Google’s bandwidth SQL Server will also enable the creation of and computing power. columnar indexes over relational databases. ADTmag.com/Waters1210B RedDevNews.com/Brust1210 Survey: Companies Struggle with Agile VISUALSTUDIOMAGAZINE.COM Microsoft PDC Focuses on Windows Management Tool Selection Phone, , Cloud BY DAVID RAMEL 5 Traps to Avoid in C# BY KATHLEEN RICHARDS A recent survey conducted by two Swedish BY PATRICK STEELE Microsoft kicked off its 2010 Professional graduate students indicates companies have This installment of C# Corner looks at the Developers Conference (PDC) by off ering diffi culty in picking the right Agile tools in fi ve most common and most dangerous developers worldwide an update on its a fragmented market and, as a result, often traps that developers will want to avoid emerging cloud computing, Windows Phone resort to relying on simple, “tangible” tools when programming in C#. and Internet Explorer 9 dev platforms. such as whiteboards and paper. VisualStudioMagazine.com/Steele1210 RedDevNews.com/Richards1210B ADTmag.com/Ramel1210 Working with a Client-Side AJAX Control ID Statement Visual Studio Magazine BY PETER VOGEL (ISSN 1537-002X) is published monthly by 1105 Media, Inc., 9201 Oakdale Avenue, Ste. 101, Chatsworth, CA 91311. Periodicals postage paid at Chatsworth, CA 91311-9998, and at additional mailing offi ces. Complimentary Peter Vogel looks at a popular (and free) subscriptions are sent to qualifying subscribers. Annual subscription rates payable in U.S. funds for non-qualifi ed subscribers are: U.S. $35.00, International $60.00. Annual digital subscription rates payable in U.S. funds for non-qualifi ed subscribers are: U.S. $25.00, JavaScript grid and notes that one major International $25.00. Subscription inquiries, back issue requests, and address changes: Mail to: Visual Studio Magazine, P.O. diff erence developers will notice when Box 2166, Skokie, IL 60076-7866, email [email protected] or call toll free (888) 768-8759, fax number 847-763-9564. International calls 847-763-9135. POSTMASTER: Send address changes to Visual Studio Magazine, P.O. Box 2166, Skokie, IL working with the client-side controls is the 60076-7866. Canada Publications Mail Agreement No: 40612608. Return Undeliverable Canadian Addresses to Circulation Dept. or absence of wizards and designers. Coders IMS/NJ. Attn: Returns, 310 Paterson Plank Road, Carlstadt, NJ 07072.

will have to type everything themselves. Copyright Statement © Copyright 2010 by 1105 Media, Inc. All rights reserved. Printed in the U.S.A. Reproductions in whole or part prohibited except by written permission. Mail requests to “Permissions Editor,” c/o Visual Studio Magazine, 230 California St. VisualStudioMagazine.com/Vogel1210 Suite 302, San Francisco, CA 94111.

Legal Disclaimer The information in this magazine has not undergone any formal testing by 1105 Media, Inc. and is distributed Coded UI Tests in Visual Studio 2010 without any warranty expressed or implied. Implementation or use of any information BY MICKEY GOUSSET contained herein is the reader’s sole responsibility. While the information has been reviewed for accuracy, there is no guarantee that the same or similar results may be achieved in all environments. Technical The problem with manual testing is that it inaccuracies may result from printing errors and/or new developments in the industry. requires human interaction. To solve this Corporate Address 1105 Media, 9201 Oakdale Ave. Ste 101, Chatsworth, CA 91311 www.1105media.com problem, Visual Studio 2010 has introduced Media Kits Direct your Media Kit requests to Matt Morollo, VP Publishing, 508-532-1418 (phone), Coded UI tests to help automate functional 508-875-6622 (fax), [email protected] UI testing. Jeff rey Levinson explains the Reprints For single article reprints (in minimum quantities of 250-500), e-prints, plaques and posters contact: new Coded UI Test in Visual Studio 2010, PARS International Phone: 212-221-9595 E-mail: [email protected] www.magreprints.com/QuickQuote.asp and shows how to create a basic test. List Rental This publication’s subscriber list, as well as other lists from 1105 Media, Inc., is available for rental. For more information, VisualStudioMagazine.com/Gousset1210 please contact our list manager, Merit Direct. Phone: 914-368-1000; E-mail: [email protected]; Web: www.meritdirect.com.

4 VISUAL STUDIO MAGAZINE · December 2010 · VisualStudioMagazine.com Silverlight, .NET, WPF, WCF, WF, C API, C++ Class Lib, COM & more! Document 'HYHORS\RXUDSSOLFDWLRQZLWKWKHVDPHUREXVWLPDJLQJWHFKQRORJLHVXVHGE\Microsoft, HP, Sony, Canon, Kodak, GE, Siemens, the US Air Force and Veterans Affairs Hospitals.

/($'722/6 SURYLGHV GHYHORSHUV HDV\ DFFHVV WR GHFDGHV RI H[SHUWLVH LQ color, grayscale, document, medical, vector and multimedia imaging development. ,QVWDOO /($'722/6 WR HOLPLQDWH PRQWKV RI UHVHDUFK DQG SURJUDPPLQJ WLPH ZKLOH PDLQWDLQLQJKLJKOHYHOVRITXDOLW\SHUIRUPDQFHDQGIXQFWLRQDOLW\ DICOM Medical ‡Silverlight: 100% pure Silverlight 3 and 4 Imaging SDK. ‡Image Formats & Compression: Supports 150+ image formats and compressions including TIFF, EXIF, PDF, JPEG2000, JBIG2 and CCITT G3/G4. ‡Display Controls: ActiveX, COM, Win Forms, Web Forms, WPF and Silverlight. ‡Image Processing:  ¿OWHUV WUDQVIRUPV FRORU FRQYHUVLRQ DQG GUDZLQJ IXQFWLRQV supporting region of interest and extended grayscale data. ‡OCR/ICR/OMR: Full page or zonal recognition for multithreaded 32 and 64 bit GHYHORSPHQWZLWK3')3')$;36'2&;0/DQG7H[WRXWSXW Form Recognition & Processing ‡Forms Recognition & Processing: Automatically identify and classify forms and H[WUDFWXVHU¿OOHGGDWD ‡Barcode:$XWRGHWHFWUHDGDQGZULWH'DQG'EDUFRGHVIRUPXOWLWKUHDGHG ELW development. ‡Document Cleanup/Preprocessing: Auto-GHVNHZ GHVSHFNOH KROH SXQFK OLQH and border removal, inverted text correction and more for optimum results in OCR and Barcode recognition. ‡PDF & PDF/A:5HDGZULWHDQGYLHZVHDUFKDEOH3')ZLWKWH[WLPDJHVERRNPDUNVDQG Barcode annotations. ‡Annotations: Interactive UI for document mark-up, redaction and image measurement (including support for DICOM annotations). ‡Medical Web Viewer Framework: 3OXJLQ HQDEOHG IUDPHZRUN WR TXLFNO\ EXLOG KLJKTXDOLW\IXOOIHDWXUHGZHEEDVHGPHGLFDOLPDJHGHOLYHU\DQGYLHZHUDSSOLFDWLRQV ‡PACS Workstation Framework: Set of .NET PACS components that can be used to build a full featured PACS Workstation application. ‡Medical Image Viewer: +LJKOHYHOGLVSOD\FRQWUROZLWKEXLOWLQWRROVIRULPDJHPDUNXS Multimedia ZLQGRZOHYHOPHDVXUHPHQW]RRPSDQFLQHDQG/87PDQLSXODWLRQ ‡DICOM:)XOOVXSSRUWIRUDOO,2'FODVVHVDQGPRGDOLWLHVGH¿QHGLQWKH',&20VWDQGDUG LQFOXGLQJ(QFDSVXODWHG3')&'$DQG5DZ'DWD  ‡PACS Communications: Full support for DICOM messaging and secure communication HQDEOLQJTXLFNLPSOHPHQWDWLRQRIDQ\',&206&8DQG6&3VHUYLFHV ‡3D:&RQVWUXFW'YROXPHVIURP'',&20PHGLFDOLPDJHVDQGYLVXDOL]HZLWKDYDULHW\RI methods including MIP, MinIP, MRP, VRT and SSD. ‡Scanning: 7:$,1  :,$   ELW  DXWRGHWHFW RSWLPXP GULYHU VHWWLQJV IRU KLJK Vector speed scanning. ‡DVD: Play, create, convert and burn DVD images. ‡MPEG Transport Stream::LWK'95IRU8'3DQG7&3,3VWUHDPV DXWROLYHVXSSRUW ‡Multimedia: Capture, play, stream and convert MPEG, AVI, WMV, MP4, MP3, OGG, ISO, DVD and more.

Free 60 Day Evaluation! www.leadtools.com/vsm (866) 530-3399

Untitled-9 1 11/2/10 11:42 AM Check out our events at VSLive.com We’ll be in Vegas, at Microsoft HQ and in Orlando in 2011

VisualStudioMagazine.com Letters December 2010 • Volume 20 • No. 12 Editorial Staff Vice President, Doug Barney Editorial Director Silverlight Strategy Editor in Chief Michael Desmond A reader responds to “Protect What’s Yours” (November 2010), in which Andrew Executive Editor Kathleen Richards Managing Editor Wendy Gonchar Brust expressed concerns about Microsoft’s ability to defend its ground: Associate Managing Editor Katrina Carrasco Well, if Brad Becker was vague, Bob Muglia wasn’t: “Our strategy has shifted” Tools Editor Peter Vogel (tinyurl.com/377lexh). I’m just wondering how all the partners who’ve developed products and businesses based on Silverlight feel now. Contributing Editors Andrew J. Brust, Ken Cox, Kathleen Dollard, Bruce Armstrong Roger Jennings, Jeff Levinson, Bill McCarthy, Karl E. Peterson, Keith Pleas, Bill Wagner, Dan Wahlin, John K. Waters Wishing for jQuery Doug Gregory’s tips, presented in our Language Lab section, on using jQuery Art Staff Creative Director Scott Shultz controls in ASP.NET MVC 2 (“Visual Studio 2010 Tips: How to Use jQuery UI Art Director Joshua Gould Controls in ASP.NET MVC 2, Debug WCF Services in Silverlight Apps,” November Production Staff 2010) evoked this reader response: Director, Print Production Jenny Hernandez-Asandas Production Coordinator Serena Barnes Nice article. But when oh when are we Web Forms developers going to have access to server-side controls that use jQuery on the client? I don’t want to give up on Web Online/Digital Media Director, Online Media Becky Nagel Forms and its validation framework—but I’d like to be able to use some controls (like Executive Editor, New Media Michael Domingo a date picker) that use jQuery on the client. Why isn’t Microsoft spending time on Site Administrator Shane Lee this? Surely a couple of interns could crank this out in a few months! Designer Rodrigo Muñoz Posted Online Advertising/Sales VP, Publishing Matt Morollo Regional Sales Manager Chris Kourtoglou Cloud Happy National Accounts Director William Smith A reader responds to Andrew Brust’s Oct. 29, 2010, Redmond Diary blog post, Microsoft Account Manager Danna Vedder “Windows Azure’s 3.0 Maturity in a 2.0 Release,” praising Microsoft’s evolving Windows Azure strategy: Although pundits may have written Microsoft off in the cloud, they ain’t seen President Henry Allain Vice President, Publishing Matt Morollo nothing yet. The cloud movement is a gift to Microsoft. And like Ballmer said, Director of Marketing Michele Imgrund they’re all-in—and I’m in with them! Online Marketing Director Tracy Cook Posted Online

President & Neal Vitale Is Apple Not So Bad After All? Chief Executive Offi cer A reader takes issue with Michael Desmond’s contention that Microsoft “gets” Senior Vice President Richard Vitale developers while Apple does not (“Knowing Developers,” October 2010): & Chief Financial Offi cer Executive Vice President Michael J. Valenti “Microsoft gets developers, and Apple doesn’t.” Really? I’d like to think so, as I’ve Senior Vice President, Abraham M. Langer used [Microsoft] technologies for the past 10 years, and the examples of how they Audience Development don’t get me are evident everywhere. LINQ to SQL—dead. Windows Presentation & Digital Media Vice President, Christopher M. Coates Foundation not having the same tooling support as Silverlight. Kicking Web Forms Finance & Administration to the curb to push Test-Driven Development with Model-View-Controller. Dropping Vice President, Erik A. Lindgren Information Technology Visual Basic 6 off a cliff with the introduction of .NET and no migration wizard worth & Application Development anything. ASP classic crushed and now alive again with IIS Express and WebMatrix Vice President, Carmel McDonagh Attendee Marketing because PHP is kicking butt. Most recently, no SQL Server Compact on Windows Vice President, David F. Myers Phone 7, and Visual Basic as only a CTP that will never see the light of day. Event Operations

I think Microsoft does what it wants to do when the dollars are right, and Apple is Chairman of the Board Jeff rey S. Klein no diff erent. I’m still a fan of Microsoft, but things of course could be done better, REACHING THE STAFF with the developer more at the forefront of their eff orts. Staff may be reached via e-mail, telephone, fax, or mail. Posted Online A list of editors and contact information is also available online at VisualStudioMagazine.com. E-mail: To e-mail any member of the staff , please use the following form: [email protected]. Irvine Offi ce (weekdays, 9:00 a.m. - 5:00 p.m. PT) Visual Studio Magazine wants to hear from you! Send us your thoughts Telephone 949-265-1520; Fax 949-265-1528 about recent stories, technology updates or whatever’s on your mind. 16261 Laguna Canyon Road, Suite 130, Irvine, CA 92618 E-mail us at [email protected] and be sure to include Framingham Offi ce (weekdays, 9:00 a.m. - 5:00 p.m. ET) your first and last name, city and state. Please note that letters may be Telephone 508-875-6644; Fax 508-875-6633 edited for form, fit and style. They express the views of the individual 600 Worcester Road, Suite 204, Framingham, MA 01702 Corporate Offi ce (weekdays, 8:30 a.m. - 5:30 p.m. PT) authors, and do not necessarily reflect the views of the VSM editors or Telephone 818-814-5200; Fax 818-734-1522 1105 Media Inc. 9201 Oakdale Avenue, Suite 101, Chatsworth, CA 91311

Visual Studio Magazine The opinions expressed within the articles and other contents 6 VISUAL STUDIO MAGAZINE · December 2010 · VisualStudioMagazine.com herein do not necessarily express those of the publisher. Untitled-1 1 11/10/10 3:05 PM

{ SOFTWARE DEVELOPMENT GONE WRONG }

The .NET Whistleblower

Terry had spent the better part of the past whether they were completed successfully decade digging through the trenches of or not: QuidCorp’s fl agship application QuidFlow—a Function UnLockRecord( program used to fl owchart business strTableName) As boolean processes. Though QuidFlow performed well if strTableName = "" then and, overall, customers were happy with the strSQLText = "DELETE FROM LOCKINFO product, whenever it came time to address WHERE PERSNO=" & a bug or investigate just how the fi lename SQLQuote(session("LOGGEDUSER")) validation worked; the source code was Else beginning to show its age. strSQLText = "DELETE FROM LOCKINFO Terry raised his concerns to management. WHERE TABLENAME = " & Much to his surprise, management approved SQLQuote(strTableName) & " AND PERSNO=" Whistleblow a plan to transition their C++ developers & SQLQuote(session("LOGGEDUSER")) Concerned that QuidCorp might actually into the world of .NET through a little End If ship something so fetid and maligned, Terry on-the-job experience. ExecSQL(strSQLText) decided he had to pay a visit to QuidFlow’s Unlockrecord = false project manager. Homemade with Love End Function “You’re right, Terry, this is in no way a Paired up with a senior programmer who solid application, but unfortunately, it is had been working on QuidFlow, an ASP.NET Function SystemInfoClear() As boolean what it is,” the project manager explained. document control app written in VB.NET, ExecSQL("DELETE FROM SYSTEMINFO") “However, that’s why we’re assigning all Terry was handed some completed quality SystemInfoClear = False you C++ guys with your awesome track assurance (QA) test plans. End Function record to look into these bugs so we’ll be “Don’t stress yourself out trying to fi gure It was widely known that QuidFlow would able to ship QuidFlow!” out how to solve every problem just yet,” kick back strange and frightening messages Somehow, the compliment didn’t feel right. the senior programmer advised, “really just when things went horribly wrong. As such, At the end of the week, Terry and his fellow get yourself versed in how to check the Terry could appreciate why a developer QuidFlow developers were pulled from their code out, compile it and poke around a bit.” would want to shield a division by zero error on-the-job .NET training. QuidCorp had just The application refused to start and when or a similar condition from a user. sold a motherload of QuidFlow licenses to a Terry eventually managed to get it going, However, this feeling of appreciation was corporate client and they were asking for exceptions were thrown all over the place reversed somewhat after seeing two some big-time enhancements, which would of by the runtime environment when he tried similarly named functions immediately course mean they needed all C++ developers to run the application on his local machine. thereafter. Though he wasn’t even on hand immediately. Throughout the codebase, there was one remotely close to being able to call himself While the move of QuidFlow to .NET was section of code common to all the pages. a Web developer, Terry felt that there had on hold until some time freed up, their Sharing common code is a great thing—Terry to be an easier way of rendering the HTML hands-on .NET training wasn’t all for nothing. had employed a similar method in C++. at the top of each page. See the code at When the time came, at least they would However, in this one module, above all VisualStudioMagazine.com/DevDis1210. know how not to develop a .NET app. VSM others, there was something funny about how it all worked. Tell Us Your Tale Not in Kansas Anymore First of all, in his old role functions returned Mark Bowytz is a contributor to the popular Web site The Daily WTF (thedailywtf.com). He has a meaningful value. However, littered more than a decade of IT experience and is currently a systems analyst for PPG Industries. Have you experienced the darker side of development? We want to publish your story. E-mail your tale through QuidFlow were functions, which to Executive Editor Kathleen Richards at [email protected] and put “DevDisasters” ETTER RYAN BY ILLUSTRATION always returned the same value of False, as the subject line.

8 VISUAL STUDIO MAGAZINE · December 2010 · VisualStudioMagazine.com Project3 12/16/09 11:55 AM Page 1

ERwin Data Modeler

CA Inc. VSToolbox Web: erwin.com Phone: 800-225-5224 Price: $4,795 Designing Databases Quick Facts: A comprehensive tool for data modeling and managing with ERwin Data Modeler 7.3 database designs This complete package takes care of modeling data and managing the resulting Pros: Provides end-to-end support designs—provided you’re using entity-relationship modeling to design your databases. in one package for both operational databases and data warehouses Cons: Expensive; may be more tool BY PETER VOGEL You can also reverse engineer existing than you need This month we’re looking at two related databases to create a data model. ERwin tools for data modeling: CA ERwin Data goes beyond data structures to include Modeler 7.3 ERwin Data Data ERwin Modeler for designing your database modeling triggers and stored procedures. As ERwin will import and export models schema and Red Gate SQL Source Control you make changes in development, ERwin from a huge number of formats and for keeping track of the changes that you can generate alter scripts that will upgrade repositories, including UML, XML and the make to your schema as you add and your production database to match the Common Warehouse MetaModel. modify applications. It’s easy to see why changes you’ve made in your dev database. Integration with Visual Studio is lacking, ERwin earned Merit Award distinction in ERwin also understands the difference though ERwin does integrate with Visual the Databases and Data Development and between operational databases and data Studio Team System 2008 Database Edition. Modeling category of this year’s VSM warehouses. It includes tools that support With large data models, the ERwin Readers Choice Awards. The tool may be linking several operational databases to reporting tools let you produce summaries expensive, but it’s hard to think of anything create a single data warehouse, and for of key information. ERwin comes with ERwin doesn’t do in the data-modeling field. modeling the fact tables that support Crystal Reports, but will probably work ERwin lets you graphically develop a end-user reporting. Unfortunately, ERwin with your existing reporting tools via an logical data model and generate a database uses two separate modeling tools for OBDC read-only driver. You can output schema from your design, which you can operational databases and warehouses. You results in a variety of formats. implement in your relational database can convert operational models to There are two caveats. First, the “ER” in management system. ERwin likely supports warehouses, but the conversion only ERwin stands for entity-relationship your relational database engine—the latest handles the differences between the modeling. If you’re looking to generate a version adds support for Teradata, for modeling tools and doesn’t add support for database from your class design, ERwin instance. The ERwin design interface makes data warehousing—that’s up to you. ERwin probably isn’t the tool you want—look for a it easy to lay out and refine your initial designs. supports simple volumetric analysis so you UML-based tool. ERwin has data modeling, But only two notations are supported: can estimate database size and forecast rather than object modeling, at its core. IDEF1X and Information Engineering. hardware requirements. The other caveat is price. At $4,800, you’ll have to ask yourself if you need all the tools that ERwin provides. If you’re not planning on building a data warehouse, ERwin support in that area won’t have much value for you. There are some free data-modeling tools available (including a community edition of ERwin Data Modeler) and standalone tools that provide functionality that the free tools are missing. Red Gate SQL Compare, for instance, costs less than $400 and will allow you to compare two databases and generate an alter script. Putting together a collection of tools won’t give you the integration that ERwin provides, but it will let you pick just the ones you need. VSM

Peter Vogel ([email protected]) is the tools editor When reverse engineering an existing database, ERwin not only provides a long list of for VSM and a principal in PH&V Information objects it will model, but also infers relationships not explicitly defined in the database. Services, specializing in ASP.NET development.

10 VISUAL STUDIO MAGAZINE · December 2010 · VisualStudioMagazine.com Create cutting edge reports with the complete set of tools from Altova®

Experience how the Altova MissionKit®, the integrated suite of XML, database, and data integration tools, lets you display and analyze data through enhanced chart and report generation.

Report generation is finally easy – and affordable – with Altova MissionKit reporting tools:

StyleVision® – stylesheet and report design tool • Consolidated reporting based on XML, database and/or XBRL data • Dynamic data selection and rendering • HTML, Microsoft Word, PDF, and e-Form report creation New in XMLSpy® – advanced XML editor Version 2011: • Instant creation of charts to analyze XML data Ground-breaking • One-click export of charts to XSLT, XQuery, or image files support for chart creation MapForce® – any-to-any data mapping tool • Integration with StyleVision for rendering attractive reports • Report generation for virtually any data format: XML, databases, EDI, flat files, Excel 2007+, and more

Download a 30 day free trial!

Try before you buy with a free, fully functional, trial from www.altova.com

Untitled-9 1 11/2/10 11:41 AM SQL Source Control

VSToolbox Red Gate Software Ltd. Web: red-gate.com Phone: 866-997-0397 Manage Database Design Price: $295 Red Gate SQL Source Control is a useful tool for SQL Server developers using TFS or Quick Facts: Integrates other Red Subversion, but falls short in managing database design changes. Gate products into one of two popular source-control tools Pros: Integrates with SQL Server BY PETER VOGEL can also view all the history of changes made Management Studio to provide Red Gate Software Ltd. has always to the database, when they were made and simple source control for database provided tools for managing SQL Server who they were made by. Using an SVN bug design changes databases. The company’s latest offering is or TFS work item, you can also associate a Cons: Not a complete source-control SQL Source Control, which, to quote Red database change with a bug-tracking management tool; only directly Control Gate’s marketing, promises to “bring all of system—for example, TFS or Fogbugz. supports replacing versions of a SQL Source Source SQL the benefits of source control to your However, to fully embrace the “database database with a version from your database.” That’s not quite true, but it’s changes as source control” paradigm, I’d source-control system close enough. expect to be able to do more—to create SQL Source Control isn’t a standalone forks in my database design, for instance. tool—it’s actually the intersection between You don’t get that, at least not directly. Also, the Red Gate SQL Compare tool and a SQL Source Control doesn’t so much roll ToolTracker source-control package, either Team your database design forward or backward Foundation Server (TFS) or Subversion as replace the current version with your Free or Almost-Free (SVN). SQL Compare, when given two selected version. That’s too bad, but for the Data-Modeling Tools databases, produces a script that converts price you pay (about $700 for SQL Is ERwin Data Modeler overkill for one database into a copy of the other. What Compare plus SQL Source Control) you’ll your needs? Consider these SQL Source Control brings to the party is a save the equivalent time on your next low-cost or no-cost alternatives. simplified way to generate that delta list version release. ERwin Community Edition will and commit it to your source-control You must install SQL Source Control on reverse engineer and generate a system. In many ways, this is how a a computer with SQL Server Management database from a model. But it’s sophisticated source-control package Studio (SSMS) or SSMS Express 2008. VSM limited to 25 objects, which cripples works—it stores the changes from one it for real apps. It will compare two version to another. Peter Vogel ([email protected]) is the tools databases but won’t synchronize With your database changes under source editor for Visual Studio Magazine and a principal them. tinyurl.com/28ocxmh control, you can replace a database with one in PH&V Information Services, specializing in Oracle SQL Developer Data of the versions stored in source control. You ASP.NET development. Modeler surprisingly supports SQL Server natively, rather than through ODBC. It uses the Barker and Bachman notations. tinyurl.com/2dpeh5t DBDesigner-Fork originally was built for MySQL, but the current version actually supports SQL Server. tinyurl.com/baca9x wwwsqldesigner lets you design databases in your browser and export a script to implement your design—but there’s no reverse engineering. tinyurl.com/5pse87 Enterprise Architect costs just $100. It uses UML for modeling notation and includes database generation and reverse engineering. tinyurl.com/bador —P.V. Apply changes from source control to your database structure and review the history of those changes from SQL Server Management Studio.

12 VISUAL STUDIO MAGAZINE · December 2010 · VisualStudioMagazine.com 0810vsm_GrapeCity_Insert.indd 1 10/4/10 10:48 AM 0810vsm_GrapeCity_Insert.indd 2 10/4/10 10:48 AM

VSInsider BY MARK MICHAELIS The HTML5 Factor

so in many more Microsoft conferences to However, Microsoft’s investment in the come. This particular PDC, however, was future by no means stops with HTML5. about winning back the browser and phone Microsoft is extremely committed to markets while establishing a lead for cloud Silverlight and WPF for the foreseeable technology. The focus on HTML5 being future; they are pillars of the company’s part of the message was to show Microsoft’s strategic direction. A vast majority of commitment to standards in Internet Microsoft’s revenue continues to come HTML5 Explorer 9, not to indicate a lack of focus from Windows, and there’s no doubt the on the other UI technologies. company is committed to providing the As we approach the end of 2010, the best development experience and resulting proliferation of devices has skyrocketed software for applications targeting Windows. and shows no sign of abating. If you wish to WPF leads the way in capabilities for write an application that has the broadest targeting Windows, but it requires the reach across all these devices, HTML is .NET Framework Client Profile at a undoubtedly the way to do it. It’s the only minimum and deployments and updates During the 2010 Microsoft Professional platform that attempts to achieve write- are likely to be via ClickOnce. Developers Conference (PDC) in late once/run-anywhere. By adding HTML5 If your target reach extends to the Mac October, the keynote address demonstrated support to Internet Explorer 9, Microsoft is or Windows Phone 7, then Silverlight is the Internet Explorer 9 and its superb support establishing a minimum Internet Explorer way to go. As with any technology, for HTML5. As part of this, browser that will work when HTML5 is the however, writing a single Silverlight UI for stated: “Microsoft will build the world’s norm. When targeting HTML5 today, diverse targets such as the desktop and best implementation of HTML5 for devices you’ll be writing two versions of your UI: phone is not advisable. Instead, as running Windows.” And Bob Muglia told one that targets HTML5-supporting announced at the PDC by Shawn Burke, an reporter Mary Jo Foley: “Our Silverlight browsers (for which implementation architect on the team, strategy and focus going forward has varies), and one that targets plain HTML. developers should strive to achieve code shifted.” This sparked a significant level of For the broadest reach today, create a basic reuse in the business logic and as close to concern among developers committed to HTML Web application and a second one the UI layer as possible. Each target should Microsoft development technologies: Are that supports Silverlight for a richer UI then have its own UI implementation. Silverlight and Windows Presentation experience. Using HTML5 in place of One final point: If you have a n existing Foundation (WPF) still the right choices— Silverlight will result in less reach and a application that already targets ASP.NET, and how long will investment in these suboptimal UI experience—HTML5 Silverlight or WPF and it’s working well technologies remain viable? The fact that applications are far less capable than those for you, don’t change what you have. throughout the conference there was written in Silverlight. Microsoft is committed to each of these relatively little information on new technologies—not just to supporting technology for WPF or Silverlight didn’t Heavy Investment them, but to investing in them and help ease the worry. In this column I’ll Make no mistake, Microsoft will be enhancing them in the long run. VSM address these concerns. investing heavily in many platforms. For it to do otherwise would be a disappointment Mark Michaelis started IntelliTechture Corp. and Commitment to Standards to us and a huge mistake for the company. serves as chief technical architect and trainer. WPF and Silverlight have garnered Redmond’s recent investment in HTML5 is He’s been a Microsoft MVP for C#, Visual Studio significant limelight for UI development great because it shows a commitment to Team System and the Windows SDK since 1996. since their initial launches—in 2006 and standards as well as a renewed focus on In 2007, he was recognized as a Microsoft 2007, respectively—and will continue to do winning back the browser market. regional director.

Make no mistake, Microsoft will be investing heavily in many platforms.

VisualStudioMagazine.com · December 2010 · VISUAL STUDIO MAGAZINE 13 Untitled-4 2 11/8/10 2:56 PM Untitled-4 3 11/8/10 2:56 PM VSM COVER STORY

Silverlight Futures With HTML5 promising native support for video and animation, what can developers expect from Silverlight in the months to come? BY KATHLEEN RICHARDS

Developers’ excitement about the U.S. rollout Uncertainty in the developer community was initially sparked in March by Microsoft’s release of the Internet Explorer 9 Platform of Windows Phone 7 on Nov. 8 was tempered by growing Preview, which centered on HTML5, the next version of the HTML questions about the future of Silverlight, the Microsoft standard for creating text and elements in Web sites. HTML5 is a giant leap forward with support for inline video, audio, animation rich Internet application (RIA) and Windows Phone 7 and other interactive features provided today by browser plug-ins development platform. such as Silverlight and Adobe Flash.

16 VISUAL STUDIO MAGAZINE · December 2010 · VisualStudioMagazine.com Untitled-1 1 10/14/10 12:00 PM COVER STORY Silverlight Futures

“‘Windows development’ now all of a sudden doesn’t just mean Windows. It means Windows, Windows Phone, Windows Embedded Devices—they’ve [even] decided that it includes the Mac.” Rockford Lhotka, Principal Technology Evangelist, Magenic

Recently, anxiety has been heightened by reports of alleged internal compelling OS, it has to come with a compelling browser that can do conflicts at Microsoft about HTML5 versus Silverlight, ambiguous all this stuff that we want the Web sites to do—so Internet Explorer 9 messaging and blog postings, and less emphasis on Silverlight tech- makes all the sense in the world in terms of making sure that Windows nology outside of Windows Phone 7 development at the 2010 remains a very good Web client.” Microsoft Professional Developers Conference (PDC10) in October. Microsoft, he says, has to have a dual strategy of supporting the The Silverlight 4 beta release, which added functionality that Web in a very powerful way, while simultaneously supporting solidified the RIA platform’s viability for line-of-business (LOB) smart client development. apps, was a major highlight of PDC09. Silverlight 4 shipped in “If the browser is the client technology and everybody is only mid-April, topping off a three-year tear of rapid releases since the building apps for the browser, then Windows becomes irrelevant, technology was introduced in 2007. right? Clearly, they’re not going to do that,” Lhotka says. “‘Windows During that time, many Visual Studio developers have come to rely development’ now all of a sudden doesn’t just mean Windows. It on the plug-in for uniformity across Web sites and browser imple- means Windows, Windows Phone, Windows Embedded Devices— mentations, and they’ve applauded the Microsoft .NET Framework they’ve [even] decided that it includes the Mac. Silverlight is clearly productivity offered by Silverlight, which features a subset of the a great technology for enabling that type of development target.” .NET Framework and the CLR. More than 600,000 developers are developing for the platform, according to Microsoft. Shift in Strategy “I really don’t think HTML5 and Silverlight are competing for the Microsoft’s failure to communicate that Silverlight is no longer viewed same plot of land,” says Todd Anglin, chief evangelist for Telerik Inc., as the primary cross-platform runtime solution for .NET developers a toolmaker for Silverlight and Windows Phone 7, among other came to a head at PDC. Comments about a shift in Silverlight strategy Microsoft technologies. “I think there’s a future where Silverlight made by Bob Muglia—president of the Microsoft Server and Tools and HTML5 continue to coexist and technologies like Windows Division—during a PDC interview were reported by longtime Phone 7 only underscore that reality. HTML5 and related technologies Microsoft watcher Mary Jo Foley in her All About Microsoft blog. will be perfectly suited for building the rich, standards-based Web, Silverlight is the development platform for Windows Phone 7, “sweet and I think eventually as HTML5 solidifies and as more and more spots” in media and LOB apps, and a cross-platform runtime solution browsers uniformly implement [it], Silverlight may be used on for some OSes and browsers, Muglia explained in the interview. occasion to provide greater degrees of richness in the browser. But “But HTML is the only true cross-platform solution for everything, for the most part, the rich Web will be done through HTML5.” including [the Apple] iOS platform,” he reportedly said, according to Mary Jo Foley’s Oct. 29 blog, “Microsoft: Our Strategy with Silverlight Dual Strategy Has Shifted.” Criticized over the years for failing to conform to World Wide Web Various interpretations of Muglia’s comments went viral, which Consortium (W3C) and International Organization for Standardiza- ignited an uproar on the Web and Twitter. The aftershocks even tion (ISO) standards, Microsoft with Internet Explorer 9 seems to reached mainstream media outlets such as The Wall Street Journal. be addressing those concerns, with aggressive support for HTML5 The resulting confusion has forced some developers to face tough (including 2D rendering with Canvas), Cascading Style Sheets 3 questions after working to convince management and customers (CSS3) and Scalable Vector Graphics (SVG). The goal is to enable to commit to Silverlight technology. developers to use the “same markup” across browsers. “[W]e’ve been hit by a big wave of questions,” says Louis-Philippe “Internet Explorer is the dominant browser and everybody hates it Pinsonneault, a senior .NET developer at consultancy RunAtServer because it’s not compliant with any other browser,” says Rockford Inc. and a Microsoft MVP in Device Application Development. Lhotka, principal technology evangelist at Magenic. “On the other “My company, RunAtServer, is seen as the local leader in RIA and hand, I use a lot of browsers and none of them are compliant with Silverlight applications, so we had to reassure our customers that each other, so I think that criticism of Internet Explorer is a little false.” Silverlight is there to stay. We had some customers who put projects Internet Explorer 9 and its support of GPU-accelerated HTML5 on hold. But once the customers understood the real meaning of were spotlighted during the opening segment of the PDC10 keynote the ‘shift in strategy,’ everything went back to normal.” by Microsoft CEO Steve Ballmer and VP Dean Hachamovitch, Many Silverlight devotees remain unfazed. “Certainly the spin who’s in charge of Microsoft browser efforts. In September, when on what was quoted by Mary Jo was shocking, but the reality I the Internet Explorer 9 beta was released, Microsoft announced think is not nearly so sensational,” says Lhotka. “Anyone who that Bing and Xbox 360 will support HTML5 compatibility—in stopped and thought about it would realize that Microsoft has some instances replacing smooth streaming and Silverlight—in an invested an amazing amount of resources and energy into making effort to lower costs with the ESPN3 video application. Windows Silverlight a primary development target for Windows, for the Phone 7 at launch does not support HTML5. browser, for the Mac, for the phone, for embedded devices. So the “It’s clear that the expectations of all of us for the Web are raised,” says idea that just on a whim they would go, ‘Oh yeah, HTML5 will Lhotka, who identifies himself primarily as a Silverlight developer. actually become real in about three to five years, so we’re going to “We expect more from our Web sites. For Windows to continue to be a bet the whole company on that.’ I mean, that’s crazy.”

18 VISUAL STUDIO MAGAZINE · December 2010 · VisualStudioMagazine.com Untitled-1 1 10/14/10 12:00 PM COVER STORY Silverlight Futures

“HTML5 is good for sites, Silverlight is good for applications.” Louis-Philippe Pinsonneault, Senior .NET Developer, RunAtServer

Andrew Brust, chief technology officer at Tallan Inc. and Redmond blog in early November. He reiterated that Silverlight is a strategic Review columnist for Visual Studio Magazine, says Microsoft’s technology for Microsoft and that the company’s investments in the Silverlight strategy had to change to account for HTML5. “But the technology focus on three core areas: client apps inside and outside the phrase ‘our strategy has shifted’ made it sound like Silverlight was browser, apps on devices (Windows Phone and Windows Embedded) being explicitly de-emphasized. And even if that were true, I’d be and media solutions. surprised to hear someone pronounce it so directly,” Brust says. Guthrie explained: “Where our strategy has shifted since we first Scott Guthrie, Silverlight lead and corporate vice president of the started working on Silverlight is that the number of Internet-connected Microsoft Developer Division, addressed Silverlight concerns in his devices out there in the world has increased significantly in the last

HTML Everywhere

In early November, Brian Goldfarb, director of Developer Platforms at HTML5 is designed to support inline video and audio tags and Microsoft, reiterated the new thinking behind Silverlight to reassure interoperability of implementations, but it’s a work in progress a developer who commented on the Nov. 1 Silverlight Team Blog. and there has been no agreement on the video codecs that the “The key thing that has been clarified is that we see HTML as standard will support. H.264-encoded HTML5 video is supported in the technology that gets you everywhere,” Goldfarb responded to the Apple iPad and Internet Explorer 9, but the threat of licensing the commenter. “In fact, for the broadest reach today, the solution fees stopped Mozilla and others from supporting it. In August, you should use is HTML4. But if [you] want a richer, more tailored MPEG LA announced indefinite royalty-free licensing for Internet experience, on the devices and areas we support—and we’re Broadcast AVC video. investing in this with Windows Embedded, Automotive, Desktop, In April, Apple posted CEO Steve Jobs’s “Thoughts on Flash” Phone and more in the future—both in and out of the browser, manifesto against Adobe Flash and then changed course for [then] Silverlight was and continues to be your best solution.” some App Store apps shortly after Android 2.2, which supports Is HTML everywhere a realistic approach to Web develop- Flash 10.1, was released. ment solutions today, given its history and inconsistency across “I don’t think it’s a matter of will Flash be somewhere where implementations? Silverlight isn’t,” says Todd Anglin, chief evangelist at Telerik Inc. “HTML 1, 2, 3 and 4 have been complete failures in terms of “I think both of these rich plug-ins face the same reality that rich writing one Web page and having it work across all the browsers, Web development will increasingly move toward HTML5. The so it would be insane to think that HTML5 is going to be any standard had simply been unable to keep up with rich Web, so we different,” says Rockford Lhotka, principal technology evangelist, needed plug-ins to overcome that and now we have a standard Magenic. “I have zero expectation that we’re going to be able to that’s up to par and looking forward to the future so we don’t write a Web page and have it work across all the browsers—that’s have as much need for plug-ins to fill in that gap. just not going to happen. However, I have complete confidence “However, we still have the need to build rich client apps and that I’ll be able to write a Silverlight application and have it work we still need platforms for doing so that are suited for the rich across all the Silverlight targets.” client app experience,” Anglin continues. “In that arena I think World Wide Web Consortium (W3C) HTML4 was released in Silverlight will be successful both on the desktop and on the 1999 and updated in 2001. HTML4.1 was followed by a serialized phone. I think Flash or the Adobe products have a weaker story: XML version of HTML called XHTML 1.0. But XHTML1.0 ran into They’re not as well-suited to the developer experience.” compatibility issues with older technologies. IDC Program Director Al Hilwa, who specializes in applications With an emphasis on backward compatibility, Apple Inc., development software, liked a lot of what he heard at the Adobe MAX the Mozilla Foundation and Opera Software ASA formed Web conference in late October. “[T]he overall sense I get is that this is Hypertext Application Technology Working Group (WHATWG) to a company that understands its destiny is to take its platform to drive the HTML5 specification, which also includes updates to the mobile world, and I think they’re right,” he wrote in an analyst XHTML1.0 and DOM2 HTML. In 2006 W3C, which had focused its note. “They’re really doing more for multiscreen, multiform efforts on other technologies, decided to rejoin the effort and a factors, multichannel (print, online, mobile) development than working group was formed to work with WHATWG in 2007. The anyone else in the industry. I think the publishing ventures are HTML5 specification, which is currently in the W3C Working Draft unique and I love the idea of an app store that does the busy stage, is edited by Ian Hickson of Google Inc. According to the work on behalf of the overwhelmed developer to get their apps W3C Working Draft: “Apple, Mozilla and Opera allowed the W3C to to many of those proliferating markets. I think that’s a killer idea.” publish the specification under the W3C copyright, while keeping At the same time, Hilwa thinks that Adobe has focused too a version with the less restrictive license on the WHATWG site.” much on the HTML5 threat. “[The] reality is that HTML5 won’t Therefore, WHATWG HTML5 is not identical with W3C HTML5. touch Flash in features, adoption, pixel fidelity or ease of Although the official schedule lists 2010 for a release candidate development for many years to come,” he wrote. “I do expect of the W3C version of the standard, it’s likely years away (though HTML5 to replace HTML for sure, but there will always be room vendors are already starting to implement parts of it). at the top for high-end plug-ins.” —K.R.

20 VISUAL STUDIO MAGAZINE · December 2010 · VisualStudioMagazine.com Untitled-1 1 10/14/10 12:01 PM COVER STORY Silverlight Futures

“The media support in HTML5 is a breakthrough relative to HTML4, but it’s rather primitive compared to Silverlight—or Flash, for that matter.” Andrew Brust, CTO, Tallan Inc.

two years (not just with phones, but also with embedded devices Silverlight 4, Microsoft has introduced some functionality, which is like TVs), and trying to get a single implementation of a runtime only available for a specific platform. COM is an example,” he says. “So across all of them is no longer really practical (many of the devices I’m not surprised that they decided to offer platform-specific function- are closed platforms that don’t allow extensibility). This is true for ality. This is the real meaning, in my eyes, of the ‘shift in strategy.’” any single runtime implementation—whether it’s Silverlight, Flash, Pinsonneault says Silverlight and HTML5 are still complemen- Java, Cocoa, a specific HTML5 implementation or something else.” tary technologies, similar to Silverlight and HTML4 today. “Yes, IDC analyst Al Hilwa agrees with that assessment. “The world HTML5 provides an easier way to display video and animation has actually changed in the last three years in this one important than previous versions. But when we talk about live streaming video, respect: application platforms are proliferating like wildfire. And Silverlight is the product of choice. HTML5 is good for sites, in such a transformative age where this proliferation might get Silverlight is good for applications,” he says. Several content pro- worse before it gets better, it’s going to be impossible to support all viders rely on Media and PlayReady DRM platforms,” Hilwa explains. platforms, which are supported in Silverlight. Hilwa notes that many key platforms restrict the use of layered plat- “The media support in HTML5 is a breakthrough relative to HTML4, forms above them. Both iOS and Windows Phone 7 follow this model. but it’s rather primitive compared to Silverlight—or Flash, for that “What I’m hearing from Microsoft is a perfectly sane strategy, which matter,” agrees Brust. “And I expect that ‘delta’ in media capabilities is to target a specific set of platforms and do them well,” Hilwa says. might grow in size.” Silverlight will continue to be multi-platform, but use a different Silverlight was always intended to be an RIA platform and RIA approach than when it was first introduced, says Pinsonneault. “Since really means interactive LOB apps, says Magenic’s Lhotka. “It’s

Silverlight: What Web Forms Wanted to Be BY TODD ANGLIN

ASP.NET Web Forms was ahead of its time. An ambitious attempt Ultimately, Microsoft created a Web development platform tuned for to make programming for the Web feel like programming for LOB applications, and abstracted as much of “the Web” as possible Windows, Microsoft introduced an innovative platform in January without requiring custom browser software. 2002 that heavily abstracted the complexities of developing UI Unfortunately, the Web and magic do not mix. Eventually, Web elements with HTML and transformed Web development into applications must pay a price for the illusion they have the state an experience nearly indistinguishable from the complementary that comes naturally to their desktop counterparts. As much as Windows Forms. Web Forms is a style of ASP.NET Web develop- Web Forms tries, it can’t overcome the fact that it’s operating in a ment designed to bring the familiar event-driven programming stateless environment. While it goes a long way to close the gap model of Visual Basic and Windows Forms applications to the between desktop and Web development, it never fully realizes the Web. It unlocked the opportunities of Web development for the goal of making Web development feel like desktop development. masses of existing client-application developers coming from a Does that mean Web Forms is a bad idea? Of course not! decade of Visual Basic. Almost. Businesses understand the value of applications that can be easily The key problem that Web Forms had to solve: making a deployed and updated via the Web, avoiding the slow and resource- “stateless” development environment behave as if it had state. intensive process of building, testing and deploying software to The Web is inherently “forgetful.” Once a server delivers a page, desktops. In a perfect world, businesses would be happy to take it forgets about it. This presents a challenge for line-of-business existing desktop applications, along with the associated “stateful” (LOB) applications that often need to do some processing and development model, and marry that to the Web’s simplified redisplay a form while retaining changes made by the user. deployment. Web Forms tried—it just failed to go far enough. With nearly a decade of hindsight, Microsoft recognized that the Microsoft’s Secret Sauce only way to truly achieve the utopia businesses desired was to stop Overcoming this forgetfulness in a standards-based way, relying trying to work magic with the Web and instead build and deliver a on nothing but the Web’s traditional HTML and HTTP infrastructure, plug-in that completely avoids the limits of browsers. Silverlight is borders on magic. The underlying features that grant state to the the solution. A cross-browser, cross-platform plug-in, Silverlight is Web might as well be magic for many Web developers. Microsoft a Microsoft technology for building rich Internet applications using created a complex processing system that included a secret sauce the popular .NET programming model and tools. called “ViewState” to overcome the forgetful nature of Web servers Silverlight is what Web Forms wanted to be: a stateful application toward the pages they serve. At the same time, Microsoft heavily development model that can be deployed and updated as easily abstracted developers away from the core technologies of the as traditional Web sites. Unencumbered by the limits of stateless Web—HTML, CSS and JavaScript—and instead introduced a model that interpreted server markup to produce the needed output. Continued on p. 24

22 VISUAL STUDIO MAGAZINE · December 2010 · VisualStudioMagazine.com Untitled-1 1 10/14/10 12:01 PM COVER STORY Silverlight Futures

“Client development—even rich native development for a platform like Windows Phone, I think—needs something that goes beyond HTML5.” Todd Anglin, Chief Evangelist, Telerik Inc.

more compelling than Windows Forms or some of the older .NET has more access to the local processor, has more access to the technologies because it has simple browser-based deployment and, local system APIs. I think that’s where the Silverlight future lives yet, has all of the smart-client capabilities that we want.” in the .NET space, as more of a replacement for what we might Magenic is building several enterprise apps for customers in call traditional client application development with Windows government and large organizations that run in the browser. Many Forms and Windows Presentation Foundation and other technol- of these projects were started in Silverlight 3 and then transitioned ogies of the past. Silverlight comes in to replace that model, giving to Silverlight 4. The apps support things like geolocation mapping us the true desktop-like development experience while taking out and terrain analysis, and are often used by people who are managing the sort of overhead that has existed in the past for desktop data in the field. Silverlight makes real-time field validation and application deployment.” other functionality a lot easier to build. Anglin says Windows Phone 7 is a case in point. The Windows Magenic also used Silverlight for Windows Phone 7—a subset of Phone Marketplace is an ideal platform for selling Silverlight appli- the Silverlight technology that’s closer to Silverlight 3—to build and cations that target the native capabilities of the Windows Phone 7 market a consumer-facing app in the Windows Phone Marketplace. platform in a way that HTML5 is “frankly incapable of doing,” he says. The Windows Phone 7 app, GuestList, is a front-end to a Web service “We see it on the iPhone. We see it on the Android. So this is definitely called Eventbrite for running user groups, conferences or meetings. played out in other mobile environments as well,” he explains. It allows you to check people into the event as they arrive. “Client development—even rich native development for a plat- Silverlight 5 form like Windows Phone, I think—needs something that goes Scott Guthrie is expected to talk more about the Microsoft vision for beyond HTML5,” agrees Telerik’s Anglin. “It needs something that Silverlight—and what’s coming in the next release—when he gives

Continued from p. 22

pages, developing for Silverlight finally achieves what ViewState new Visual Studio LightSwitch from Microsoft. Targeted could not: It allows traditional desktop application developers to exclusively at simplifying LOB development, LightSwitch produces reuse their skills and development patterns for apps that can be applications that can be deployed to the Web or desktop, and it deployed with no installation, save for the Silverlight plug-in. uses Silverlight to produce both experiences. It also solves many of the other “problems” Web development Silverlight is not a silver bullet. It requires a software install creates for client application developers. With a consistent to load the plug-in. With locked-down corporate networks, or runtime not pegged to unpredictable browser implementations, devices such as the Apple iPad, this software is inaccessible. In Silverlight is able to deliver a consistent user experience without many ways, Silverlight is best viewed as a replacement for client requiring days of extra testing and tweaking. The improved application development and not a replacement for Web develop- statefulness enables rich experiences often omitted in Web Forms ment. Even Web Forms is designed more to help with “client-like” applications, such as real-time field validation and error messages. application development than “pure” Web development. That Web Forms attempted to offer solutions to provide similar richness, point is reinforced by the recent introductions of ASP.NET but the perceived complexity of JavaScript, AJAX, and a host of variants, such as ASP.NET MVC, that move away from the other technologies needed to make it all come together often left simulated stateful programming model in Web Forms. For Web time-strapped enterprise developers on the sidelines. site development, or for applications where the Silverlight plug-in cannot absolutely be guaranteed, one of ASP.NET’s powerful Browser and Desktop variants is still the best choice for development. It’s clear that Silverlight is the natural successor to Web Forms, Microsoft envisioned a world in 2002 where developing for but its value extends beyond the original vision of Web Forms. the Web and Windows would be indistinguishable. Windows Able to run out of the browser context and in absence of a Forms and Web Forms tried to present a uniform approach, but network connection, Silverlight is arguably an up-and-coming ultimately Web Forms was bound by the limits of the Web and replacement for traditional client application development, too. the vision was never fully realized. In all but the most unique applications, Silverlight’s capabilities With Silverlight, Microsoft’s vision is nearly complete: A single, make it a suitable replacement for apps that today may be built unified programming model for building applications that run with Windows Forms or Windows Presentation Foundation (WPF). on the Web, desktop and—with the release of mobile OSes like With a single development and deployment model, Silverlight Windows Phone 7—the emerging Internet-connected device, too. applications can target both browser-based and desktop use Web Forms and Silverlight will continue side-by-side long into the cases. Whereas Windows Forms and Web Forms require two future, but for LOB applications, Silverlight has the momentum— distinct approaches to .NET application development, Silverlight and Web Forms to thank for laying the foundation. allows developers to focus on mastering a single approach. If more evidence is needed to prove this is the future, examine the Todd Anglin is chief evangelist for Telerik Inc.

24 VISUAL STUDIO MAGAZINE · December 2010 · VisualStudioMagazine.com Untitled-1 1 10/14/10 12:02 PM COVER STORY Silverlight Futures

“Microsoft isn’t a monolith. It’s a big company, accommodating a variety of opinions.” Andrew Brust, CTO, Tallan Inc.

HTML5 Will Replace HTML “There are features of Blend Plug-ins continue to dominate the high end. that I’d like to see in Visual Studio,” says Lhotka. “I think Richer Animation, 3D Pixel Fidelity Across Platforms the minimum bar for an app Content Protection Plug-in is higher than it was, and so Efficient Video Conceptual Pyramids Architectures things like basic animations of All Web Applications (Flash/Silverlight) (Much Larger in 2015) and transitions—we need some way to tap into that Plug-in from inside Visual Studio.” Architectures Lhotka also thinks there’s a (Flash/Silverlight) lot of room for improvement in the Visual Studio XAML Designer. “I have confidence HTML Web HTML/HTML5 Web that we’ll see major improve- Applications Applications ments,” he explains. “What we’ve got is perfectly good, but not great, and I want 2010 2015 Source: IDC something great.”

Coexistence the keynote for the Silverlight Firestarter on Dec. 2, an all-day educa- Brust wouldn’t be surprised to see direct HTML5 support and related tional event that will be streamed live and also available on-demand. tooling in Visual Studio for ASP.NET applications. One area that developers are anxious to hear more about is the “Microsoft isn’t a monolith. It’s a big company, accommodating a roadmap for additional convergence between Silverlight and Windows variety of opinions,” he says. “And I think that variety includes some Presentation Foundation (WPF), which Microsoft promised at diversity of philosophy around .NET versus native code and HTML5 PDC09. “I think that convergence has to take place,” says Brust. versus RIA and client technology like Silverlight and WPF. I think “This, too, involves strategy that’s still evolving. But unification will the two will coexist, as I think they should. The exact configuration come, at some point.” of that coexistence is still evolving, and so are Microsoft’s internal In 2009, Microsoft said that convergence would take two or three opinions on the matter.” releases, recalls Lhotka. “They can’t just break; they’ve established IDC’s Hilwa praises Microsoft for supporting HTML5, which WPF and Silverlight user bases. But you can see it from Silverlight 3 he says is an important transition that will define the Web over and .NET 3.5 to Silverlight 4 and .NET 4—there’s already a substantial the next 10 years. “The fact that we won’t have intense HTML5 convergence between Silverlight and WPF.” is a good thing, and everyone should breathe a sigh Microsoft is continuing to bring some key features of WPF into of relief,” he says. Silverlight. “Microsoft now suggests [you] start by creating a Silverlight “However, HTML5 won’t do a lot of things,” cautions Hilwa, “and application, and then switch to WPF if some features are required, the envelope on what is doable by devices will continue to move because it’s easier to move from Silverlight to WPF than vice-versa,” inexorably higher and in ways that standards will never keep up says Pinsonneault. “In the next version of WPF, it will support with. Plug-ins to browsers will continue to bring these capabilities hosting of Silverlight applications.” to the Web world and also provide synergies with off-browser Lhotka would like to see Microsoft adopt a unified programming application development models. In that sense, I see Silverlight as a model, with a common Silverlight core and desktop, Web and Phone strategic evolution of WPF as applications continue to transform extensions. “WPF hopefully will end up having the Silverlight to Web architectures.” core with lots of extra goodies to make Windows development really Brust advises developers to tell clients the same thing he’s telling a lot of fun,” he says. his Silverlight RIA customers: “Be careful, keep your eye on this Silverlight 4 still lacks key functionality such as client-side storage situation as it develops and resolves itself, and avoid putting too of data—also a hotly debated issue on Silverlight for Windows much stock into any prediction that features hysteria or drama.” Phone—and internal reporting capabilities. Workarounds to build Lhotka agrees. “I look at what happened in the media and the reporting engines such as the rudimentary printing subsystem and twittersphere as a blip,” he says, “because if you step back and look at Office integration (Excel) introduced in Silverlight 4, or browser what’s been going on for the last three years or so, there’s been this integration with SQL Server Reporting Services, are not adequate. steady embrace of Silverlight across all these different platforms and “For most of us, that’s not really what our employers are paying us to things that are really strategic to Microsoft’s overall direction.” VSM do,” says Lhotka. Developers can use Visual Studio 2010 and Expression Blend to Kathleen Richards ([email protected]) is executive editor of Visual build Silverlight applications, but many still find Blend intimidating. Studio Magazine.

26 VISUAL STUDIO MAGAZINE · December 2010 · VisualStudioMagazine.com Untitled-1 1 10/14/10 12:02 PM Content provided by MSDN Magazine, Microsoft’s premier publication for developers.

BY CHARLES PETZOLD

For many Silverlight programmers, the touch event is the entire activity of a finger that first touches the most exciting news about Windows Phone 7 is its screen when no other fingers are in contact with the screen.) Moving from the mouse to multi-touch will require some support for Silverlight as one of its two program- thought: Both Silverlight for the Web and Silverlight for Windows ming interfaces (the other is XNA). Not only can Phone support the static Touch.FrameReported event, but this Silverlight programmers leverage their existing event is a rather low-level interface to multi-touch. I focused on this event in my article “Finger Style: Exploring Multi-Touch Sup- knowledge and skills in writing apps for the phone, port in Silverlight” in the March 2010 issue of MSDN Magazine but they should be able to build Silverlight pro- (msdn.microsoft.com/magazine/ee336026). Silverlight for Windows Phone supports a subset of the Manipula- grams for the Web and the phone that share code. tion events that originated in the Surface SDK and have since become Of course, sharing code—particularly UI code—is rarely as easy part of Windows Presentation Foundation (WPF). It’s an example of as it first seems. The version of Silverlight used in the phone is called how multi-touch is becoming more mainstream in steps. The phone Silverlight for Windows Phone, and it’s mostly a stripped-down supports only the translation and scaling functions, not rotation, implementation of Silverlight 3. When contemplating a shared-code and does not implement inertia, although sufficient information is app, you’ll want to take a close look at the documentation: For each available to implement inertia on your own. These Manipulation Silverlight class, the online documentation indicates which environ- events are not yet supported in the Web version of Silverlight. ments support that class. Within each class, lists of properties, methods In summary, if you want to share code between Silverlight for and events use icons to indicate Windows Phone 7 support. the Web and Silverlight for Windows Phone, you’ll be sticking A Silverlight application for the Web gets user input through the either with mouse events or with Touch.FrameReported. keyboard, mouse and perhaps multi-touch. In a Windows Phone 7 program, multi-touch is the primary means of input. There’s no Consider the Thumb mouse, and while there might be a hardware keyboard on the phone, However, there’s another option: If you need only the translation Silverlight programs can rely only on the existence of a virtual support of the Manipulation events, and you don’t want to worry keyboard—the Software Input Panel, or SIP—and only through about whether the input is coming from the mouse or touch, there the TextBox control. is a control that provides this support in a very pure form. This If your existing Silverlight programs never directly obtain keyboard control is the Thumb. or mouse input and rely entirely on controls, you won’t have to worry It’s possible that you’ve never actually encountered the Thumb. about the conversion to multi-touch. Also, if your programs contain The Thumb control is hidden away in the System.Windows.Con- their own mouse logic, you can actually retain that logic when porting trols.Primitives namespace and is primarily intended for ScrollBar the program to the phone. and Slider templates. But you can also use it for other chores, and I’ve On the phone, primary touch events are converted to mouse recently come to think of the Thumb as a high-level implementation ILLUSTRATION BY RYAN ETTER RYAN BY ILLUSTRATION events, so your existing mouse logic should work fine. (A primary of the translation feature of the Manipulation events.

28 VISUAL STUDIO MAGAZINE · December 2010 · VisualStudioMagazine.com FEATURE

These tools allow you to create Windows Phone 7 projects from Visual Studio. Begin by creating a regular Silverlight 4 project called Drag- Image. The resulting DragImage solution contains the customary DragImage project (which is the Silverlight program itself) and a DragImage.Web project (which hosts the Silverlight program in an HTML or ASP.NET page). Next, add a new project of type Windows Phone Application to the solution. Call this project DragImage.Phone. (It’s likely you won’t want that name showing up in the program list of the phone or the phone emulator, so you can change the display name in the Title attribute of the App tag in the WMAppManifest.xml file.) Figure 1 The Silverlight and Windows Phone 7 thumb controls. By right-clicking either the DragImage.Web project or the DragImage.Phone project, you’ll get a context menu from which Now, the Thumb isn’t a truly “multi”-touch control—it supports you can select Set as StartUp Project and run either the regular only one touch at a time. However, exploring the Thumb in some Silverlight program or the Windows Phone 7 program. A toolbar detail will give you an opportunity to experiment with supporting drop-down in Visual Studio lets you deploy the phone program to touch computing along with sharing code between a Silverlight either an actual phone device or the phone emulator. (Visual Studio application and a Windows Phone 7 application. won’t build the projects if this drop-down is set for Windows The Thumb defines three events: Phone 7 Device and no phone is attached.) ■ DragStarted is fired when the user first touches the control In the DragImage project (the regular Silverlight project), add a with a finger or mouse. new item of type Silverlight User Control. Call it DraggableImage. ■ DragDelta indicates movement of the mouse or finger As usual, Visual Studio creates DraggableImage.xaml and Draggable- relative to the screen. Image.xaml.cs files for this control. Figure 2 shows Draggable- ■ DragCompleted indicates the mouse or finger has lifted. Image.xaml with the visual tree of the control. The standard outer The DragDelta event is accompanied by event arguments with Grid named LayoutRoot will occupy the full dimensions of the con- the properties HorizontalChange and VerticalChange that indicate trol’s container; the inner Grid is aligned at the upper-left corner, but the mouse or finger movement since the last event. You’ll generally there’s a TranslateTransform assigned to its RenderTransform prop- handle this event by adding the incremental changes to the X and Y erty to move it within the outer Grid. This inner Grid holds an Image properties of a Translate Transform set to a RenderTransform prop- element with a Thumb control on top with its Template property set erty of some draggable element, or the Canvas.Left and Canvas.Top to a visual tree containing only a transparent Rectangle. attached properties. Notice that the Source property of the Image element is bound In its default state, the Thumb is rather plain. As with other con- to the Source property of the control itself. That property is defined trols, the HorizontalAlignment and VerticalAlignment properties in the DraggableImage.xaml.cs file shown in Figure 3 (p. 30). That are set to Stretch so the Thumb normally fills the area allowed for file also processes the DragDelta event from the Thumb by changing it. Otherwise, the Silverlight Thumb is just four pixels square. In the X and Y properties of the TranslateTransform. Silverlight for Windows Phone, the Thumb is 48 pixels square, but To share that control with the Windows Phone 7 project, right- visually it’s really just 24 pixels square with a 12-pixel wide trans- click the DragImage.Phone project and select Add | Existing Item parent border on all four sides. At the very least, you’ll probably want to set an explicit Height and Width on the Thumb. Figure 1 shows the Silverlight and Windows Figure 2 DraggableImage.xaml Phone versions side by side, with the default light-on-dark color pays attention to the Foreground property. Very often you’ll want not only to resize the Thumb, but also to Sharing Controls Suppose you want a simple control that lets the user drag bitmaps around the screen. A very easy approach is to put both an Image element and a Thumb in a single-cell Grid, with the Thumb the same size as the Image and overlaying it. If the ControlTemplate for the Thumb is just a transparent Rectangle, the Thumb is invisible but it still fires drag events. Let’s try to create such a control that’s usable in both regular Silverlight and Windows Phone 7 projects. I’ll assume you have the Windows Phone 7 Developer Tools installed (create.msdn.com).

VisualStudioMagazine.com · December 2010 · VISUAL STUDIO MAGAZINE 29 FEATURE Silverlight and Windows Phone 7

That’s probably the simplest way you can share a control between Figure 3 DraggableImage.xaml.cs two Silverlight projects, one for the Web and one for Windows using System.Windows; Phone 7. Because the control uses the Thumb, both programs work using System.Windows.Controls; with the mouse or touch. using System.Windows.Controls.Primitives; The downloadable code for the DragImage solution also includes using System.Windows.Media; a project named DragImage.Wpf, which is a WPF program that also namespace DragImage { uses this control. In the general case, however, sharing controls public partial class DraggableImage : UserControl { between Silverlight and WPF is harder than sharing controls public static readonly DependencyProperty SourceProperty = DependencyProperty.Register("Source", between Silverlight and Windows Phone 7. typeof(ImageSource), typeof(DraggableImage), Color and Resolution new PropertyMetadata(null)); Aside from mouse and touch input, when attempting to share code public DraggableImage() { between Silverlight and Windows Phone 7, you’ll need to deal with InitializeComponent(); two other issues: color and video resolution. } On the desktop, Silverlight displays black text on a white background.

public ImageSource Source { (However, a Silverlight program could use the SystemColors class set { SetValue(SourceProperty, value); } in order to display the Windows colors selected by the user.) By get { return (ImageSource)GetValue(SourceProperty); } default, Windows Phone 7 displays white text on a black background } except if the user changes the color theme to display black on white. void OnThumbDragDelta(object sender, DragDeltaEventArgs args) { Windows Phone 7 provides handy, predefined resource keys, such translate.X += args.HorizontalChange; as PhoneForegroundBrush and PhoneBackgroundBrush, to help a translate.Y += args.VerticalChange; program use the selected color scheme. } } Any code or markup shared between Silverlight and Windows } Phone 7 that uses explicit colors will have to figure out some way to determine the platform on which it’s running to get the correct colors. The video resolution problem is a little trickier. All Silverlight to bring up the Add Existing Item dialog box. Navigate to the coordinates are in units of pixels, and that rule applies to the phone DragImage project directory. Select DraggableImage.xaml and as well. The average desktop video display probably has a resolution DraggableImage.xaml.cs, but don’t click the Add button. Instead, somewhere in the vicinity of 100 dots per inch (DPI). (For example, click the little arrow to the right of the Add button and select suppose a 21-inch video display handles 1600 x 1200 pixels, or Add as Link. The files show up in the DragImage.Phone project 2000 pixels diagonally. That’s a resolution of 105 DPI.) By default, with little arrows on the icons indicating that the files are shared Windows assumes that the display resolution is 96 DPI, although between the two projects. the user can change that to make the screen easier to read. Now you can make changes to the DraggableImage files and A Windows Phone 7 device has a screen that’s 480 x 800 pixels both projects will use the revised versions. with a diagonal of 933 pixels. Yet the screen measures only 3.5 inches To test it out, you’ll need a bitmap. Store the bitmap in an Images diagonally, which means the resolution is about 264 DPI, some directory within each of the projects. (You don’t need to make copies 2.75 times the resolution of the desktop display. of the bitmap; you can add the bitmap to the Images directory using This means that shared elements of a particular size that look fine a link.) on the desktop are going to be too small on the phone. However, the There should be two MainPage.xaml files floating around. One is viewing distance of the phone is usually shorter than for desktop from the regular Silverlight project and the other is from the Windows displays, so the elements don’t have to be increased by a full 2.75 Phone 7 project. In MainPage.xaml for the Silverlight project, add an times to be visible on the phone. XML namespace binding called (traditionally) “local”: How big should the Thumb be for touch purposes? One criterion xmlns:local="clr-namespace:DragImage" I’ve read indicates that touch targets should be 9 millimeters (or 0.25 Now you can add DraggableImage to the page: inches) wide and high. On a desktop display with a resolution of 96 pixels to the inch, that’s 34 pixels—but on the phone it’s 93 pixels. Figure 4 The Thumb Style from TextTransformer.xaml The MainPage class for the Windows Phone 7 project is in a name-

30 VISUAL STUDIO MAGAZINE · December 2010 · VisualStudioMagazine.com DESIGN Design Applications That Help Run the Business

Our xamMap™ control in Silverlight and WPF lets you map out any geospatial data like this airplane seating app to manage your business. Come to infragistics.com to try it today!

Infragistics Sales 800 231 8588 Infragistics Europe Sales +44 (0) 800 298 9055 Infragistics India +91 80 4151 8042 @infragistics

Untitled-6 1 11/10/10 11:41 AM FEATURE Silverlight and Windows Phone 7

for different platforms. It is this approach I used in the TextTrans- form program. I created the TextTransform solution the same way I created the DragImage solution. The solution has three projects: TextTransform (the Silverlight program), TextTransform.Web (the Web project to host the Silverlight program) and TextTrans- form.Phone (for Windows Phone 7). In the Silverlight project, I then created a TextTransformer control that derives from UserControl. This control is shared between the Silverlight project and the Windows Phone 7 project. The Text- Transformer control contains a hardcoded text string (the word “TEXT”) surrounded by a Border with four Thumb controls at the corners. Moving a Thumb causes a non-affine transform to be applied to the Border and TextBlock. (It only works correctly if the quadrilateral formed by the Border has no concave corners.) The TextTransformer.xaml file doesn’t create a new template for the Thumb, but it does define a Style as shown in Figure 4 (p. 30). Figure 5 The TextTransform program in the browser. Notice the references to ThumbSize and HalfThumbOffset. On the other hand, the standard button on a Windows Phone 7 Although the TextBlock displaying the text gets the correct Fore- device is only 72 pixels tall, and that seems adequate. Perhaps the ground property through property inheritance, the Border must best approach is to experiment until you find something that’s easy be explicitly colored with the same foreground color: to use but isn’t too clunky. Traditionally, programs adjusted themselves for different platforms Where are these resources defined? They’re defined in App.xaml. using preprocessor directives for conditional compilation. A Silverlight The regular Silverlight project includes a Resources collection in its program defines the conditional compilation symbol SILVERLIGHT, App.xaml file that contains the following: and a Windows Phone 7 program defines both SILVERLIGHT and PHONE. (You can see these by selecting the Build tab on the project Properties page.) That means you can have code that looks some- thing like this: 36 #if PHONE -18 // Code for Windows Phone 7 #else The App.xaml file for the Windows Phone 7 program references // Code for regular Silverlight the predefined resources for the two brushes and defines larger #endif ThumbSize and HalfThumbOffset values: Or, you can differentiate at run time by accessing the Environ- ment.OSVersion object. If the Platform property is PlatformID.WinCE on a Windows Phone 7 device (or perhaps Windows Phone 8 or 9). files using the AlternateContent and Choice tags defined in the 96 markup-compatibility (mc) namespace, but these tags don’t seem -48 to be supported in Silverlight. But XAML can contain data bindings, and these bindings can Figure 5 shows the program running in the browser and Figure 6 reference different objects depending on the platform. XAML can shows the program running on the Windows Phone 7 emulator. also have StaticResource references that retrieve different objects The emulator is displayed at 50 percent of full size to compensate for the higher pixel density on the phone. These techniques suggest that sharing code between the desktop and phone has become a reality. If you want to delve a bit deeper into this subject, the Surface Toolkit for Windows Touch includes a SurfaceThumb control for WPF developers. This is just like the normal Thumb control, but it adds support for true multi-touch and events for when the thumb is flicked. For more information, see the Surface Toolkit for Windows Touch beta page at msdn.microsoft.com/library/ee957351. VSM

Charles Petzold is a longtime contributing editor to MSDN Magazine. His new book, “Programming Windows Phone 7,” is available as a free download. Figure 6 The TextTransform program on the Windows Phone 7 emulator. CODE DOWNLOAD AT VisualStudioMagazine.com/MultiTouch

32 VISUAL STUDIO MAGAZINE · December 2010 · VisualStudioMagazine.com 2011 Esri Developer Summit

March 7–10 | Palm Springs, CA Esri® Developer Network Register at esri.com/devsummit Integrate Mapping and GIS into Your Applications

Give your users an effective way to visualize and analyze their data so they can make more informed decisions and solve business problems.

By subscribing to the Esri® Developer Network (EDNSM), you have access to the complete Esri geographic information system (GIS) software suite for developing and testing applications on every platform. Whether you’re a desktop, mobile, server, or Web developer, EDN provides the tools you need to quickly and cost-effectively integrate mapping and GIS into your applications.

Subscribe to EDN and leverage the power of GIS to get more from your data. Visit esri.com/edn.

Copyright © 2010 Esri. All rights reserved. Esri, the Esri globe logo, EDN, and esri.com are trademarks, registered trademarks, or service marks of Esri in the United States, the European Community, or certain other jurisdictions. Other companies and products mentioned herein may be trademarks or registered trademarks of their respective trademark owners.

Untitled-1 1 11/3/10 10:49 AM Content provided by MSDN Magazine, Microsoft’s premier publication for developers.

BY SACHA FAUST

Anyone doing ASP.NET development probably Overview admits, openly or not, to introducing or stumbling You can download the ASP.NET security code analysis rules package upon a security issue at some point during their for Visual Studio 2010 and FxCop version 10.0 from go.microsoft.com/ career. Developers are often pressured to deliver ?linkid=9750555. The installation contains three new rules packages: ■ ASP.NET.Security: This category focuses on security best code as quickly as possible, and the complexity of practices related to how System.Web.Ui.Page properties the platform and vast number of configuration are initialized. options can leave the application in a less than ■ ASP.NET.MVC.Security: This category focuses on security desirable security state. In addition, the configura- best practices related to how ASP.NET MVC is used. ■ ASP.NET.Security.Configuration: This category focuses on tion requirements for debugging and production security best practices related to configuration elements are different, which can often introduce debugging under the web.config files. settings in production, causing a variety of issues. Once the rules package is installed, you can start reviewing the security of your Web application automatically by clicking on the Over the years, the ASP.NET platform has matured and better Run Code Analysis on Web Site button under the Build menu. The documentation has been made available through MSDN and com- analysis will review each Page class and web.config file of your munity blogs, but knowing which feature or configuration setting to application against a series of security best practices for ASP.NET. use is often troublesome. Even with good knowledge of the security For example, one widespread security vulnerability in Web appli- functionality, mistakes can happen that could result in security cations is cross-site request forgery, which allows an attacker to vulnerabilities in your application. execute commands as another user. The common mitigation for this Peer code review is a useful process and a good way to catch issues vulnerability is to use the Page.ViewStateUserKey property early. Still, not everyone has the time or budget—or knowledgeable (bit.ly/cTSHM0). You can also employ the AntiForgeryToken in peers at hand—for such review. ASP.NET MVC (bit.ly/ciiQIP). Both techniques prevent a malicious Since the introduction of code analysis in Visual Studio 2005, replay attack on your application. The code analysis will make sure developers have been able to automatically analyze their code to that the appropriate mitigation is being used in your application. see if it complies with a series of best practices ranging from design, A common bit of feedback I’ve heard from developers running maintainability, performance and security. So far, code analysis has code analysis for the first time is the overwhelming number of been a great tool, but it hasn’t focused on providing best security warnings returned (see Figure 1, p. 36). It’s easy to feel like you’re practice guidance for ASP.NET—until now. on your own to figure out how to fix all of them. In this article I’ll introduce you to the new ASP.NET code analysis To eliminate some of the burden of addressing each warning, rules that can be used with analysis as well as each rule includes a clear indication of what must be fixed and how with the standalone FxCop appli cation to improve the security of to fix it, along with some references if you need more information your ASP.NET applications. before applying the change (see Figure 2, p. 36).

34 VISUAL STUDIO MAGAZINE · December 2010 · VisualStudioMagazine.com DEVELOP Rich Business Intelligence Applications in WPF and Silverlight

Robust Pivot Grids for WPF and Silverlight let your users analyze data to make key business decisions. Visit infragistics.com to try it today!

Infragistics Sales 800 231 8588 Infragistics Europe Sales +44 (0) 800 298 9055 Infragistics India +91 80 4151 8042 @infragistics

Untitled-6 1 11/10/10 10:57 AM FEATURE ASP.NET Security

Code analysis can also be configured to run after each build by clicking Website | Configure Code Analysis for Website and then checking the “Enable Code Analysis on Build (defines CODE_ ANALYSIS constant)” option (see Figure 3).

Code Analysis with FxCop The code analysis feature is only available in Visual Studio Premium and Ultimate versions. However, you can also use the standalone FxCop tool to perform ASP.NET code analysis. FxCop is available as part of the Windows SDK. The Windows SDK 7.1 release is available from bit.ly/dzCizq. When using the standard FxCop tool, a little bit more work is required to perform the analysis. I’ll walk you through the steps to get it working. Normally, when you compile your Web project, the page markup—the page code not included in a code-behind file—is not compiled and is left intact in the Web root of your appli- cation. When the first user requests the page, the markup is compiled into separate assemblies. This lets a site be updatable without requiring Figure 1 Violations are listed in the error list warnings tab. everything else to be recompiled. (For details about the ASP.NET page compilation process, see msdn.microsoft.com/library/ms366723.) Because not all code is automatically compiled, some of the code isn’t visible during analysis and important security issues could be missed. To make sure that all code is available during analysis, you need to force the precompilation of all pages. Precompilation can be achieved by using the Publish Web Site tool, which can be started by clicking Build | Public Web Site. The tool allows you to configure how the Web site will be published, and this is where precompilation can be enabled. Simply uncheck the “Allow this precompiled site to be updatable” option and Figure 2 click OK (see Figure 4). This will result in a fully Detailed information in the warnings section. compiled site ready for analysis. Now that you have a fully compiled site, unleash FxCop on it. ASP.NET analysis requires functionality that is only available in the command-line version of FxCop, so open a command prompt and navigate to the FxCop installation. This will most likely be one of the following, depending on whether you’re running a 32- or 64-bit version of Windows: C:\Program Files (x86)\Microsoft FxCop 10.0 C:\Program Files\Microsoft FxCop 10.0 You can run Fxcop cmd.exe from the FxCop folder to start your code analysis. For an ASP.NET Web site, use a command like this: fxcopcmd.exe /file:”H:\MSDN\PrecompiledWeb\ MSDNSampleSite\bin” /rule: AspNetConfigurationSecurityRules.dll /rule:AspNetMvcSecurityRules.dll /rule:ASPNetSecurityRules.dll /aspnet /console Figure 3 Enabling code analysis during build.

36 VISUAL STUDIO MAGAZINE · December 2010 · VisualStudioMagazine.com DynamicPDF…Proven .NET Components for Real-Time PDFs

Easy-to-use Highly efficient Industry leading support Huge feature set 4RYIT&2%%TODAY Layout reports in DynamicPDF Designer with its Visual Studio look and feel. %XPERIENCEOURFULLYFUNCTIONAL NEVEREXPIRINGEVALUATION ANDCOMMUNITYEDITIONS DynamicPDF Generator v6.0 for .NET $YNAMIC0$&3UITEVFOR.%4 s,INEARIZE&AST7EB6IEWs*AVA3CRIPT /UREASY TO USETOOLSINTEGRATEWITH!30.%4 s%NCRYPTION3ECURITYs0$&8 As0$&! AB AND!$/.%4ALLOWINGFORTHEQUICK REAL TIME s#REATE4AGGED0$&Ss)NTERACTIVE&ORM&IELDS GENERATIONOF0$&DOCUMENTSANDREPORTS s/VER2EADY 4O 5SE0AGE%LEMENTS)NCLUDING "AR#ODESAND#HARTINGs$IGITAL3IGNATURES &OREASYMAINTENANCEANDDEPLOYMENT OURMOSTPOPULARTOOLSARENOWAVAILABLE ASABUNDLEDSUITE $YNAMIC0$&-ERGERVFOR.%4 s-ERGEs3TAMPs!PPENDs3PLITs0ASSWORD3ECURITY s&ORM &ILLs/UTLINEAND!NNOTATION0RESERVATION s0LACE 2OTATE 3CALEAND#LIP0AGESs$ECRYPTION

$YNAMIC0$&2EPORT7RITERVFOR.%4 s'5)2EPORT$ESIGNERs%VENT$RIVENs2ECURSIVE3UB 2EPORTS s5SE0$&4EMPLATESs!UTOMATIC0AGINATIONs0LACEHOLDERS s2ECORD3PLITTINGAND%XPANSIONs#OLUMN3UPPORT s&ULL$YNAMIC0$&-ERGERAND'ENERATOR)NTEGRATION

!LSO CHECKOUTOURNEWESTPRODUCT $YNAMIC0$&0RINT-ANAGERFOR.%4.

ceTe Software has been delivering quality software applications and components to our customers for over 10 years. Our DynamicPDF product line has proven our commitment to delivering innovative software components and our ability to respond to the changing needs of software developers. We back our products with a first class support team trained to provide timely, accurate and thorough responses to any support needs.

Untitled-1 1 3/15/10 11:50 AM FEATURE ASP.NET Security

A common bit of feedback I’ve heard from developers running code analysis for the fi rst time is the overwhelming number of warnings returned. It’s easy to feel like you’re on your own to fi gure out how to fi x all of them.

Figure 4 Publishing Web site with precompilation.

Let’s walk through this so you understand the options I’m using. The /file option indicates what assemblies are to be analyzed. In this example, my precompiled site assemblies are under H:\MSDN\ PrecompiledWeb\MSDNSampleSite\bin. The /rule option indicates which rules to use during analysis. For the purpose of this example, I’m only using three ASP.NET security rules: AspNetConfigurationSecurityRules.dll, AspNetMvcSecurity- Rules.dll and ASPNetSecurityRules.dll. The /aspnet option enables ASP.NET analysis, and the /console option directs analysis output to the command window. More information about the Fxcopcmd and its various options can be found at msdn.microsoft.com/library/bb429474(VS.80).

Wrapping Up Making ASP.NET sites more secure can be a difficult task, but the ASP.NET security code analysis rules do a lot of the work for you by identifying some significant threats. As you’ve seen in this article, the process is simple and can be configured to run each time you build, giving you early identification of issues. I recommend deploying the rules to each developer machine and also adding them as part of a Team Foundation Sever or other repository check-in policy. This enables individual developers to verify their code at build time and also enforces the policy so that no code can be checked that doesn’t meet best practices. You can also implement your own custom code analysis rules. If you’re interested in going down this route, there’s some excellent information in a blog post by Duke Kamstra on the Code Analysis Team Blog (bit.ly/blpP38). You can also find a useful walkthrough of the process on Tatham Oddie’s blog (bit.ly/5tFrMw). VSM

Sacha Faust is a developer on the 365 platform team. You can follow Faust at blogs.msdn.com/sfaust. EXPERIENCE Beautiful Data Visualizations That Bring Your Data to Life

Use our Motion Framework™ to see your data over time and give your users new insight into their data. Visit infragistics.com to try it today!

Infragistics Sales 800 231 8588 Infragistics Europe Sales +44 (0) 800 298 9055 Infragistics India +91 80 4151 8042 @infragistics

Copyright 1996-2010 Infragistics, Inc. All rights reserved. Infragistics, the Infragistics logo and NetAdvantage are registered trademarks of Infragistics, Inc. Motion Framework is a trademark of Infragistics, Inc.

Untitled-6 1 11/10/10 10:57 AM BY ANDREW J. BRUST Whither BizTalk?

BizTalk Server is a blockbuster product, but it’s also a sleeper. Its make sense too. In fact, a lineup of Windows Server AppFabric, a value is immense, yet its following is limited. Every so often it new BizTalk Server based on it, and a Windows Azure version of comes into the Microsoft spotlight, and typically it exits shortly BizTalk would parallel nicely the triad of SharePoint Foundation, thereafter. Now, because of Windows Azure and Windows Azure SharePoint Server and SharePoint Online. AppFabric (both in the cloud and on-premises), the BizTalk profi le is At this year’s Microsoft Professional Developers Conference (PDC), rising again. Before it recedes from the foreground, let’s consider the BizTalk “futures” that were discussed came pretty close to this its history and its future. reorganized stack. The notion of a multitenant, cloud-based As BizTalk has progressed through its numerous versions, it has “Integration as a Service” off ering with an on-premises counterpart become more comprehensive, more stable and more results-oriented. was introduced, as was the intention to architect both products with BizTalk Server 2000 and 2002 were COM-based, somewhat buggy Windows Azure AppFabric as the underlying platform. That direction and misunderstood by both the market and Microsoft itself. is logical and intuitive, and the ease of provisioning that the cloud Redmond presented these early releases as Web service developer provides could bring integration functionality to a wider audience. toolkits, when they were in fact much more. But BizTalk Server 2004, the fi rst Microsoft .NET Framework-based version of the Why Does It Matter? product, brought a stable and full-fl edged business-to-business That wider reach is important, both for Microsoft customers and (B2B) data mapping and publish/subscribe integration server. Microsoft itself. Integration is infrastructural and it’s hard to get BizTalk Server 2006 added fi t and fi nish as well as a host of people excited about it. It’s hard to get Microsoft excited about it, too. valuable adapters acquired from iWay Software; the 2006 R2 release BizTalk revenue, though strong, is peanuts compared to Windows brought enhanced electronic data interchange (EDI) capabilities, and Offi ce, and is even small compared to SQL Server and SharePoint. radio-frequency identifi cation (RFID) support and a native adapter But, high revenue or not, a good integration server is important for Windows Communication Foundation (WCF). BizTalk 2009 added to the credibility of the Microsoft stack. You can’t have data, further EDI enhancements and Hyper-V virtualization support. The business intelligence and applications without plumbing, tooling recent 2010 release brings integration with Windows Workfl ow and management features for moving that data between Foundation and the Windows Azure AppFabric Service Bus. If all that applications—and that goes double in the cloud. The on- and were not enough, support for the Health Insurance Portability and off -premises versions of Windows Azure AppFabric provide a good Accountability Act (HIPAA), as well as the BizTalk Accelerator for HL7 skeleton, but for enterprises, Microsoft has to put fl esh on those and BizTalk Accelerator for SWIFT make the product extremely bones. If Microsoft provided only the Windows Azure AppFabric valuable in the health-care and fi nancial services industries. The fundamentals, it would be hard to argue a value proposition over BizTalk story is now extremely cohesive. open source products like Jitterbit and FuseSource. Layering on a product like BizTalk Server, with compelling value Scatter/Gather provided by its adapters, and the BizTalk EDI and RFID features, But Microsoft has muddied the waters. The introduction of the means Redmond can make the argument and win. Microsoft should service-management component of Windows Server AppFabric, be providing more business value than open source, with more code-named “Dublin,” provides an app server that parallels much of compelling economics than other commercial off erings. With the the BizTalk architecture, but lacks the latter’s vast feature set and cloud, maybe BizTalk will morph from the little integration engine manageability. On the cloud side, the Microsoft .NET Service Bus that could to the big one that does. VSM bears some resemblance to the BizTalk message box. Branding-wise, the .NET Service Bus is a component of Windows Azure AppFabric Andrew J. Brust is a Microsoft regional director and MVP, and coauthor of that in its early beta form was actually called BizTalk Services. “Programming Microsoft SQL Server 2008” (Microsoft Press, 2008). A BizTalk is Microsoft’s integration server. Ironically, it needs some frequent speaker at developer industry events, Brust is also cochair of the integration of its own. A future version of BizTalk built atop VSLive! family of conferences and a contributing editor to Visual Studio Windows Server AppFabric would make sense for on-premises work. Magazine. Brust has been a participant in the Microsoft ecosystem for 15 A cloud version of BizTalk, based on a version of Windows Azure years, and has worked closely with both the Microsoft Redmond-based AppFabric more conformed to its on-premises counterpart, would corporate team and its field organization for the last six years.

40 VISUAL STUDIO MAGAZINE · December 2010 · VisualStudioMagazine.com Untitled-14 1 10/7/10 3:47 PM Untitled-1 1 10/4/10 11:54 AM