PART I INTRODUCTION TO UPGRADING\r\n\r\n1 Visual Basic .NET Is More Than Visual Basic 6 + 1 3\r\n\r\nWhy Break Compatibility? 6\r\nAdding New Features 6\r\nFixing the Language 7\r\nModernizing the Language 8\r\nIt Is Still Visual Basic 8\r\nExpect Subtle Differences 8\r\nPlan for a 95 Percent Automated Upgrade 9\r\nWhy Should I Upgrade? 10\r\nNew Language Features 10\r\nWindows Forms 14\r\nNew Web Development Features 15\r\nBetter Development Environment 15\r\nIs Visual Basic Still the Best Choice for Visual Basic Developers? 16\r\nConclusion 18\r\n\r\n2 Visual Basic 6 and Visual Basic .Net: Differences 19\r\n\r\n.NET Framework vs. ActiveX 19\r\n.NET Framework 21\r\nMemory Management 22\r\nType Identity 25\r\nThreading Model 29\r\nDifferences in the Development Environment 29\r\nMenu Editor 30\r\nToolbox 31\r\nProperty Browser 32\r\nTab Layout Editor 33\r\nForms Packages 34\r\nA Single Standard for Windows Forms 34\r\nTwo Forms Packages for the Price of One 35\r\nLanguage Differences 35\r\nAll Subroutine Calls Must Have Parentheses 37\r\nByVal or ByRef Is Required 38\r\nIs That My Event? 38\r\nArrays Must Have a Zero-Bound Lower Dimension 39\r\nFixed-Length Strings Are Not Supported 40\r\nVariant Data Type Is Eliminated 40\r\nVisibility of Variables Declared in Nested Scopes Is Limited 41\r\nChanges in the Debugger 42\r\nNo Edit and Continue 42\r\nCannot Continue After an Error 42\r\nNo Repainting in Break Mode 42\r\nConclusion 43\r\n\r\n3 Upgrading Options 45\r\n\r\nUpgrading Is Optional 45\r\nDon’t Upgrade 45\r\nPartial Upgrade 46\r\nComplete Upgrade 47\r\nUpgrade with Interoperability 47\r\nRole of the Upgrade Wizard 48\r\nThe Upgrade Report 48\r\nTesting 49\r\nUpgrading from Earlier Versions of Visual Basic 49\r\nSelecting Projects to Upgrade 50\r\nEvaluating the Benefits 51\r\nEvaluating the Effort Required 55\r\nDeveloping the Upgrade Plan 58\r\nConclusion 59\r\n\r\n4 Preparing Your Project for the Upgrade to Visual Basic .NET 61\r\n\r\nWhy Change Anything? 61\r\nCleaning Up Legacy Code 62\r\nVarPtr, DefInt, and Other No-Shows 62\r\nDAO and RDO Data Binding 63\r\nGood Visual Basic 6 Coding Practices 64\r\nVariants and Variables 64\r\nAbstraction 66\r\nEarly Binding vs. Late Binding vs. Soft Binding 69\r\nWatch Out for Null and Empty 73\r\nImplicit Object Instantiation 74\r\nConclusion 76\r\n\r\nPART II UPGRADING APPLICATIONS\r\n\r\n5 Your First Upgrade 79\r\n\r\nUpgrade Walkthrough 79\r\nWhat Just Happened? 85\r\nLanguage Changes 88\r\nOther Files in Your Project 92\r\nUpgrading Project Groups 94\r\nUsing the VB Snippet Upgrade Add-In 98\r\nUpgrading Using the Command Line 99\r\nConclusion 100\r\n\r\n6 Common Tasks in Visual Basic .NET 101\r\n\r\nA Guide to Working in Visual Basic .NET 101\r\nCreating a Visual Basic .NET Project 102\r\nGetting to Know the Visual Studio .NET IDE 104\r\nRunning Your Project 106\r\nA Quick Introduction to Debugging 107\r\nMiscellaneous Items 108\r\nHandling Build Errors 108\r\nUsing the Task List 109\r\nUsing Breakpoints 110\r\nReferences 111\r\nProblem-Solving Techniques 112\r\nUsing the System.Diagnostics Library 112\r\nUsing CorDbg 113\r\nSimplifying Complex Expressions 114\r\nConclusion 115\r\n\r\n7 Upgrade Wizard Ins and Outs 117\r\n\r\nUpgrade Philosophy 117\r\nIt’s Your Code 117\r\nJust Make It Work 118\r\nCompatibility Library 119\r\nUpgrade Wizard Capabilities and Limitations 119\r\nWizard Methodology 119\r\nProject Upgrade 121\r\nForms and Intrinsic Controls 128\r\nActiveX Controls and ActiveX References 137\r\nVisual Basic Code 140\r\nGlobal Objects 145\r\nClass Modules and User Controls 145\r\nObjects for Accessing Data 146\r\nDesigners 147\r\nConclusion 148\r\n\r\n8 Errors, Warnings, and Issues 149\r\n\r\nThe Different Kinds of EWIs 152\r\nUpgrade Issues 152\r\nUpgrade ToDos 153\r\nRun-Time Warnings 154\r\nDesign Issues 154\r\nUpgrade Notes and Global Warnings 155\r\nUnderstanding the Upgrade Report 155\r\nEstimating Fix Time 157\r\nWorking with EWIs 159\r\nThe Different Upgrade EWIs 160\r\nUpgrade Issues 160\r\nUpgrade ToDos 163\r\nUpgrade Warnings 164\r\nDesign Errors 167\r\nGlobal Warnings 169\r\nUpgrade Notes 170\r\nWhich Problems Are Not Detected? 172\r\nConclusion 174\r\n\r\n9 Using Visual Basic 6 with Visual Basic .NET: COM Interop 175\r\n\r\nWhere COM Interop Comes into Play 177\r\nActiveX Controls 177\r\nCommunication Between a .NET Client and a COM Server Component 177\r\nCommunication Between a COM Client and a .NET Server Component 178\r\nUpgrading a Visual Basic 6 Client/Server Application 178\r\nCreating a .NET Client That Talks to a COM Server 180\r\nDebugging Between the Visual Basic .NET Client and Visual Basic 6 Server 182\r\nExposing a Visual Basic .NET Component to Be Called by a Visual Basic 6 Client 184\r\nDebugging Between the Visual Basic 6 Client and .NET Server 187\r\nTying It All Together 188\r\nReplacing COM with .NET: Binary Compatibility 189\r\nIndirect Replacement Model 190\r\nEnabling Binary Compatibility in Visual Basic .NET Classes 191\r\nConclusion 196\r\n\r\nPART III GETTING YOUR PROJECT WORKING\r\n\r\n10 Ten Common Upgrade Problems 199\r\n\r\nDefault Properties 199\r\nAddItem and ToString with COM Objects 201\r\nDeterministic Finalization and Garbage Collection 203\r\nBringing a Little Determinism to the Party 205\r\nGeneric Objects (Control/Form/Screen) 206\r\nDim…As New 207\r\nSub Main (or Default Form) 208\r\nFont Disparities 209\r\nBad Constants 212\r\nDrag and Drop 213\r\nDrag and Drop in Visual Basic 6 213\r\nDrag and Drop in Visual Basic .NET 215\r\nCollection Classes 219\r\nConclusion 222\r\n\r\n11 Resolving Issues with Language 223\r\n\r\nLanguage Elements 224\r\n#If…#End If Precompiler Statements 224\r\nConstants and Constant Expressions 224\r\nControl Flow 227\r\nFile Functions 232\r\nTypes and Type Operations 238\r\nObject Replaces Variant 238\r\nArrays 242\r\nStructures 245\r\nMaking Your Code Thread-Safe 249\r\nWindows API 251\r\nType Changes 252\r\nAs Any No Longer Supported 253\r\nAddressOf Changes 254\r\nPassing User-Defined Types to API Functions 258\r\nObjPtr and StrPtr Not Supported 261\r\nConclusion 263\r\n\r\n12 Resolving Issues with Forms 265\r\n\r\nSimilarities in Form Structure 265\r\nGeneral Issues 267\r\nDifferences in Properties, Methods, and Events 267\r\nTechnology Differences 269\r\nIssues Involving Forms 274\r\nEvent Firing Differences 274\r\nThe Default Form: DefInstance 277\r\nApplication Lifetime and Forms 278\r\nMDI Forms 282\r\nConclusion 283\r\n\r\n13 Upgrading ActiveX Controls and Components 285\r\n\r\nActiveX Controls Are Still Supported—Yes! 285\r\nActiveX Upgrade Strategy 286\r\nLimitations of ActiveX Control Hosting 286\r\nActiveX .NET Controls: Best of Both Worlds 289\r\nActiveX Interop Ax Wrapper: The Windows Forms Wrapper 289\r\nProperty and Parameter Type Mappings 290\r\nStandard Component Wrappers and ActiveX Control Subobjects 293\r\nCommon Exceptions That Require Type Conversions 295\r\nName Collisions 297\r\nEvent Name Collisions 297\r\nUsing ActiveX Components from .NET 298\r\nWhen ByRef Bites 298\r\nWhen a Collection Is Not a Collection 299\r\nNonzero-Bound Arrays 301\r\nAlias Types Are Not Supported 301\r\nModule Methods Are Not Supported 302\r\nConclusion 303\r\n\r\n14 Resolving Data Access Issues 305\r\n\r\nData Access in Visual Basic 306\r\nCode 306\r\nData Binding 307\r\nADO Data Environment 307\r\nComponents That Don’t Upgrade 308\r\nADO.NET Is the Future 309\r\nGeneral Issues with Data Access Code 309\r\nDAO and RDO Module Methods 309\r\nADO Version 2.7 311\r\nErrors in Events 311\r\nRDO Connection 313\r\nNull, vbNullString, and vbNullChar 314\r\nADO Data Environment 315\r\nCalling Dispose 315\r\nInitialize Event 316\r\nCursor Location with Microsoft Access Databases 316\r\nADO Data Binding 316\r\nControl Arrays of ADO Data Controls 318\r\nSetting Data Binding Properties at Run Time 318\r\nConclusion 321\r\n\r\n15 Problems That Require Redesign 323\r\n\r\nReplacing the OLE Container Control 323\r\nReplacing Painting Functions 328\r\nRewriting Clipboard Code 331\r\nUsing the Controls Collection 333\r\nUsing the Forms Collection 335\r\nUpgrading PrintForm Code 337\r\nReplacing Property Pages 340\r\nEliminating ObjPtr, VarPtr, and StrPtr 343\r\nConclusion 345\r\n\r\n16 Upgrading COM+ Components 347\r\n\r\nCOM+ Application Types 347\r\nUsing COM+ in Visual Basic .NET 348\r\nCOM+ Requirements in Visual Basic .NET 350\r\nInheriting from the ServicedComponent Class 351\r\nWorking with Attributes 352\r\nCreating a Strong Name for Your Assembly 356\r\nRegistering COM+ Applications 358\r\nUpgrading COM+ Components 360\r\nMaking .NET and COM Components Work Together 364\r\nConclusion 364\r\n\r\n17 Upgrading VB Application Wizard Projects 365\r\n\r\nApp.Revision 367\r\nfrmAbout Form 369\r\nfrmLogin Form 370\r\nfrmMain Form 370\r\nAPI Declare Statements 370\r\nmnuHelpAbout_Click Event Procedure 371\r\nApp.HelpFile 371\r\nActiveMdiChild in MDI Projects 372\r\nForms Collection in frmMain_Closed 374\r\nClipboard in MDI Projects 375\r\nfrmSplash Form 376\r\nfrmBrowser Form 378\r\nData Forms 378\r\nModule1 Module 379\r\nLoadResStrings Method 379\r\nConclusion 381\r\n\r\nPART IV TECHNIQUES FOR ADDING VALUE\r\n\r\n18 Adding Value to Your Applications 385\r\n\r\nOverview of the Sample Application 386\r\nNew File Functions 387\r\nReading the Contents of a Directory 387\r\nFinding All the Forms in a DLL 388\r\nLoading Forms Dynamically 389\r\nReading and Writing to Files 389\r\nUsing Dynamic Properties 390\r\nNew Windows Capabilities 392\r\nAccessing the Registry 392\r\nControl Anchoring 394\r\nGraphics Features 394\r\nWindows XP–Style Controls 398\r\nXCopy Deployment 400\r\nConclusion 401\r\n\r\n19 Replacing ActiveX Controls with Windows Forms Controls 403\r\n\r\nBenefits of Upgrading Controls 404\r\n100 Percent .NET Compatibility 404\r\nImproved Versioning 404\r\nSimpler Deployment 405\r\nProcess of Replacing Controls 405\r\nManually Upgrading a Control 406\r\nMappings for Visual Basic 6 ActiveX Controls 412\r\nActiveX Controls vs. Windows Forms Controls 413\r\nConclusion 416\r\n\r\n20 Moving from ADO to ADO.NET 417\r\n\r\nADO.NET for the ADO Programmer 417\r\nOverview of ADO.NET 418\r\nDataSets 419\r\nIntegrating Your ADO Code into a Visual Basic .NET Application 421\r\nBinding Your ADO Recordset to .NET Controls 422\r\nUsing ADO with XML Web Services 423\r\nMapping ADO Objects to ADO.NET 425\r\nConnection and Command Objects 425\r\nRecordsets 427\r\nUsing DataViews 429\r\nData Binding 430\r\nBinding to Windows Forms Controls 430\r\nA Note About Performance 432\r\nConclusion 434\r\n\r\n21 Upgrading Distributed Applications 435\r\n\r\nImportant Concepts for Distributed Applications 436\r\nLoosely Coupled vs. Tightly Coupled Applications 436\r\nOverhead in Method Invocation 437\r\nComponentization and Logical Organization 439\r\nDistributed Technologies in .NET 440\r\nXML Web Services 440\r\nCreating a Simple XML Web Service 441\r\nSupporting Web Services in Your Existing Applications 446\r\nRemoting 452\r\nA Simple Remoting Example 453\r\nArchitecture for Remoting 456\r\nDistributed COM+ Applications 461\r\nCOM+ and Remoting 461\r\nUsing SOAP Services 461\r\nCOM+ Application Proxies in .NET 463\r\nConclusion 464\r\n\r\nPART V APPENDIXES\r\n\r\nAPPENDIX A Object Mapping Reference 467\r\nAPPENDIX B Function Mapping Reference 515\r\n\r\nINDEX
无封面