12.07.2015 Views

net developer's journal sneak peek - sys-con.com's archive of ...

net developer's journal sneak peek - sys-con.com's archive of ...

net developer's journal sneak peek - sys-con.com's archive of ...

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

.NET DEVELOPER’S JOURNAL SNEAK PEEKTMdot<strong>net</strong>developers<strong>journal</strong>.comPreview Issue • October2002FROM THE EDITORWelcome to a Truly IndependentVoice in the World <strong>of</strong> .NETby Derek Ferguson pg. 5BOOK REVIEWSSams Teach Yourself ASP.NETin 21 Days, Se<strong>con</strong>d EditionVisual Basic .NET and the .NETPlatform: An Advanced Guidereviewed by Derek Ferguson pg. 26PREMIERINGIN JANUARY 2003SUBSCRIBENOWdot<strong>net</strong>developers<strong>journal</strong>.com.NETDJ Interview: The Present and Future Derek Ferguson<strong>of</strong> .NET An interview with Micros<strong>of</strong>t’s David Treadwell 6.NET Security: Tamper-Pro<strong>of</strong>ing Your Assembly Kevin H<strong>of</strong>fmanUsing Code Access Security to foil unauthorized users 10Feature: All Data, All the Time...Bob BeaucheminAn introduction to .NET data access and SQLXML Web services 16COMING IN THE PREMIER ISSUE:VS.NET: Customizing the PictureBox ControlPreserving the aspect ratio <strong>of</strong> an imageMigration: Avoid Common Pitfalls That Foil.NET Migration The process is rarely without incidentSecurity First: Inter<strong>net</strong> Information Server 6IIS 6 can help developers get a better night’s sleepMigration: Migrate Your COM Applicationsto .NET Harness .NET’s interoperability featuresErik BrownMatthew MacDonaldKent TegelsBrian Noyes


infragisticswww.infragistics.com2Preview Issue • dot<strong>net</strong>developers<strong>journal</strong>.com


infragisticswww.infragistics.comdot<strong>net</strong>developers<strong>journal</strong>.com • Preview Issue3


EditorialEDITORIALEditor-in-ChiefDerek Ferguson derek@<strong>sys</strong>-<strong>con</strong>.comEditorial BoardGary Cornell gary@thecornells.comPeter Drayton peter@razors<strong>of</strong>t.comKeith Franklin ka_franklin@empowered.comDean Guida deang@infragistics.comEditorial DirectorJeremy Geelan jeremy@<strong>sys</strong>-<strong>con</strong>.comExecutive EditorGail Schultz gail@<strong>sys</strong>-<strong>con</strong>.comManaging EditorJean Cassidy jean@<strong>sys</strong>-<strong>con</strong>.comEditorsM’lou Pinkham mpinkham@<strong>sys</strong>-<strong>con</strong>.comNancy Valentine nancy@<strong>sys</strong>-<strong>con</strong>.comAssociate EditorsJamie Matusow jamie@<strong>sys</strong>-<strong>con</strong>.comCheryl Van Sise cheryl@<strong>sys</strong>-<strong>con</strong>.comAssistant EditorJennifer Stilley jennifer@<strong>sys</strong>-<strong>con</strong>.comOnline EditorLin Goetz lin@<strong>sys</strong>-<strong>con</strong>.comWRITERS IN THIS ISSUEBob Beauchemin, Derek Ferguson, Christian Forsberg,Kevin H<strong>of</strong>fman, Andreas SjöströmSUBSCRIPTIONSFor Subscriptions And Requests For Bulk Orders,Please Send Your Letters To Subscription DepartmentSubscription Hotline: subscribe@<strong>sys</strong>-<strong>con</strong>.comCover Price: $6.99/issueDomestic: $69.99/yr. (12 Issues)Canada/Mexico: $99.99/yr. Overseas: $129.99/yr.(U.S. Banks Or Money Orders). Back Issues: $12/ea.,plus shipping and handling.EDITORIAL OFFICESSYS-CON Media 135 Chestnut Ridge Rd.,Montvale, NJ 07645Telephone: 201 802-3000 Fax: 201 782-9600.Net Developer’s Journal (ISSN#1541-2849) IsPublished Monthly(12 Times A Year) For $69.99 BySYS-CON Publications, Inc.,135 Chestnut Ridge Road, Montvale, NJ 07645.Periodicals Postage Rates Are Paid AtMontvale, NJ 07645 And Additional Mailing Offices.Postmaster: Send Address Changes To:.NET Developer’s Journal,SYS-CON Publications, Inc.,135 Chestnut Ridge RoadMontvale, NJ 07645.Copyright © 2002 By SYS-CON Publications, Inc.All Rights Reserved.No Part Of This Publication May Be Reproduced OrTransmitted In Any Form Or By Any Means, Electronic OrMechanical, Including Photocopy Or Any InformationStorage And Retrieval System, Without Written Permission.For Promotional Reprints, Contact Reprint CoordinatorCarrie Gebert, Carrieg@<strong>sys</strong>-<strong>con</strong>.com.All brand and product names used on these pages aretrade names, service marks, or trademarks <strong>of</strong> theirrespective companies. SYS-CON Publications, Inc., is notaffiliated with the companies or products covered in .NETDeveloper’s Journal.SYS-CON Publications, Inc., Reserves The Right To Revise,Republish And Authorize Its Readers ToUse The Articles Submitted ForPublication.dot<strong>net</strong>developers<strong>journal</strong>.com • Preview IssueWelcome to a Truly IndependentVoice in the World <strong>of</strong> .NETwelcome to the first issue <strong>of</strong>SYS-CON Media’s new.NET Developers Journal.We’ve started this magazinebecause we’re excited about .NET.We’re excited about Visual Studio.NET’s ability to bring the power <strong>of</strong>drag-and-drop, GUI-based developmentto even the most complicatedkinds <strong>of</strong> development. We’re excitedabout the .NET Framework’s potentialfor radically decreasing theamount <strong>of</strong> custom code developersmust write. Finally, perhaps most <strong>of</strong>all, we’re excited about .NET’s potentialto become the industry’s platform<strong>of</strong> choice for XML Web servicesdevelopment – not just on Windows,but on all manner <strong>of</strong> devices andoperating <strong>sys</strong>tems.As editor-in-chief, I want to maketwo promises to you regarding our<strong>con</strong>tent.The first is that we’ll always be atruly independent voice on .NET technologies.We’ll give you the whole story:the good, the bad, and the ugly…regardless<strong>of</strong> the players involved. Myse<strong>con</strong>d promise is that we’ll alwaysserve up technically in-depth <strong>con</strong>tent.Developers don’t need another publicationthat’s long on opinions and shorton code. We aim to bring you the indepthinformation you need to succeedas a .NET developer.Meet the TeamTo help us deliver on thesepromises, we’ve rounded up some <strong>of</strong>the best people in the industry forour editorial advisory board and to beour regular columnists. Industry leaderssuch as Gary Cornell from Apress,Peter Drayton from DevelopMentor,Dean Guida from Infragistics, andKeith Franklin from EmpoweredS<strong>of</strong>tware Solutions have alreadyjoined our editorial board.Meanwhile, for columnists, we’vealready gathered together suchrespected names as ChristianForsberg and Bob Beauchemin – withmore <strong>of</strong> similar caliber soon to follow!Love at First SightAs for myself, I had the honor to beone <strong>of</strong> the first to see a <strong>sneak</strong> preview<strong>of</strong> .NET nearly three years ago atMicros<strong>of</strong>t’s corporate headquarters –before they’d even decided to call it.NET. But even then, with flaky technicalpreview code, it was love at firstsight! Even then it was easy to see howthe tools that now make up the .NETplatform were going to vastly improvedevelopers’ lives – particularly those <strong>of</strong>us who were wrestling with the difficulties<strong>of</strong> COM programming on aday-to-day basis.When I’m not editing this <strong>journal</strong>,I work as CTE for Expand BeyondCorporation, makers <strong>of</strong> wirelessenterprise management s<strong>of</strong>twareproducts such as PocketDBA andPocketAdmin. For this reason, I havea particularly keen interest in themobile aspects <strong>of</strong> .NET technology.Last year, I even wrote a book forApress called Mobile .NET.Getting AroundWhether you’re doing mobilecomputing or more traditional desktopand Web-based development,you’re sure to find plenty <strong>of</strong> interestin every new issue <strong>of</strong> .NETDeveloper’s Journal. To this end,we’ve divided it into four main sections:“Home” is where you’ll find bookreviews, news items, and editorials. In“Desktop,” GDI+, Visual Studio .NETtips and tricks, and general languagediscussions are just some <strong>of</strong> the manytopics. In our “Server” section, technologiessuch as ASP.NET, ServicedComponents, and other enterprisecomputingtopics will be given thespotlight. Last, but not least, “Everywhere”covers such cutting-edge topicsas mobile computing, .NET on otherplatforms, and Web services.Finally, as you read this or futureissues, please feel free to send whatevercomments, complaints, or suggestionsdirectly to me at derek@<strong>sys</strong><strong>con</strong>.com.Happy coding!BY DEREK FERGUSONDerek Ferguson is editor-in-chief <strong>of</strong>.NET Developer’s Journal and arenowned author, speaker, anddeveloper. His list <strong>of</strong> booksauthored includes Mobile.NET,Debugging ASP, MCSD SolutionArchitectures, and BroadbandInter<strong>net</strong> Access for Dummies.Derek serves as chief technologyevangelist for Expand BeyondCorp., a leading provider <strong>of</strong> wirelessenterprise management s<strong>of</strong>tware.derek@<strong>sys</strong>-<strong>con</strong>.comDESKTOPSERVEREVERYWHERE5HOME


.NETDJ InterviewThe Present and Future <strong>of</strong> .NETAn interview withMicros<strong>of</strong>t’s David TreadwellHOMEINTERVIEWED BYDEREK FERGUSON,EDITOR-IN-CHIEFOF .NETDJDESKTOPSERVEREVERYWHERE.NETDJ: What can you share withus about the current state <strong>of</strong> developingand licensing the .NETCompact Framework?DT: It’s currently in beta, and peoplewho are interested can downloadit from our device developersite: http://msdn.micros<strong>of</strong>t.com/vstudio/device/default.asp. Thereare currently more than 10,000developers in our beta program givingus feedback and building coolapplications..NETDJ: What do you think will bethe “killer app” for mobile .NETcomputing?DT: We’ve seen lots <strong>of</strong> creativedevelopment going on using locationservices and integration withservice providers using XML Webservices. I’ve also seen solutionsthat have provided immediate solutionsto some <strong>of</strong> today’s problems.For example, one early adopterupgraded a manual paper-orderingprocess using Pocket PCs, the .NETCompact Framework, and XML Webservices. Now they punch in orderselectronically, and the orders getprocessed in minutes rather thanhours. This has resulted in big savingsin operational costs. But really,that’s just scratching the surface <strong>of</strong>what’s possible. Ultimately, it’sdevelopers who will come up withthe next big killer app, not us. Myteam’s job is to give developers thetools to write the killer app..NETDJ: What will be the biggestchallenge in making .NET succeed,and how will Micros<strong>of</strong>t overcome it?DT: So far, I’d actually say thatwe’ve been incredibly successful –we have hundreds <strong>of</strong> case studiesreaching into the Fortune 100, millions<strong>of</strong> developers using the .NETFramework and Visual Studio .NET,hundreds <strong>of</strong> books, and an incrediblyactive developer community.Getting that kind <strong>of</strong> momentum wasour first challenge. Our next challengeis getting people other thandevelopers to understand what.NET is and why it’s important.Developers know what it means tothem – an elegant framework andtoolset for writing applications andXML Web services – but we’ve beenvague in our use <strong>of</strong> .NET for enterprisecustomers and end users.Going forward, you’ll see us introducingclear guidelines – focusedon end users and enterprises –about what .NET is and why it’sgood..NETDJ: What can you tell us aboutnew features in the next release <strong>of</strong>the .NET Framework?DT: You can find out a lot athttp://msdn.micros<strong>of</strong>t.com/vstudio/productinfo/roadmap.asp. As you’llsee there, this next release isfocused on dependability. For us,the higher order bit is making theAPIs as stable, secure, and reliableas they can be. If I had to call outone especially cool feature, it’s theintegration between IIS 6 andASP.NET in Windows .NET Server,most notably between IIS 6 andASP.NET. Of course, the rollout <strong>of</strong>the .NET Compact Framework willalso be a major “feature” as well..NETDJ: Do you think Micros<strong>of</strong>tdeserves any <strong>of</strong> the media hypeabout alleged poor security – or is itall just a question <strong>of</strong> averages? Or isit something else altogether?DT: Security is a shared responsibility– Micros<strong>of</strong>t, our customers, ourbroader community, and even thepress need to participate actively. Atthe core <strong>of</strong> it, Micros<strong>of</strong>t must delivera secure stack and a great securitymodel that make it easy for developersto design and write rock-solidapplications. When we set out tobuild the .NET Framework over fouryears ago, that was our top priority.We were able to deliver on this commitmentwith features like evidencebasedsecurity, role-based security,and new <strong>con</strong>cepts in authenticationand authorization, and isolated storage.Delivering a great implementationis just a small part, however.Micros<strong>of</strong>t is making a huge investmentto ensure that we’re evangelizingbest practices for security codingto developers. We’ve introducedTrustworthy Computing sessions toall our developer <strong>con</strong>ferences, we’rerolling out books and prescriptivearchitectural guidance documents,updating our Web sites, and generallymaking a huge investment ineducation and evangelism aroundsecurity..NETDJ: How tightly integrated will.NET be with future versions <strong>of</strong>Windows? Is this at all a <strong>con</strong>cern, incase anyone would ever want itunbundled for some reason?DT: Micros<strong>of</strong>t’s strategic directionfor developers is toward managed6Preview Issue • dot<strong>net</strong>developers<strong>journal</strong>.com


code – the kind <strong>of</strong> code developerswrite on the .NET Framework. Bydefault, every product we ship goingforward will have a managed-codecomponent. At the heart <strong>of</strong> this isWindows: we are the Windows company.We believe in an integratedplatform that provides programmabilityand application services as acore part <strong>of</strong> the OS, and our customerslove that the plumbing isthere and just works for them – noassembly required. Including the.NET Framework as a core feature <strong>of</strong>Windows .NET Server and all otherfuture versions <strong>of</strong> Windows is agreat example <strong>of</strong> how we’re producingthis integrated platform..NETDJ: What is your favorite .NETlanguage and why?DT: Ah, that’s always a hard one toanswer, since the answer dependsso much on what you want to develop!Five or so years ago, when I wasdoing lots <strong>of</strong> hard-core development,I probably would have picked.NETDJ: Given the ease and power<strong>of</strong> ASP.NET, why isn’t everyoneusing it to build their Web sitestoday?DT: They are! Our research showsthat developers are incredibly excitedabout ASP.NET and are buildingASP.NET applications at an amazingrate. There have been over 100,000downloads <strong>of</strong> our ASP.NET WebMatrix Project development tool(www.asp.<strong>net</strong>), and our ASP.NET discussiongroups get posts from thousands<strong>of</strong> unique developers each day.I haven’t met a developer yet thathasn’t raved about the improvementsover traditional ASP when they’veused ASP.NET. When Web developersgive it a shot, they fall in love with it..NETDJ: As Micros<strong>of</strong>t allows .NETto be integrated with an increasinglydiverse set <strong>of</strong> technologies, how willyou avoid lending additional supportto competing products (for example,Apache versus IIS)?DT: For us, it’s not an issue <strong>of</strong>avoiding; it’s about partnering withother vendors to ensure that thecustomer gets the best possibleexperience. Micros<strong>of</strong>t has alwaysworked closely with our competitors– companies like Oracle and IBMare some <strong>of</strong> our best customers andwe help them build great productson Windows. We will talk with anyonewho wants to make investmentsin .NET, and the reality <strong>of</strong> the timesis that that means having to workenabling them to be more efficient.This gives .NET developers over100,000 components at their fingertipsto seamlessly plug into theirapplications. That’s a clear indicationthat we won’t be stepping ontheir toes – we actually work closelywith them to broaden and extendthe capabilities <strong>of</strong> .NET development.Ultimately, it enables developersto have a broader and more universaldevelopment experience..NETDJ: Which is more important toMicros<strong>of</strong>t: winning the OS market orthe Web services market?DT: XML Web services is a set <strong>of</strong>technologies to integrate applications.Without an implementation <strong>of</strong>XML Web services – that is, somes<strong>of</strong>tware that speaks these commonprotocols – there’s nothing to talkabout. Our implementation – the.NET Framework – is a feature <strong>of</strong>Windows. So, by definition, implementingyour XML Web service with.NET is a Windows win.“We said we’d agree on standards andcompete on implementation. We’vepoured lots <strong>of</strong> blood, sweat, and tearsinto making our implementation rock”C# or C++ for their power and flexibility.However, these days I’m notdoing as much development myself,so I usually fire up VB.NET when Ineed to do some coding, as it’s theeasiest way to get <strong>of</strong>f the groundand write cool applications quickly.dot<strong>net</strong>developers<strong>journal</strong>.com • Preview Issuewith companies who also supportcompeting products..NETDJ: As Micros<strong>of</strong>t <strong>con</strong>tinues toadd functionality to .NET, how willyou avoid stepping on the toes <strong>of</strong>your third-party component vendors?DT: We have partners integratingtools, languages, and <strong>con</strong>trolsdirectly within the Visual Studio .NETIDE. We have enterprise customersintegrating their in-house tools andonline communities within the IDEusing the Visual Studio .NETIntegration SDK. And we also havecomponent vendors building theircomponents on the .NETFramework, which extends their<strong>of</strong>ferings to .NET developers,.NETDJ: Are you at all surprised bySun’s slowness and resistance toWeb services – given their obviousbenefits, even to Sun?DT: Not really. I don’t think Sun recognizedthe power <strong>of</strong> applicationlayer integration, and they definitelyviewed XML Web services as a threatto Java, but we’re happy they finallycame around. More industry heavyweightssupporting XML Web servicesequals more ubiquitous technology,which ultimately equals adrastically improved developmentexperience..NETDJ: Given that VS.NET lets youcreate Web services in minutes, whyisn’t everyone building Web servicestoday?7


.NETDJ InterviewDT: You might be surprised. IBMhas said that 80% <strong>of</strong> their new <strong>con</strong>sultingwork is around XML Webservices. We’re seeing similar patternsin our own work with customers.So our customers are buildingWeb services today, and wehave lots <strong>of</strong> case studies to demonstratethat. Today, our customers aremostly integrating <strong>sys</strong>tems behindtheir firewalls, making legacy codeand <strong>sys</strong>tems work side by side withnew projects. We expect this integrationto take place outside thefirewall in a B2B scenario in the nearfuture, and in a B2C scenario in thenext 12-18 months.own port <strong>of</strong> the CLI to FreeBSD –the Shared Source CLI. We createdand delivered over a million lines <strong>of</strong>code that developers can downloadfor noncommercial uses free <strong>of</strong>charge on FreeBSD and WindowsXP. Regarding Mono specifically,we’re really happy to see that Miguel[de Icaza] is also finding the platformtechnologies to be compelling anduseful. They are a <strong>con</strong>crete example<strong>of</strong> people building on the ECMAstandards process..NETDJ: Does Micros<strong>of</strong>t feel thatWeb services must remain rootedin XML in order to succeed?such as Web services, which shouldideally run well on very limiteddevices and platforms?DT: That’s a fairly common criticism <strong>of</strong>XML, but look at how other technologiesthat emphasize interoperabilityand scale over absolute performancehave fared over the years. A greatexample is TCP/IP. In the late 1980sand early 1990s, there was a lot <strong>of</strong>debate in the industry about whetherTCP/IP would ever be ubiquitous, sinceit was much “fatter” than other <strong>net</strong>worktransport protocols like NetBEUI andXNS. Some people claimed thatTCP/IP would never run well on PCssince it was so heavyweight relative to“I haven’t met a developer yet thathasn’t raved about the improvementsover traditional ASP when they’veused ASP.NET”HOMEDESKTOPSERVEREVERYWHERE.NETDJ: Since Web services are, bydefinition, platform independent –why choose Micros<strong>of</strong>t?DT: Time to market, cost, performance,and standards compliance.We have the best platform andtools, making it easy to build applicationsthat expose and <strong>con</strong>sumeXML Web services. We <strong>of</strong>fer integralsupport for the entire stack <strong>of</strong> XMLWeb services standards – XML,SOAP, WSDL, and UDDI – and apowerful, familiar programming environmentthat most developersalready know. We <strong>of</strong>fer developmentin over 20 popular programming languages.We’ve got high-performanceaccess to SQL Server andOracle databases. The list goes onand on. But overall, we said we’dagree on standards and compete onimplementation. We’ve poured lots<strong>of</strong> blood, sweat, and tears into makingour implementation rock..NETDJ: What is Micros<strong>of</strong>t’s positionon Mono and other non-FreeBSDattempts to port .NET to other platforms?DT: Of course, we’re partial to ourWhat about other, non-XMLbased approaches to Web servicesthat are currently gainingmomentum?DT: Web services are about <strong>con</strong>necting.IBM, Micros<strong>of</strong>t, and otherindustry leaders have pushed XMLas the base technology to build onbecause <strong>of</strong> its ubiquity, flexibility,and power. The openness and ubiquity<strong>of</strong> XML are key to the <strong>con</strong>nectivityvision <strong>of</strong> Web services, and allthe major s<strong>of</strong>tware vendors haveinvested a lot <strong>of</strong> time and money intrying to add XML to their applicationserver <strong>of</strong>ferings. Otherapproaches – binary protocols, orprotocols that perform simple operations– have been tried and havefailed to deliver on global-scale,multiplatform integration. XML is notonly a viable approach, it’s the onlyapproach based on current technologythat can deliver..NETDJ: So, what would be yourresponse to critics who say thatXML is far too bandwidth and processingintensive to form a foundationfor interoperability technologiesthe other protocols. The fact is that itneeded that extra heft in order toachieve its primary goals, and the enormousforces caused by Moore’s Lawand the Inter<strong>net</strong> simply overwhelmedany marginal performance advantagethat the other transports had. I expectthat the same thing will happen withXML and Web services: the interoperabilitywill prove so compelling that anydownsides are swept away as theindustry works hard to apply the power<strong>of</strong> Web services to a broad array <strong>of</strong>devices.David Treadwell is the generalmanager for Micros<strong>of</strong>t's .NETDeveloper Platform team, part <strong>of</strong>the Developer Division. The team isresponsible for the .NETFramework and CommonLanguage Runtime (CLR), the coreruntime platform <strong>of</strong> .NET; the .NET Compact Framework,which brings the platform to small devices; and theMicros<strong>of</strong>t Shared Source Common Language Infrastructure(CLI), which makes the platform, including underlyingsource, available on several operating <strong>sys</strong>tem platforms.David played an important role in the establishment <strong>of</strong>Micros<strong>of</strong>t’s .NET strategy for developers. David holds aBSE in electrical engineering from Princeton University.8Preview Issue • dot<strong>net</strong>developers<strong>journal</strong>.com


.NETQuestions?Sams Publishing is dedicated to craftingquality books on Micros<strong>of</strong>t technologiesby partnering with the best minds andgreatest teachers.Visit www.samspublishing.com fordiscounts on these and other booksfrom Sams.For all <strong>of</strong> your technology questions,Sams has the answers.Sams Teach Yourself ASP.NETin 21 Days, Se<strong>con</strong>d Editionby Chris Payne ISBN: 0-672-32445-8 ISBN: 0-672-32068-1 ISBN: 0-672-32232-3ALSO AVAILABLE:Micros<strong>of</strong>t .NET XML Web ServicesISBN: 0-672-32088-6XML and Web Services UnleashedISBN: 0-672-32341-9Sams Teach Yourself C# in 21 DaysISBN: 0-672-32071-1C# UnleashedISBN: 0-672-32122-XProgramming Data-Driven WebApplications with ASP.NETISBN: 0-672-32106-8.NET and COM: The CompleteInteroperability GuideISBN: 0-672-32170-X.NET Common Language RuntimeUnleashedISBN: 0-672-32124-6Database Programming with Visual Basic.NET and ADO.NET: Tips, Tutorialsand CodeISBN: 0-672-32247-1ISBN: 0-672-32421-0ISBN: 0-672-32143-2ISBN: 0-672-32476-8ISBN: 0-672-32234-Xwww.samspublishing.com


.NET SecurityTamper-Pro<strong>of</strong>ing Your AssemblyUsing Code Access Securityto foil unauthorized usersDESKTOPBY KEVIN HOFFMANHOMESERVEREVERYWHEREby now you’ve probablyalready created your first“Hello World” applicationusing one <strong>of</strong> the languagesin the .NET Framework suchas C# or VB.NET – or perhaps you’veeven managed VC++. The .NETFramework allows all kinds <strong>of</strong> differentlanguages to utilize code writtenin various other languages and byother vendors. But there’s a downside:how do you make sure yourcode isn’t used by unauthorizedclients?There’s been an enormousamount <strong>of</strong> marketing and publicitysurrounding the .NET Frameworkand all the wonderful things it cando for you. If you browse the Web atall, you simply can’t escape theonslaught <strong>of</strong> advertising and marketingrelated to how XML Web serviceswill change the future <strong>of</strong> programmingand the future <strong>of</strong> the Web.One <strong>of</strong> the features that Micros<strong>of</strong>tuses as a selling point for theiradventurous new framework is the<strong>con</strong>cept <strong>of</strong> Code Access Security(CAS). Every piece <strong>of</strong> code executedby the Common Language Runtime(CLR) runs within a security <strong>con</strong>text.Such code is granted permissionsbased on various identifying factorsthat are also the elements that <strong>con</strong>tributeto the strong name <strong>of</strong> anassembly. They are:• Filename: The filename <strong>of</strong> theassembly itself (such as My-Assembly.DLL or MyProgram.EXE)• Culture: The target culture <strong>of</strong> theassembly (such as en, fr, or fr-CA)• Version: The version number <strong>of</strong>the assembly• Public Key: A key that’s assignedto your assembly when you buildit against an RSA signature fileIt is the last <strong>of</strong> these, the publickey, that we’ll focus on in this article.Keeping OutUnauthorized UsersAdministrators can execute asecurity policy that grants orrevokes permissions at various levelsthroughout the enterprise toassemblies based on any <strong>of</strong> theabove identifying characteristics.This allows an administrator to preventa given assembly from <strong>con</strong>tactinghosts on the Inter<strong>net</strong> or fromdeleting files from the local harddrive.It’s fine that administrators can<strong>con</strong>trol what code is allowed to do –and what it’s not allowed to do – ontheir own machines. But problemsarise when the developers and theadministrators have a <strong>con</strong>flict <strong>of</strong>interest.Take the following scenario:you’re the publisher <strong>of</strong> some s<strong>of</strong>twarethat reads and writes its datain an encrypted, proprietary format.This is advantageous to you becauseonly your s<strong>of</strong>tware can read andwrite this data. Now, along comes.NET and you <strong>con</strong>vert your s<strong>of</strong>twareto .NET and distribute it. Let’s sayyou have a class library that managesall <strong>of</strong> the I/O with regard toyour proprietary file type. Well, withcommand-line utilities likeILDASM.EXE and programmatictools using Reflection, anyone cansimply examine the metadata forthat assembly and get a detaileddescription <strong>of</strong> all methods and theirarguments. It would take a programmeronly a few minutes todetermine how to use your assemblyto manipulate your proprietaryfiles.Obviously, you don’t want this tohappen. There are countless otherscenarios in which companies needto protect their own interests bypreventing their APIs and classesfrom being executed by unauthorizedusers.Strong-Naming an AssemblyIt might look bad, but you dohave an option. Earlier, we mentionedthat you can strong-name anassembly by signing it with an RSAsignature file. This creates apublic/private key pair and storesthat pair in a file. All assemblies builtusing this signature file will exposethe same public key, which allowsthem to be identified as coming fromthe same publisher. No one can producean assembly with the samepublic key unless they manage to getaccess to your RSA signature file.To create this RSA signature file,open up a command prompt(preferably the one Visual Studio.NET provides, which automatically<strong>con</strong>figures your path settings) andtype the following:SN –k SecureProducts.snkFor our examples, we’re going towork with a fictitious companycalled Secure Products, Inc. Theyproduce APIs they want to restrictso only code written by SecureProducts, Inc., can use them.I mentioned earlier that signingall your assemblies with the samesignature file effectively marks themas having come from the same publisher.Let’s create a sample assemblyand sign it with the SecureProducts.snkfile.To do this, open up Visual Studio.NET and create a new Class Libraryproject (in C#). Call the projectSecureAssembly and leave thedefault namespace and filenamealone. Then open up theAssemblyInfo.cs, set the version10Preview Issue • dot<strong>net</strong>developers<strong>journal</strong>.com


Write faster codeControl revisionsModelDeployAutomate the mundaneSimplifyWrite code fasterGet a lifebe liberatedBeing among the first Micros<strong>of</strong>t ® .NET developers may be exciting. But wasting time is not. That’s where we come in. We’vespent six years working with Micros<strong>of</strong>t, and we’ve developed a new solution for .NET that lets you work completely inside theVisual Studio ® .NET shell. Want everything from modeling to code analysis right at your fingertips? Done. Want your modelautomatically updated when you write code and vice versa? Done. Want to get rid <strong>of</strong> alt/tab and static void Main ()? Done.Want to try out the products that can make you the best .NET developer on the pla<strong>net</strong>? Go to www.rational.com/<strong>of</strong>fer/dot<strong>net</strong>13. Done.Rational, the Rational logo, among others, are trademarks or registered trademarks <strong>of</strong> Rational S<strong>of</strong>tware Corporation in the United States and/or in other countries. Micros<strong>of</strong>t and Visual Studio aretrademarks or registered trademarks <strong>of</strong> Micros<strong>of</strong>t Corporation. All other names are used for identification purposes only and are trademarks or registered trademarks <strong>of</strong> their respective companies.ALL RIGHTS RESERVED. ©2001 Rational S<strong>of</strong>tware Corporation.


.NET SecurityDESKTOPf 1f 2 FigureFigure 1: Permission failed!2: Success!HOMESERVEREVERYWHEREnumber to 1.0.0.0, and modify theAssemblyKeyFile attribute to pointto the file we created.You should end up with twoattribute lines that look like this:[assembly:AssemblyVersion("1.0.0.0")][assembly:AssemblyKeyFile(@"..\..\SecureProducts.snk")]This gives the linker enoughinformation to properly strongnameyour assembly. Make sure youcopy the SecureProducts.snk file tothe root directory <strong>of</strong> the Secure-Assembly project; otherwise,VS.NET won’t compile it.Now we have an assembly that’sstrongly named and, theoretically,digitally signed as having comefrom Secure Products, Inc. Let’sremove the default Class1.cs classand add our own. We’ll call itSecuredClass.Add a method to SecuredClasscalled GetTopSecretInformation(not very original, but it’ll do for ourpurposes). Here’s the code for thatmethod:public class SecuredClass{public SecuredClass(){}public stringGetTopSecretInformation(){return "The neon blue eagle "+"flies at dawn.The turtle has landed.";}}We don’t want the<strong>con</strong>tents <strong>of</strong> this string t<strong>of</strong>all into enemy hands.Therefore, we need touse a feature <strong>of</strong> CAS todemand that only codewith the public keybelonging to SecureProducts, Inc., caninstantiate this class oruse it in any way.To do this, we need toobtain the full public keyfor Secure Products, Inc.In order to do that, we’lluse another commandlineutility called secutil.This allows us to extractsecurity information fromalready compiled assemblies.Get your commandprompt, go to theSecureAssembly\obj\debug directory, and typethe following:Secutil –hex –strongnameSecureAssembly.dll> secutiloutput.txtThis will create a text file thatlooks a little like this:Micros<strong>of</strong>t (R) .NET FrameworkSecUtil 1.0.3512.0Copyright (C) Micros<strong>of</strong>tCorporation 1998-2001. All rightsreserved.Public Key =0x0024000004800000940000000602000000240000525341310004000001000100EB8C810B9B24A636F7FFCA28693AB03DA926839C0FCC5C2B4F0A94CE0C94EB9690F519AC71AAC3C38F9AADAD460DEC33BFD8678B8199322BDC586F757339E6CE88DDED22B03466F8AB2205C75E8406A0F40C33F7FC11F06C73A43C95B21DD9E9ABD27C5B9946054233FF5C6B37D89690696CCDB41D7E74F8B59E66FB5EA1059EName =SecureAssemblyVersion =1.0.0.0SuccessNow we’re going to highlight theentire public key hex string (exceptthe prefix <strong>of</strong> 0x, which is redundantsince we know the string is in hex)and copy it to the clipboard.Then, we’ll use the public key wecopied to place the following attributeat the top <strong>of</strong> our SecuredClassclass definition, as follows:[StrongNameIdentityPermission(SecurityAction.LinkDemand,PublicKey="00240000048000009400000006020000002400005"+"25341310004000001000100EB8C810B9B24A636F7FFCA28693"+"AB03DA926839C0FCC5C2B4F0A94CE0C94EB9690F519AC71AAC"+"3C38F9AADAD460DEC33BFD8678B8199322BDC586F757339E6C"+"E88DDED22B03466F8AB2205C75E8406A0F40C33F7FC11F06C7"+"3A43C95B21DD9E9ABD27C5B9946054233FF5C6B37D89690696"+"CCDB41D7E74F8B59E66FB5EA1059E")]public class SecuredClassWhat we’re doing here is informingthe CLR that any attempt toaccess this class (both static andobject instances) must have thepublic key we specify (hence theLinkDemand enumeration value).If not, the CLR will throw an exception.There’s no way to create anassembly that has this public keywithout possessing the private keybelonging to it – and that resides inour SecureProducts.snk file. Therefore,keep your signature files secure.Security TestNow, to prove my point and tomake sure this is more than just12Preview Issue • dot<strong>net</strong>developers<strong>journal</strong>.com


Your <strong>con</strong>nection to the .NET experienceThe most secure link between .NET and your data.The .NET platform enables you to create powerful s<strong>of</strong>tware that fully harnesses the <strong>con</strong>nectivity <strong>of</strong> theInter<strong>net</strong>. But how will you <strong>con</strong>nect your .NET s<strong>of</strong>tware to vital information that resides in the myriad<strong>of</strong> databases in your enterprise? DataDirect Connect for .NET.Our data provider delivers secure, high-performance data <strong>con</strong>nectivity to the leading databases.And since every bit <strong>of</strong> unmanaged code that reaches outside the Common Language Runtime(CLR) increases security risks, it’s built with 100% managed code. So it runs entirely within the.NET CLR, providing you with better performance and fewer security risks.The .NET result? You get the best experience <strong>con</strong>necting your applications to your data.An experience that’s supported by our unparalleled relationships with the creators <strong>of</strong> the.NET standard and leading database vendors. To learn more and experience .NETthe way it was meant to be, visit our site today, www.datadirect-technologies.com/<strong>net</strong>Your S<strong>of</strong>tware, Our Technology—Experience the Connection. SM©2002 DataDirect Technologies. DataDirect Connect is a registered trademark <strong>of</strong> DataDirect Technologies. All other trademarks and registered trademarks are the property <strong>of</strong> their respective companies.


FeatureAll Data, All the Time…An introduction to .NET data accessand SQLXML Web servicesSERVERBY BOB BEAUCHEMINHOMEDESKTOPEVERYWHEREin this “Data Access” column,I will discuss topicsrelating to the Micros<strong>of</strong>t.NET data access stack,known as ADO.NET. This installmentstarts with an overview <strong>of</strong> thedifferent pieces <strong>of</strong> the stack and finisheswith an interesting developmentin the world <strong>of</strong> SQL Server,.NET, and XML Web services.The ADO.NET data access APIs<strong>con</strong>sist <strong>of</strong> three types <strong>of</strong> classes:1. Classes for executing databasecommands in <strong>con</strong>nected mode:This is accomplished by a series<strong>of</strong> data providers that run inmanaged code as much as possible.Each <strong>of</strong> these data providersimplements approximately thesame set <strong>of</strong> interfaces andexposes an analogous class hierarchy.2. Dis<strong>con</strong>nected data access classes:A series <strong>of</strong> classes in theSystem.Data namespace that<strong>con</strong>sists <strong>of</strong> a complex in-memorycollection class (called theDataSet), which approximatesrelational database semantics,and supporting classes such asthe DataTable, DataRow, andDataRelation.3. Classes for XML integration:DataSets, with help from a fewadditional classes in the System.Xmlnamespace (althoughthey “live” in the System.Data.dll),integrate the XML and relationaldata access worlds. It’s also possibleto allow for data interchangewith heterogeneous platforms,such as Unix <strong>sys</strong>tems and IBMmainframes, using XML Web services.An ADO.NET Crash CourseWe’ll start with a crash course inADO.NET <strong>con</strong>sisting <strong>of</strong> some simpleprograms.Executing Database Commandsin Connected ModeData providers include a SQLServer–specific provider (theSqlClient data provider) and adata provider, known as the OleDbdata provider, which is a bridgefor OLE DB data sources. Justbefore .NET shipped in February,Micros<strong>of</strong>t released a bridgeprovider for ODBC data sourcesfor download from the Web. So, ifyou use SQL Server or have anOLE DB provider or ODBC driverfor your database, you can use the.NET data access classes directlywith your data.The simplest starter program forreading a resultset (the results <strong>of</strong> aSQL SELECT statement) <strong>con</strong>tainingtwo columns from a SQL Server table(in C#) would look like Listing 1.The program uses the SqlClientdata provider’s Connection class(which includes a <strong>con</strong>structor thattakes a database <strong>con</strong>nection string)to open a <strong>con</strong>nection to SQL Server.The Command class encapsulatesSQL statement functionality andincludes a <strong>con</strong>structor that takes aSQL command string. We use this toexecute the SQL; the results arereturned in a DataReader class. Thisclass has methods that allow us tomove forward through the rows inthe resultset, along with methodsthat allow us to access the data ineach row by using zero-based columnordinals.We’ll discuss using dataproviders with different datasources in more detail in futurecolumns. In addition to Micros<strong>of</strong>t’sdata providers, third parties canbuild data providers. For example,DataDirect Technologies hasshipped native providers for Oracleand Sybase. You can also build yourown. I built a simple data providerthat’s available for download athttp://staff.develop.com/bobb.Dis<strong>con</strong>nected Dataand the DataSet ClassThe DataSet class is a specializedcollection class that includes a collectionthat follows the relationaldata model. If you’re used to dealingwith tables, columns, rows, andrelationships, you’ll be right athome with DataSet. DataSets can beused as an in-memory cache or adata source for ASP.NET Web Forms<strong>con</strong>trols, or they can be directlybound and manipulated byWindows Forms <strong>con</strong>trols. DataSetsinteract with data providers througha data provider’s DataAdapter class.Listing 2 shows a simple programthat reads data into a DataSet,updates the DataSet, and flushesthe updates back to the database.Note that you don’t have to open the<strong>con</strong>nection directly when you’reusing a DataAdapter because theDataAdapter.Fill method opens the<strong>con</strong>nection, reads the rows, andthen closes the <strong>con</strong>nection automatically.Although using a DataSet is similarin <strong>con</strong>cept to using the dis<strong>con</strong>nectedADO Recordset class, aDataSet can <strong>con</strong>tain multiple tables16Preview Issue • dot<strong>net</strong>developers<strong>journal</strong>.com


and the XML integration is infinitelymore flexible. It’s instructive to lookat the DataSet as an ADO Recordseton steroids.You can use DataSets with datafrom any data provider, synthesizetables and data using the APIsdirectly, or fill the DataSet usingXML. Using DataSets alone or in<strong>con</strong>junction with the XmlDataDocumentclass (a hybrid <strong>of</strong> DataSetand XmlDocument) allows you totransparently mix and switchbetween XML and relational data.Here’s an example that writes aDataSet as XML:DataSet ds = new DataSet();SqlDataAdapter da = newSqlDataAdapter("select au_id, au_lname fromauthors","server=myserver;uid=myuser;pwd=mypwd;database=pubs");da.Fill(ds, "authors");ds.WriteXml("c:\\authors.xml");ds.WriteXmlSchema("c:\\authors.xsd");I’ll look at some <strong>of</strong> the intricacies<strong>of</strong> the DataSet and related classes infuture columns.SQL Server, XML,and Web ServicesNow that we’ve covered thebasics <strong>of</strong> the ADO.NET data accessstack, let’s turn to another featurethat helps integrate Micros<strong>of</strong>t’s SQLServer database, XML documents,.NET programming, and XML Webservices. This extension to SQLServer, known as SQLXML, is availableon the Web for download.The SQLXML Configuration ToolThe SQLXML 3.0 version addedthe capability to expose data fromSQL Server and perform databasemaintenance through Web services.This means that database operationscan be accomplished from anyplatform that supports Web services,without needing SQL Serverclient libraries, OLE DB providers,or ODBC drivers to be installed oneach user’s workstation. This isimplemented through an IIS ISAPI(Inter<strong>net</strong> Services API) applicationthat supports sending and receivingmessages using SOAP (Simpledot<strong>net</strong>developers<strong>journal</strong>.com • Preview IssueObject Access Protocol). The SOAPprotocol (and Web services in general)is designed to provide interoperabilitybetween heterogeneousplatforms. You don’t need to usethem when you have a direct <strong>con</strong>nectionto SQL Server and can useSQL Server’s native TDS (TabularData Stream) protocol to communicate.However, if you have a Webservice that passes DataSets aroundas XML, there’s no automatic way toprovide .NET DataSets to VB6clients. VB6 could in this case be<strong>con</strong>sidered a heterogeneous platformas well.SQLXML 3.0 makes exposingresults from a stored procedure,user-defined function, or SQLXMLtemplate query (a SQL or XPathquery bracketed by XML) as easy as<strong>con</strong>figuring it in the SQLXML IIS<strong>con</strong>figuration utility. No server-sidecode need be written. You even havea few choices <strong>of</strong> how to return yourSQL results: as a .NET DataSet, anarray <strong>of</strong> .NET DataSets, or an array<strong>of</strong> XmlElement. The XmlElement isa .NET class in the managed XMLstack that can represent an XMLdocument or a document fragment.When you’re returning arrays, yourepresent this in your .NET clientprogram as an array <strong>of</strong> type Object,because your stored procedure mayreturn errors <strong>of</strong> type SqlMessage iferrors occur in execution. I’llexplain more about the array <strong>of</strong>objects when we write the client.You also have a choice <strong>of</strong>whether your SQL resultsets aregenerated in “XML RAW” format or“XML NESTED” format. XML RAWformat returns each row in theresultset as an XML element namedrow; columns are returned in attributenormal form (i.e., each columnis an attribute <strong>of</strong> the row element).XML NESTED format returns hierarchicallynested XML elementsnamed after the tables used in theSQL SELECT statement. There maybe multiple levels <strong>of</strong> hierarchy,depending on the SQL statement.You also have the option <strong>of</strong> <strong>con</strong>figuringyour Web service methods toreturn a SOAP Fault element instead<strong>of</strong> a SqlMessage element if errorsoccur.To <strong>con</strong>figure the SQLXML IISutility to return SOAP, you must<strong>con</strong>figure a virtual name for theSOAP Web service after mapping aSQLXML virtual directory to a SQLServer and a specific database. Youuse the Virtual Names tab to accomplishthis. You can add one or moreSOAP virtual names per virtualdirectory if you want. Although theSOAP virtual name can be anything,a common <strong>con</strong>vention is to name it“soap” (see Figure 1).Once you’ve <strong>con</strong>figured theSOAP virtual name, you add accessto your stored procedures, userdefinedfunctions, or templatesusing the <strong>con</strong>figuration button. TheXML output format options mentionedin the previous paragraphcan be specified on a per-methodbasis. The SQLXML <strong>con</strong>figurationtool even generates the WSDL (WebService Description Language) that’sused to describe your Web serviceparameters to the outside worldautomatically when you save the<strong>con</strong>figuration. The endpoint thatexposes this WSDL document is acombination <strong>of</strong> the virtual directoryand the SOAP virtual name with“?WSDL” appended – so for example,if the name <strong>of</strong> the virtual directoryis “pubs” and the SOAP virtualname is “soap,” the WSDL may beobtained at http://webserver/pubs/soap?WSDL.Figure 2 shows how to <strong>con</strong>figurea template. In this case, the storedprocedure byroyalty is mapped to aWeb service endpoint, namedAuthorsByRoyaltyAsDataSets, usingthe raw row formatting style. ThisWeb service returns errors asSqlMessage types rather than asnative SOAP errors.Writing the ClientNow that we’ve “written” the Webservice – by virtue <strong>of</strong> having a storedprocedure, UDF (user-defined function),or SQLXML template alreadyin place (wasn’t that easy?) – let’swrite the client. Writing a .NET clientis fairly automatic (as it should be),no matter how we’ve chosen toreturn the results. In any VS.NETclient project, click on references inthe Project Explorer pane andchoose “Add Web Reference.” Pointthe Add Web Reference dialog at theWSDL file, and click “Add Reference.”A Web service proxy class is automaticallygenerated. This proxy class will<strong>con</strong>tain methods that can be used to17


FeatureSERVERf 1HOMEDESKTOPEVERYWHEREFigure 1: Configuring the SOAP virtual nameinvoke your newly created Web service.As with all VS.NET-generatedproxies, both synchronous and asynchronousexecution are supported. Ifyou don’t have VS.NET, the sameresults can be obtained by using thewsdl.exe command-line utility.Listing 3, which can be found atwww.<strong>sys</strong>-<strong>con</strong>.com/dot<strong>net</strong>/sourcec.cfm is an example <strong>of</strong> using a .NETproxy class to fill an array <strong>of</strong>DataSets.I mentioned earlier that I wouldexplain what “array <strong>of</strong> objects”means as a Web services returnvalue. This is best illustrated byinspecting the WSDL generated bythe <strong>con</strong>figuration tool. The typessection <strong>of</strong> the WSDL file <strong>con</strong>tainsschemas for four generic types:1. SqlRowSet: Produced when youchoose to expose the results as aDataSet, which <strong>con</strong>sists <strong>of</strong> anXML schema describing theresultset, followed by a resultsetin the XML DiffGram format, representedas an xsd:any type. Thisproduction corresponds to ageneric result (the xsd:any type)preceded by an inline schemadescribing the result.2. SqlXml: Produced when youchoose array <strong>of</strong> objects in the <strong>con</strong>figurationtool. It <strong>con</strong>sists <strong>of</strong> anxsd:sequence element followed byan xsd:any element. Since thexsd:any element is completelygeneric, the output is looselytyped and depends entirely on thestored procedure’s outputs.3. SqlResultCode: Consists <strong>of</strong> a singleinteger representing theResult parameter from a SQLstored procedure or UDF.4. SqlMessage: Contains multiple,well-defined elements <strong>con</strong>sisting<strong>of</strong> the information returned whenSQL Server returns an error.These types are defined in threedifferent XSD schemas exposedinside the WSDL document. A list <strong>of</strong>all the schemas for all <strong>of</strong> the types isbeyond the scope <strong>of</strong> this article, butas an example, here’s the schema forthe SqlXml and SqlRowSet complextypes. Note that the actual DataSetor XmlElement result is representedas XSD type xsd:any:If we return an array <strong>of</strong> DataSetor XmlElement it may also <strong>con</strong>tainthe SqlMessage complex type iferrors occur, so the entire series <strong>of</strong>results, known as a SqlResultStreamtype, appears to the client as anarray <strong>of</strong> .NET type Object. In thatcase, the correct type <strong>of</strong> any part <strong>of</strong>the SqlResultStream can be determinedby using Object.GetType asshown in the sample program or byprior knowledge <strong>of</strong> the result by theprogrammer.Web services aficionados maybe <strong>con</strong>cerned with the loose typingimplied by the xsd:any types inthe SqlRowSet and SqlXml complextypes. It’s necessary for specificreasons. First, the DataSetitself is a generic <strong>con</strong>tainer class;you can deduce the schema <strong>of</strong> aspecific DataSet instance onlyfrom the inline schema in theSqlRowSet. Se<strong>con</strong>d, the WSDL generatorin the SQLXML <strong>con</strong>figurationutility can’t obtain metadatafrom the database that describesstored procedures’ resultsets.Stored procedures may obtain differentresults and even differentnumbers <strong>of</strong> results on a case-bycasebasis. But how will thesetypes be accessed by non-.NETclients that don’t have definitions<strong>of</strong> the XmlElement or DataSetclasses? Doesn’t this amount toreturning every result as generic,untyped XML and forcing theclient to figure out what’s in there?Although the SQLXML <strong>con</strong>figurationutility doesn’t know what canbe obtained from the stored procedure,UDF, or template returns, theTransact SQL programmer <strong>of</strong> theseXML Web services does know. Fornon-.NET clients that require strongtyping, you can hand-code alternativeWSDL and make it available atan alternate endpoint. If your clientcan handle inline schema, this maybe as easy as exposing a customschema that specifies a complextype your stored procedure produces.In the case <strong>of</strong> SqlXml, youcan code an alternate (stronglytyped) complex type. For example,the result returned in the exampleabove could be coded as:18Preview Issue • dot<strong>net</strong>developers<strong>journal</strong>.com


Get all the details online!Go to www.gartner.com/us/eai now for . . .• Complete session descriptions• Updated keynote guest roster• Hotel & travel discounts and information• Fast and easy online registration• $200 Early Bird SavingsA clear view <strong>of</strong> theintegration future.And a roadmapto get you there!Application Integration and Web Services:The Next-Generation S<strong>of</strong>tware Infrastructure EmergesOctober 28 – 30, 2002Sheraton Chicago Hotel and TowersChicago, IllinoisTo register call1.800.778.1997 or +1.203.316.6757or visit www.gartner.com/us/eaiAnd don’t miss these special<strong>con</strong>ference features:■ Facilitated peer <strong>net</strong>working■ Corporate case studies■ Interactive vendor panels■ Gartner analyst One-on-OnesAfter years <strong>of</strong> false starts and missteps, the future <strong>of</strong> application integration andWeb services is finally clear – and at Gartner’s groundbreaking <strong>con</strong>ference thisfall, you can be among the first to see it. From product and vendor selectionto project planning and implementation, our balanced strategic guidance andtactical advice can help you make the right decisions now – saving time, moneyand ensuring your organization a lasting competitive advantage.Choose from dozens <strong>of</strong> in-depth sessions in three high-focus tracks:Track A: Application IntegrationLearn how key application integration <strong>con</strong>cepts, technology, products andvendors will transform and develop – and what to do now in order to stayahead <strong>of</strong> it all.Track B: Web Services and S<strong>of</strong>tware InfrastructureExplore in detail how J2EE, .NET – and the very nature <strong>of</strong> Web servicesthemselves – are altering the way <strong>sys</strong>tems are designed, implementedand managed.Track C: Management IssuesExamine each key element <strong>of</strong> a successful integration project – includingproject payback, IS staffing, vendor viability, s<strong>of</strong>tware acquisition and otherimportant application integration and Web services management issues.Reference Priority Code: APNWSJ


Featurel 1Listing 1SqlConnection <strong>con</strong>n = new SqlConnection("server=myserver;uid=myuser;pwd=mypwd;database=pubs");SqlCommand cmd = new SqlCommand("select au_id, au_lname from authors", <strong>con</strong>n);SqlDataReader rdr;try {<strong>con</strong>n.Open();rdr = cmd.ExecuteReader();while (rdr.Read())Console.WriteLine("author {0} has name {1}", rdr[0],rdr[1]);}catch (Exception e) {Console.WriteLine(e.Message);}finally {if (<strong>con</strong>n.State == ConnectionState.Open)<strong>con</strong>n.Close();}f 2 Figure2: Configuring a stored procedure toreturn SOAPThis complex type should be usableby any client, not only those writtenin ADO.NET.DataSet ds = new DataSet();l 2 Listing 2SqlDataAdapter da = new SqlDataAdapter("select au_id, au_lname from authors","server=myserver;uid=myuser;pwd=mypwd;database=pubs");// this classes builds commands to update the databaseSqlCommandBuilder bld = new SqlCommandBuilder(da);// <strong>con</strong>nection is closed here...da.Fill(ds, "authors");// <strong>con</strong>nection closed here toods.Tables[0].Rows[0][1] = "newlastname";da.Update(ds, "authors");Bob Beauchemin has more than 22years’ experience in the computerindustry as an instructor, courseauthor, s<strong>of</strong>tware developer, and<strong>sys</strong>tems administrator. He’s currentlya senior staff instructor atDevelopMentor, curriculum liaison forthe data access curriculum, andauthor <strong>of</strong> courses on ADO.NET, OLEDB, ADO, SQL Server applicationdevelopment, and Java data access.bobb@develop.comHOMEDirect Programmatic AccessWe’ve seen how SQLXML lets usproduce Web services <strong>con</strong>sumable byany client with little or no coding onthe server side. We wouldn’t want touse these services gratuitously if <strong>con</strong>sumingTDS directly is possible; usingTDS instead <strong>of</strong> XML is always going tobe more efficient. But for situations inwhich we want to make SQL Serveravailable to non-Micros<strong>of</strong>t clients,combining SQL, XML, and SOAP maybe an easy way to achieve interoperability.When using .NET clients, thisgives us the ability to permit <strong>con</strong>trolledaccess to our SQL Server withoutrequiring either direct access orwriting an ASP.NET Web service application.A Web service allows directprogrammatic access.Advertiser IndexADVERTISER URL PHONE PGAltova www.altova.com 978.816.1600 4Crystal Decisions www.crystaldecisions.com/cr9/021/ 888.333.6007 27DataDirect www.datadirect-technologies.com/<strong>net</strong> 800.876.3101 13Gartner www.gartner.com/us/eai 800.778.1997 19Infragistics, Inc. www.infragistics.com 800.231.8588 2, 3Interland www.interland.com 800.845.8706 28/n s<strong>of</strong>tware inc. www.ns<strong>of</strong>tware.com 919.402.0590 15Rational S<strong>of</strong>tware www.rational.com/<strong>of</strong>fer/webservices13 800.728.1212 11SERVERDESKTOPEVERYWHERENext TimeSince .NET has been released,a plethora <strong>of</strong> .NET data providershave also hit the market. Nexttime we’ll discuss strategies formigrating existing code, lookingat how the ADO.NET modelmakes it easier for provider writersto expose data source–specificfeatures, and how this affectsinteroperability.Sams Publishing www.samspublishing.com 317.581.3500 9SYS-CON Media www.<strong>sys</strong>-<strong>con</strong>.com/dot<strong>net</strong>/ 888.303.5282 21General Conditions: The Publisher reserves the right to refuse any advertising not meeting the standards that are set to protect the high editorialquality <strong>of</strong> Dot Net Developer’s Journal. All advertising is subject to approval by the Publisher. The Publisher assumes no liability for any costs ordamages incurred if for any reason the Publisher fails to publish an advertisement. In no event shall the Publisher be liable for any costs or damagesin excess <strong>of</strong> the cost <strong>of</strong> the advertisement as a result <strong>of</strong> a mistake in the advertisement or for any other reason.The Advertiser is fully responsiblefor all financial liability and terms <strong>of</strong> the <strong>con</strong>tract executed by the agents or agencies who are acting on behalf <strong>of</strong> the Advertiser. Conditions setin this document (except the rates) are subject to change by the Publisher without notice. No <strong>con</strong>ditions other than those set forth in this “GeneralConditions Document” shall be binding upon the Publisher. Advertisers (and their agencies) are fully responsible for the <strong>con</strong>tent <strong>of</strong> their advertisementsprinted in Dot Net Developer’s Journal.Advertisements are to be printed at the discretion <strong>of</strong> the Publisher.This discretion includes the positioning<strong>of</strong> the advertisement, except for “preferred positions” described in the rate table. Cancellations and changes to advertisements must bemade in writing before the closing date. “Publisher” in this “General Conditions Document” refers to SYS-CON Publications, Inc.20Preview Issue • dot<strong>net</strong>developers<strong>journal</strong>.com


introductorysubscription <strong>of</strong>fer!A TRULY INDEPENDENTVOICE IN THE WORLD OF .NET.NET Developer’s Journal is the leadingindependent monthly publication targeted at .NETdevelopers, particularly advanced developers. It brings.NET developers everything they need to know in orderto create great s<strong>of</strong>tware.Publishedmonthly, .NETDeveloper’sJournal coverseverything <strong>of</strong> interest todevelopers working withMicros<strong>of</strong>t .NET technologies– all from acompletely independentand unbiased perspective.Articles are carefullyselected for their primetechnical <strong>con</strong>tent – technicaldetails aren’t watered down withSUBSCRIBE ONLINE!www.<strong>sys</strong>-<strong>con</strong>.com/dot<strong>net</strong>/or Call1 888 303-5282Here’s what you’ll find inevery issue <strong>of</strong> .<strong>net</strong>dj:Security WatchMobile .NET.NET TrendsTech TipsStandards WatchBusiness Alerts.NET NewsBook and S<strong>of</strong>twareAnnouncements.NET Developer’s Journal is for .NETdevelopers <strong>of</strong> all levels, especially those “inthe trenches” creating .NET code on a dailybasis:• For beginners:Each issue <strong>con</strong>tains step-by-step tutorials.• For intermediate developers:There are more advanced articles.• For advanced .NET developers:In-depth technical articles and columnswritten by acknowledged .NET experts.Regardless <strong>of</strong> their experience level, .NETDeveloper’s Journal assumes that everyonereading it shares a common desire to understandas much about .NET – and the businessforces shaping it – as possible. Our aimis to help bring our reader-developers closerand closer to that goal with each and everynew issue!lots <strong>of</strong> needless opinion and commentary.Apart from the technical <strong>con</strong>tent, expert analystsand s<strong>of</strong>tware industry commentators keep developersand their managers abreast <strong>of</strong> the businessforces influencing .NET’s rapid development.Wholly independent <strong>of</strong> both Micros<strong>of</strong>t Corporationand the other main players now shaping the course <strong>of</strong>.NET and Web services, .NET Developer’s Journalrepresents a <strong>con</strong>stant, neutral, expert voice on thestate <strong>of</strong> .NET today – the good, the bad, and theugly…no exceptions.SAVE16%OFFTHE ANNUAL COVER PRICEGet 12 issues <strong>of</strong> .NETDJfor only $ 69 99 !OFFER SUBJECT TO CHANGE WITHOUT NOTICEANNUALCOVER PRICE:$83.88YOU PAY$69 99YOU SAVE$13.89OFF THE ANNUALCOVER PRICE


FeatureEnterprise .NET for Smart DevicesIntroducing the .NET Compact Frameworkand Smart Device Extensions for VS.NETEVERYWHEREBY CHRISTIANFORSBERG& ANDREAS SJÖSTRÖMHOMEDESKTOPSERVER22if you want to extend yourexisting <strong>sys</strong>tems as wellas your knowledge <strong>of</strong>.NET development whilebuilding solutions for smart devices,the upcoming .NET CF (CompactFramework) and SDE (Smart DeviceExtensions) are definitely the way togo. In this article we provide anexample <strong>of</strong> how to implement amobile application that can work asan extension to your existing <strong>sys</strong>tems,and also show you how toextend your knowledge <strong>of</strong> .NETdevelopment.It’s perhaps more true than everthat mobile solutions rarely standalone. Most <strong>con</strong>sumer-orientedapplications are created to work inan <strong>of</strong>fline or dis<strong>con</strong>nected mode,but for enterprise solutions theincreasing <strong>con</strong>nectivity <strong>of</strong> newdevices opens up enormous possibilitiesfor online and “sometimes<strong>con</strong>nected” applications as well.When looking at real-world businessscenarios and the capabilities<strong>of</strong> current mobile devices, it’s obviousthat the options are greater thanjust <strong>of</strong>fline or online. Specific userrequirements such as “how <strong>of</strong>ten?”and “at what bandwidth?” shoulddetermine where on the scale from<strong>of</strong>fline to online we need to be (seeFigure 1).The more a mobile application is<strong>con</strong>nected, the thinner it can befrom an application logic and localstorage perspective. The less it’s<strong>con</strong>nected, the higher the demandon the application logic and localstorage. A typical online mobileapplication is a Web application targetedat smart device browsers likeInter<strong>net</strong> Explorer for Pocket PC.With a Web application there are nodeployment issues for the device, asthe browser is already in place.However, most other <strong>con</strong>nectivityoptions (from “auto-<strong>con</strong>nected” allthe way to “never <strong>con</strong>nected”)require you to have a custom applicationrunning on the device.The need for <strong>con</strong>nectivity alsoimplies that we’re most <strong>of</strong>ten talkingabout extending existing <strong>sys</strong>tems toanyplace. Many workers are currentlytied to a desk with a PC on awire. They would like to be free togo wherever they want, yet still beable to perform their duties. Is itasking too much to help those poorpeople out?Consider Some ExamplesLet’s take a simple scenario likereporting time. Many mobile workershave to specify how they spendtheir time during their work hours.This is a common task in an enterpriseenvironment, and many <strong>of</strong> usare familiar with the pain <strong>of</strong> “re-creating”the past week during theweekly reporting – late Sunday night– into our company’s central timereporting <strong>sys</strong>tem. Why? Because wehave to wait until we find a PC that’swired to the company <strong>net</strong>work.What if we could do it anyplace?And since we don’t need to do theactual reporting more than weekly,it would fall into the category “seldom<strong>con</strong>nected” (see Figure 1).What if we didn’t actually have to be<strong>con</strong>nected when we do it?Another issue is how we can helpthose workers get the new tools <strong>of</strong>the trade. What if we could use thesame knowledge that we alreadyhave in building our enterprisesolutions? In the not too distantfuture, most <strong>of</strong> those solutions usingMicros<strong>of</strong>t technology will be developedfor .NET, and therefore itwould be great if we could extend.NET and .NET development skillsto build those solutions for mobiledevices. As you may already know,you’ll soon be able to do just that.Build a Business CaseIn defining how we can benefitfrom turning paper-based processesinto mobile solutions, the keywordsare speed and quality.First <strong>of</strong> all, since time is money,we want to save time. By savingtime we can get an instant paybackon the investment in most mobilesolutions. We can save time for themobile worker, and most probablyalso for the back-<strong>of</strong>fice personnelwho now enter submitted paperdata into a <strong>sys</strong>tem. Perhaps mostimportantly, we could also save thetime between data entry and datausage. For example, if the timereported was submitted each dayinstead <strong>of</strong> each week, we couldexpedite invoices related to thattime.Se<strong>con</strong>d, we’ll collect the data at thesource, gaining speed in our businessand improving data quality. Writingdata on paper, then passing it tosomeone else to read and enter into a<strong>sys</strong>tem is probably the most certainway to achieve poor-quality data.Higher quality most <strong>of</strong>ten translates tosaved time, and also to improved relationshipswith customers, partners,and even employees.Preview Issue • dot<strong>net</strong>developers<strong>journal</strong>.com


What we’re trying to say is that ifyou want to build a successfulmobile solution, do your homework– document the business casebehind the solution. Most <strong>of</strong>ten, ifyou just spend some time thinkingit through, it’s not very hard.Technology OverviewSo, what is enterprise .NETdevelopment for smart devices? Ifwe look at the <strong>con</strong>nectivity optionsfor an application (see Figure 1), wesometimes want to build a thinbrowser-based Web application, inwhich case we would probably use atool like Micros<strong>of</strong>t Mobile Inter<strong>net</strong>Toolkit with ASP.NET. But for mostother <strong>con</strong>nectivity options, we needsomething that provides a soliddevelopment environment on thedevice. This is why the upcomingrelease <strong>of</strong> the .NET CompactFramework and Smart DeviceExtensions for Visual Studio .NET(VS.NET) becomes interesting..NET CF is a subset <strong>of</strong> the full.NET Framework. Careful thoughthas been put into selecting theclasses that make the most sense ona mobile device, taking into accountthe smaller footprint required ondevices and the accompanyingmemory and performance restrictions.It includes a CLR targeted forsmart devices.SDE is a set <strong>of</strong> extensions toVS.NET that enable you to buildapplications for the .NET CF. Theextensions include pr<strong>of</strong>iles that customizeVS.NET for smart devicedevelopment. For example, whentargeting the .NET CF, you getIntelliSense for the supported classesand only supported <strong>con</strong>trols areavailable in the toolbox.For enterprise developers, thismeans that we’ll now get back to theOfflineNeverConnectedf 1SeldomConnectedFigure 1: The <strong>of</strong>fline/online scaleOftenConnecteddot<strong>net</strong>developers<strong>journal</strong>.com • Preview Issuestate where there’s a single tool setfor building applications for PCsand smart devices like Pocket PCand the coming SmartPhone 2002.C# or VB.NET?There’s been much discussion onthe selection <strong>of</strong> a development languagefor VS.NET. As we’ve made achoice to implement our sampleapplication in C#, we’ve stated ourpremium choice <strong>of</strong> language.However, we think that all enterprise.NET developers will have tomanage development in both C#and VB.NET. Various projects will berun using each, and we think thatthe choice will most <strong>of</strong>ten be madein relation to historical issues ratherthan technical issues like performanceor productivity, or evenissues like speed <strong>of</strong> developmentand ease <strong>of</strong> maintenance.Traditional Visual C++ developersand even Java developers willprobably select C# as their premiumchoice, and we think that even Javadevelopers <strong>con</strong>verting to C# willhave a less painful migration thanVisual Basic 6 developers will have<strong>con</strong>verting to VB.NET.The interesting part <strong>of</strong> .NET isnot the languages, but the framework.Despite the excellent languageinteroperability in .NET, wedon’t recommend mixing languagesin the same project if youcan avoid it.Time Reporting ExampleTo show you what we mean,we’ve put together a sample applicationto report the time you spendon different activities. With this simpletool, you can report your timeanyplace and at any time.The opening screen <strong>of</strong> the sampleapplication (see Figure 2) showsAuto-ConnectedOnlineAlwaysConnectedf 2 Figure2: Time reporting applicationa list <strong>of</strong> times reported for differentactivities (usually projects), whichyou can manipulate with the Add,Edit, and Delete buttons. You usethe Save button to save all timesreported and exit the application.When you tap the Add or Editbutton, you’re presented with a newscreen (see Figure 3). Here you canreport or update an activity withdate, project, and hours spent.Obviously, you save with the OKbutton and abort with the Cancelbutton.The sample application allowsthe user to work <strong>of</strong>fline using XMLfiles. The Project ComboBox (seeFigure 3) is filled from an XML file(projects.xml) and the reportedtime is saved in (and retrieved onstartup from) an XML file (timereport.xml).Code WalkthroughLet’s have a look at the code forthe sample application. As we’vealready stated, our choice <strong>of</strong> languagefor the sample is C#, and wehope that most VB.NET developerswill be able to follow the logic anyway.(Authors’ Note: We built our sampleapplication using prerelease versions<strong>of</strong> Visual Studio .NET, .NETCompact Framework, and SmartDevice Extension, and therefore itmay not be compatible with thefinal release versions.)One <strong>of</strong> the core features <strong>of</strong> the.NET CF is native support for23


FeatureEVERYWHEREf 3 FigureHOMEDESKTOPSERVER3: Report time screenXML. The code to populate theProject ComboBox in Figure 3 is inListing 1.As the ADO.NET DataSet hasnative support for XML, we can usethis to load an XML file (projects-.xml) <strong>con</strong>taining the current projects.Each row’s Name field in theDataSet (XML file) is then added tothe ComboBox (cboProject). And ifsomething goes wrong (such as thatwe can’t open the file), we add adummy project name instead.Finally, we select the first project asthe default value. The project.xmlfile looks like this:SDE SampleLearn .NET CFLearn SDEIn a similar way, the reportedtime is saved in an XML file (timereport.xml)each time the applicationexits. The code for the closing event<strong>of</strong> the main form looks like this:DataSet dsTime = new DataSet();dsTime.ReadXml(@"\Windows\timereportempty.xml");dsTime.Clear();// Get data from ListViewforeach (ListViewItem lit inlvwItems.Items){DataRow dr;dr = dsTime.Tables[0].NewRow();dsTime.Tables[0].Rows.Add(dr);dr["Date"] = lit.Text;dr["Project"] = lit.SubItems[1].Text;dr["Hours"] = lit.SubItems[2].Text;dsTime.AcceptChanges();}// Save to XML file dsTime.WriteXml(@"\Windows\timereport.xml");Again, an XML file (timereportempty.xml)<strong>con</strong>taining thestructure <strong>of</strong> the data is used to createthe DataSet. Then the DataSet iscleared and each <strong>of</strong> the rows in theListView (lvwItems) is added to theDataSet. Finally, and most elegantly,the DataSet is saved to an XML file(timereport.xml). The timereportempty.xmlfile looks like this:This is a very simple way <strong>of</strong> creatingthe structure <strong>of</strong> a new DataSet.We could create the DataSet usingcode for adding a table with fields,but it would require much more typingthan if we create the XML file.The resulting timereport.xml file(with the data from Figure 2) lookslike this:02/17/02SDE Sample102/18/02Learn .NETCF202/19/02Learn SDE3(Authors’ Note: The project.xmland timereportempty.xml files arerequired to be available on thedevice [emulator or physical] inthe \Windows folder to make thesample application work. You haveto download this file to the devicebefore you run the sample. Thetimereport.xml file will be createdon application exit, but you willget a message box telling you thatit’s missing on application start.)The native support for XMLmakes working with data in XMLfiles very efficient, and for someapplications this is the only localstorage you’ll ever need. For moredemanding scenarios, you’ll need tohandle local storage through a relationaldatabase like SQL Server forWindows CE.Communicating Between FormsAnother interesting feature <strong>of</strong>.NET that we’d like to cover is theway you can communicate betweenforms. As a Visual Basic 6 developer,you had to build your own plumbingto make forms talk to eachother, usually by implementing acustom public method for showingthe form. Your pain is over! Todemonstrate, let’s have a look at thecode behind the Edit button inFigure 2:frmTimeReportItem frmItem = newfrmTimeReportItem();frmItem.Date = lvwItems.Selected-Items[0].Text;frmItem.Project = lvwItems.SelectedItems[0].SubItems[1].Text;frmItem.Hours = lvwItems.Selected-Items[0].SubItems[2].Text;if (frmItem.ShowDialog() ==DialogResult.OK){lvwItems.SelectedItems[0].Text =frmItem.Date;lvwItems.SelectedItems[0].SubItems[1].Text = frmItem.Project;lvwItems.SelectedItems[0].SubItems[2].Text = frmItem.Hours;}We start by creating the subform(frmTimeReportItem, shown in24Preview Issue • dot<strong>net</strong>developers<strong>journal</strong>.com


Figure 3) and setting the publicproperties Date, Project, and Hoursfrom the currently selected row inthe ListView. We then show the formwith the ShowDialog method and ifthe return value <strong>of</strong> that call indicatesthat we tapped the OK button,the ListView is updated from thesame properties. Here’s the implementation<strong>of</strong> the Project property inthe frmTimeReportItem form:write by hand. Most <strong>of</strong> the remainingcode is generated by the projecttemplate and forms designer. Thecomplete sample is less than 100lines <strong>of</strong> code – including the lineswith only a “{“ or a “}”.The version <strong>of</strong> the SDE we’veused (the tech preview released atMicros<strong>of</strong>t’s Pr<strong>of</strong>essional DevelopersConference in November2001) didn’t include a formsprojects (projects.xml), and updatesan XML file (timereport.xml) withthe reported time. In a real-worldenterprise scenario, these fileswould be synchronized with a centraltime-reporting <strong>sys</strong>tem on aserver. One requirement is that thecentral time-reporting <strong>sys</strong>tem mustbe able to handle import and export<strong>of</strong> XML – are there any <strong>of</strong> thosearound today that can’t?“We think that all enterprise .NET developers will haveto manage development in both C# and VB.NET”public string Project{get{return cboProject.Text;}set{cboProject.Text = value;}}The property simply gets andsets the Text property <strong>of</strong> the ProjectComboBox (cboProject). To makethis work, we have to make sure thatthe ComboBox is loaded before weaccess the property. That’s why thecode to load the ComboBox isplaced in the <strong>con</strong>structor <strong>of</strong> theform class.To make the ShowDialog methodreturn different values for differentbuttons, you simply set theAcceptButton and CancelButtonproperties <strong>of</strong> the form. This codecomes from the InitializeComponentmethod in the code generatedby the forms designer:this.AcceptButton = this.btnOK;this.CancelButton = this.btnCancel;For a complete example, youshould download the sample codefor this article from www.<strong>sys</strong><strong>con</strong>.com/dot<strong>net</strong>/sourcec.cfm.Lessons LearnedThe really cool thing with thissample is that the code we’ve shownyou so far is nearly all that you needdot<strong>net</strong>developers<strong>journal</strong>.com • Preview Issuedesigner. But interestingly thistaught us something about howeasy it is to migrate a desktopWindows application to a smartdevice like the Pocket PC. We startedto build the sample as a nativeWindows application, then copiedthe forms into a smart device projectand made some minorchanges – and there we were with aworking sample application! Theminor changes in the .NETFramework and .NET CF ObjectModels were efficiently pointedout to us by the compiler and wereeasily corrected.In the version <strong>of</strong> the .NET CFthat we used there was noNumericUpDown <strong>con</strong>trol – itwould’ve been nice for enteringHours (see Figure 3). On a mobiledevice like the Pocket PC, the goal isalways to minimize user input, andtapping <strong>of</strong> up and down arrows –rather than entering numbers fromthe s<strong>of</strong>t keyboard (or letter recognizer)– will speed data entry significantly.However, replacing theTextBox <strong>con</strong>trol when theNumericUpDown <strong>con</strong>trol becomesavailable is no more than a minoradjustment.The device used to test thesample was a Compaq iPAQ 3650upgraded to Pocket PC 2002. Thesample worked fine in the emulator,too. It should run on a standardiPAQ (with Pocket PC 2000) aswell.Extending Existing SystemsThe sample application assumesthere’s an XML file with all ongoingConclusionIf you want to extend your existing<strong>sys</strong>tems, as well as your existingknowledge <strong>of</strong> .NET developmentwhile building solutions for smartdevices, the .NET CF and SDE are theway to go. All you have to do now isget started with extending your existing<strong>sys</strong>tems, and you’ll be <strong>of</strong>f buildingmobile enterprise .NET solutions!Even if this is a great first steptoward extending your time reportingto “anyplace,” the next logical stepwould be to make the synchronizationwith the server in a standardizedway. The way we’re thinking <strong>of</strong>involves another core part <strong>of</strong> .NETWeb services. However, it requiresthat the server <strong>sys</strong>tem be able to handleWeb services. If you have a serverwith Windows, this is most certainlydoable, and might even make a greatsubject for a future column.l 1Listing 1Christian Forsberg and Andreas Sjöströmare Micros<strong>of</strong>t MVPs (Most ValuablePr<strong>of</strong>essionals) for Mobile Devices and havejointly authored the bestselling bookPocket PC Development in the Enterprise.They can be visited atwww.businessanyplace.<strong>net</strong>.chris@businessanyplace.<strong>net</strong>andy@businessanyplace.<strong>net</strong>// Load projects from XML filetry{DataSet dsProject = new DataSet();dsProject.ReadXml(@"\Windows\projects.xml");foreach (DataRow dr in dsProject.Tables[0].Rows)cboProject.Items.Add(dr["Name"].ToString());}catch (Exception e){MessageBox.Show("Couldn't open projects.xml file!");cboProject.Items.Add("?");}finally{cboProject.SelectedIndex = 0;}25


.NET Book WatchHOMETitle: Sams TeachYourself ASP.NET in 21Days, Se<strong>con</strong>d EditionAuthor: Chris PaynePublisher: SamsList Price: $39.99Rating:Reviewed by DerekFergusonTitle: Visual Basic.NET and the .NETPlatform: AnAdvanced GuideAuthor: AndrewTroelsenPublisher: ApressList Price: $59.95Rating:Reviewed by DerekFergusonDESKTOPSERVEREVERYWHEREiSams Teach Yourself ASP.NETin 21 Days, Se<strong>con</strong>d Editionwill always rememberobtaining my advance copy<strong>of</strong> this manuscript, as itrequired a walk from my hotel roomin lower Manhattan to the W Hotelin Times Square. The trip was wellworth it, however! I began leafingthrough the manuscript on the trainback home and didn’t even go tosleep until I had read the entire firsthalf. I finished the remaining half inthe morning before we arrived inChicago. When a book is this good,you don’t even need the 21 dayspromised by its title.The book begins with virtuallyno assumptions about the reader’sprevious development experience.This is very ambitious, <strong>con</strong>sideringthat by the end <strong>of</strong> the book thereader will have covered all key <strong>con</strong>ceptsnecessary in order to becomea highly skilled ASP.NET developer.This process is helped along enormouslyby the presence <strong>of</strong> exercisesat the end <strong>of</strong> each chapter, to allowreaders to check their progresstoward the goal <strong>of</strong> ASP.NET mastery.Part <strong>of</strong> the reason I so quicklybecame engrossed in this manuscriptis that it gets <strong>of</strong>f to a veryquick start. It smartly sidesteps theissues associated with teachingeither C# or VB.NET and digs rightinto a working example to get readersinterested in exactly whatASP.NET can do for them in theirdaily work. Later on, Chapter 3 managesto compress into a single chapterso much C# versus VB.NET materialthat it would take days <strong>of</strong> scouringthe Micros<strong>of</strong>t documentation todeduce it for yourself.The book makes very quick work<strong>of</strong> teaching the basics <strong>of</strong> ASP.NETstructure and syntax, so the remainder<strong>of</strong> the manuscript is wisely spentexamining the various .NETFrameworks related to advancedASP.NET development. Just a few <strong>of</strong>these topics include XML, COMinteroperability, and internationalization.One thing I particularly likedabout this book was that every tooldescribed in it is absolutely free fordownload. Assuming you alreadyhave an ASP.NET-capable operating<strong>sys</strong>tem (Windows 2000 or WindowsXP, for example) this book showsyou how to install IIS, the .NETFramework, and the free debuggeravailable in the .NET SDK.The book’s attempt to cover Webservices in any form is admirable,and a basic understanding <strong>of</strong> thetechnology is very well communicated.On the other hand, topicssuch as SOAP headers, DISCO, andnon-ASP.NET clients (a Java applicationrunning on Solaris, for example)are mentioned in passing, andthen passed over. This is probably awise decision, <strong>con</strong>sidering the scope<strong>of</strong> the manuscript.sVisual Basic .NET and the .NETPlatform: An Advanced Guideo, there I was in the bookstore,trying to decide whatbook to buy for a plane tripout to Redmond. I’d been invited toa special .NET technology “bootcamp” for authors and wanted toarrive knowing even more about.NET than I knew stepping onto theplane.My peculiar situation was that Iknew a great deal about one specificarea <strong>of</strong> .NET (mobility – aboutwhich I’d already written a book,Mobile .NET). However, my day jobat Expand Beyond (www.xb.com)keeps me up to my armpits in Javamost <strong>of</strong> the time. What I needed wassomething that would expand thebreadth <strong>of</strong> my .NET knowledgewithout talking in terms that anexperienced Micros<strong>of</strong>t developerwould find insulting.The first thing you’ll notice aboutVisual Basic .NET and the .NETPlatform: An Advanced Guide is itssize. At approximately a thousandpages, I knew this wasn’t going to bea book I could finish in a round tripbetween Chicago and Seattle – muchless on my way out. However, I alsoimmediately felt that a book <strong>of</strong> thissize could present a serious claim tothe title <strong>of</strong> being “the” book on .NETdevelopment.Well, I wasn’t disappointed. Thismay not be “the” book on .NETdevelopment, but it’s certainly thebook to read if you’ve already doneMicros<strong>of</strong>t development and arenow looking to learn about .NET.I was sold from the moment theauthor, Andrew Troelsen – <strong>of</strong>Intertech-Inc fame – introducedILDASM on page 33. ILDASM is atool that lets you examine the <strong>con</strong>tents<strong>of</strong> any .NET assembly rightdown to the level <strong>of</strong> the individualIL instructions. Any book that’salready talking about this tool onpage 33 has made a <strong>con</strong>scious decisionto dispense with the fluff andget right down to business!Now, it should be noted that thisbook is essentially just a VB.NETtranslation <strong>of</strong> the author’s earlierwork, C# and the .NET Platform. So,if you’ve already read the previousbook, you might not find this booknearly as useful as I did. (We’ll keepour eyes peeled here at .NETDeveloper’s Journal for the perfectbook or books for those <strong>of</strong> you whohave already learned .NET using C#and now want to tackle VB.NET – orvice versa!)Similarly, given my own extensivebackground in Java, I didn’tneed any <strong>of</strong> the in-depth explanationsgiven for object-orienteddevelopment or multithreading.However, for the bulk <strong>of</strong> the readership– who will undoubtedly becoming from a Visual Basic 6 (orearlier) background – I’m sure thismaterial is indispensable. In anyevent, it was all wonderfully writtenand thoroughly explained.Two things that I’m glad thisbook doesn’t cover are XML Webservices and Web applications. Ifully understand that Web servicesare integral to .NET’s entire valueproposition. I also understand thatWeb applications represent one <strong>of</strong>the most stunning applications <strong>of</strong>.NET’s incredible flexible architecture.However, the author gives amore than adequate introduction tothe <strong>con</strong>cept here, so there’s no needto devote any more coverage to it.Micros<strong>of</strong>t’s own documentation andnumerous other works do an excellentjob where this is <strong>con</strong>cerned.For over a thousand pages, thisbook tells you everything you needto know about .NET – without a bit<strong>of</strong> fluff – and that’s quite an accomplishment.I must deduct half a star,however, because I couldn’t locatethe author’s e-mail address anywherein the text or on the cover.26Preview Issue • dot<strong>net</strong>developers<strong>journal</strong>.com


To learn more, visit www.crystaldecisions.com/cr9/003/ and sign up for afree online seminar. To purchase, call 1 888 333 6007, go to our online storeat www.crystaldecisions.com/cr9/021/, or <strong>con</strong>tact your preferred reseller.(c) 2002 Crystal Decisions, Inc. All rights reser ved. Cr ystal Decisions, Cr ystalReports,Crystal Enterprise, Cr ystal Analysis,Crystal Ser vices,Crystal Care, Cr ystal Assist, Crystal Applications, SeagateInfo,Holos and the Crystal Decisions logo aretrademarksorregistered trademarks<strong>of</strong> Cr ystal Decisions, Inc in the U.S. and/or other countries.Allother trademarksreferenced arethe property<strong>of</strong>theirrespective owners.


Your dedicated serverdeserves a dedicatedsupport manager.Steve S.DedicatedSupport ManagerWith Interland Web hosting, dedicated support is always there for you.• NEW dedicated service programIt’s about you. Your business. Your Web site. Your needs. Interland promises to delivercustomer service beyond your expectations. You get your very own dedicated supportmanager, backed by a support team focused on your site and your business. And yourvery own dedicated toll-free phone number means your access to support is fast and easy.• Our best will always be thereTechnical problems rarely <strong>con</strong>fine themselves to regular <strong>of</strong>fice hours. That’s why Interland<strong>of</strong>fers superior technical support 24 hours a day, 7 days a week. Available online or overthe phone, our best support managers are ready to solve your problems. And you getpriority routing to ensure your account receives immediate attention. This incrediblesupport is just one more reason why Interland is the #1 provider in managed dedicatedhosting to small and mid-sized businesses.• Plans start at only $ 129/mo.Regardless <strong>of</strong> your business, we have a dedicated Web hosting plan that will meet yourneeds. You’ll get the bandwidth you need at a price you can afford. Compare our prices,setup fees and customer service to our competitors - you’ll see why Interland is theobvious choice when it comes to choosing a dedicated Web host provider.Web hosting that’s here to stay.Visit interland.com or call us at 1-800-845-8706.*Offer valid through October 15, 2002. Offer is valid only on new Power 200, Power 300, Accelerator 200 and Accelerator 300 plans with a 12-month or longeraccount. Offer is valid on all new TrueAdvantage and Freedom Plans with a 24-month pre-paid account. Free months are added at end <strong>of</strong> full <strong>con</strong>tract accountperiod. Setup fees will apply. Promotional <strong>of</strong>fer valid only for telephone sales. Promotions cannot be combined with any other <strong>of</strong>fers. © 2002 Interland, Inc. Allrights reserved. Not responsible for errors or omissions in typography or photography. Interland is a registered trademark and the Interland design, Power,PowerView, Web Extras, True, TrueAdvantage, TrueBasic, TrueAdvanced, TrueBusiness, Freedom Accelerator, ezSiteStarter and ezSiteBuilder are trademarks <strong>of</strong>Interland, Inc. Micros<strong>of</strong>t is a registered trademark <strong>of</strong> Micros<strong>of</strong>t Corporation. All other product names appearing herein are for identification purposes only andmay be trademarks <strong>of</strong> their respective companies. All orders subject to credit approval, availability and other terms and <strong>con</strong>ditions (including terms <strong>of</strong> serviceand acceptable use policy) available at www.interland.com. Features, functions and pricing subject to change without notice.DEDICATED HOSTINGPLANS START ATONLY $ 129/mo!POWER 200Heightened performanceThis dedicated hosting plan providesthe speed, performance and reliabilityyou need to support high-traffic anddatabase-driven Web sites. Complete withroot access for the <strong>con</strong>trol youneed to self-manage your business.1 GHz CPU speed512 MB installed RAM2x18 GB hard disk storage100 GB monthly transferStarting at just $499.95 per monthBased on 12-month <strong>con</strong>tractIncludes Powerview (remote reboot and event notification), rootaccess to <strong>con</strong>trol your Web site, 24x7 basic monitoring, customersupport and business email. RAID <strong>con</strong>figuration is also available.GET 3 FREEMONTHS OFWEB HOSTINGfor each new Interland account you open.*

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!