Upload
raymond-adams
View
216
Download
0
Tags:
Embed Size (px)
Citation preview
DEV341 Visual Basic: Migrating and Upgrading Lessons Learned
DEV341 Visual Basic: Migrating and Upgrading Lessons Learned
Jay RoxeJay RoxeProduct ManagerProduct ManagerMicrosoftMicrosoft
AgendaAgenda
Migration Strategy And PitfallsMigration Strategy And Pitfalls
VB .NET Language AidsVB .NET Language Aids
VB6 Code AdvisorVB6 Code Advisor
Migration WizardMigration Wizard
Amplifying the ApplicationAmplifying the Application
Not Everything Gets MigratedNot Everything Gets Migrated
Inventory and evaluate applicationsInventory and evaluate applications
Education: Get some VB .NET Education: Get some VB .NET ExperienceExperience
Target a few small applicationsTarget a few small applicationsPick Carefully! Evaluate the apps firstPick Carefully! Evaluate the apps first
Migrate one piece at a timeMigrate one piece at a timeHorizontal Slice: UI or Middle TierHorizontal Slice: UI or Middle Tier
Vertical Slice: Bank formsVertical Slice: Bank forms
New Application DevelopmentNew Application Development
Tools help migrationTools help migrationVB6 ApplicationVB6 Application
VB6VB6
VB6VB6
VB.NETVB.NET
Prepare for upgradePrepare for upgrade
VB6 Code AdvisorVB6 Code Advisor
Upgrade and fix issuesUpgrade and fix issues
Migration WizardMigration Wizard
Enhance Enhance with new with new featuresfeatures
VB6VB6
VB6VB6VB6VB6
Micro Issues are 88%Micro Issues are 88%Simple to fix. Simple to fix.
Create “Noise”Create “Noise”
Five issues represent 88% of all upgrade Five issues represent 88% of all upgrade issuesissues
Default propertiesDefault properties 52%52%
Property/method not upgradedProperty/method not upgraded 13%13%
Property/method different behaviorProperty/method different behavior 12%12%
Module methods of COM objectsModule methods of COM objects 7%7%
Null/IsNullNull/IsNull 4%4%
Strongly Typed VariablesStrongly Typed Variables
Visual Basic 6.0 codeVisual Basic 6.0 code
After upgradeAfter upgrade
Result: works perfectlyResult: works perfectly
Dim myTextBox As TextBoxmyTextBox = "Hey There"
Dim myTextBox As System.Windows.Forms.TextBoxmyTextBox.Text = "Hey There"
Visual Basic 6.0 codeVisual Basic 6.0 code
After upgradeAfter upgrade
Result: Runtime errorResult: Runtime error
Dim myTextBoxmyTextBox = "Hey There"
Dim myTextBox As Object'UPGRADE_WARNING: Couldn't resolve default property of object myTextBox. myTextBox = "Hey There"
Latebound VariablesLatebound Variables
Choice Of SolutionsChoice Of Solutions
Solution 1: Prepare in Visual Basic 6.0Solution 1: Prepare in Visual Basic 6.0
Solution 2: Fix after upgradingSolution 2: Fix after upgrading
Dim myTextBoxmyTextBox = "Hey There"
Dim myTextBox As Object'UPGRADE_WARNING: Couldn't resolve default property of object myTextBox. myTextBox.Text = "Hey There"
As TextBox
.Text
Macro IssuesMacro IssuesActiveX DocumentsActiveX Documents
DHTML PagesDHTML Pages
UserControls. Leave in VB6, UserControls. Leave in VB6, Navigate to VB.NETNavigate to VB.NET
StrPtr, ObjPtr, VarPtrStrPtr, ObjPtr, VarPtr Memory pinningMemory pinning
GraphicsGraphics Use GDI+Use GDI+
Deterministic finalizationDeterministic finalization DisposeDispose
Use GC methodsUse GC methods
RDO/DAO data bindingRDO/DAO data binding Use ADO, ADO.NETUse ADO, ADO.NET
TransactionsTransactions System.EnterpriseServicesSystem.EnterpriseServices
GoSubGoSub ProceduresProcedures
AgendaAgenda
Migration Strategy And PitfallsMigration Strategy And Pitfalls
VB .NET Language AidsVB .NET Language Aids
VB6 Code AdvisorVB6 Code Advisor
Migration WizardMigration Wizard
Amplifying the ApplicationAmplifying the Application
Using COM From .NETUsing COM From .NET
Runtime CallableRuntime CallableWrapperWrapper
IFooIFoo
IUnknownIUnknown Common Language Common Language RuntimeRuntime
ComServerComServer
ClientClient
ReferenceCounted
ObjectObject
Best PracticeBest Practice
Use Primary Interop AssembliesUse Primary Interop AssembliesProduced by COM API ownerProduced by COM API owner
May be modified for correctness or managed client May be modified for correctness or managed client friendlinessfriendliness
Recognized by Visual Studio.NET Recognized by Visual Studio.NET
Ensure consistent identity for Interop typesEnsure consistent identity for Interop types
Visual Studio ships with PIAsVisual Studio ships with PIAsC:\Program Files\Microsoft.NET\Primary Interop C:\Program Files\Microsoft.NET\Primary Interop AssembliesAssemblies
Office 2003 PIAs also availableOffice 2003 PIAs also availablehttp://http://msdn.microsoft.com/library/default.asp?urlmsdn.microsoft.com/library/default.asp?url=/downloads/list/=/downloads/list/office.aspoffice.asp
Exposing Managed APIs to COMExposing Managed APIs to COM
Many unmanaged clients/hosts existMany unmanaged clients/hosts existInternet ExplorerInternet Explorer
OfficeOffice
Windows shellWindows shell
Every managed object is a COM objectEvery managed object is a COM objectHas a class factoryHas a class factory
Implements IUnknown, IDispatchImplements IUnknown, IDispatch
Type library can be generated using tlbexp.exe Type library can be generated using tlbexp.exe (Type Library Exporter)(Type Library Exporter)
CCW (COM Callable Wrapper) takes care of all this CCW (COM Callable Wrapper) takes care of all this during runtimeduring runtime
.NET from COM.NET from COM
IFooIFoo
IDispatchIDispatch
IUnknownIUnknown
COM COM CallableCallableWrapperWrapper
ServerServer
IFooIFoo
Common Language Common Language RuntimeRuntime
ClientClient
COM ClientCOM Client
ProblemsProblems
Not all the features of managed objects are Not all the features of managed objects are exposable to COMexposable to COM
Static (shared) methods not exposedStatic (shared) methods not exposed
Parameterized constructors not exposedParameterized constructors not exposed
Overloaded methods are renamedOverloaded methods are renamed
COM VisibilityCOM VisibilityTypes are visible to COM by default; so what?Types are visible to COM by default; so what?
Are they usable from COM by default? Maybe not!Are they usable from COM by default? Maybe not!
.NET Framework Examples.NET Framework ExamplesSystem.Math contains only static methodsSystem.Math contains only static methods
System.Collections.BitArray does not have a default System.Collections.BitArray does not have a default constructorconstructor
COM InteropCOM Interop
VisualBasic.dllVisualBasic.dll
CollectionCollection Constants (Constants (vbCancel, vbCrLf…vbCancel, vbCrLf…
ControlChars (ControlChars (CrLf, Tab,…CrLf, Tab,…
DateAndTime (DateAndTime (DateAdd…DateAdd…
ErrObjectErrObject FileSystemFileSystem Information (Information (IsDate, IsDBNull, …IsDate, IsDBNull, …
VBMathVBMath
VisualBasic.Compatibility.dllVisualBasic.Compatibility.dll
Class DirListBoxEx Inherits Microsoft.VisualBasic.Compatibility.VB6.DirListBoxEnd Class
Class DirListBoxEx Inherits Microsoft.VisualBasic.Compatibility.VB6.DirListBoxEnd Class
Caution: Functions in the Visual Basic 6.0 Compatibility library are provided only for use by the upgrading tools. Although it is possible to use this library when writing new code, there is no guarantee that it will be supported in future versions of Visual Basic.
AgendaAgenda
Migration Strategy And PitfallsMigration Strategy And Pitfalls
VB .NET Language AidsVB .NET Language Aids
VB6 Code AdvisorVB6 Code Advisor
Migration WizardMigration Wizard
Amplifying the ApplicationAmplifying the Application
Prepare VB6 codePrepare VB6 code
Strongly type variablesStrongly type variables
Null PropagationNull Propagation
Non zero lower bound arraysNon zero lower bound arrays
Replace values with EnumsReplace values with Enums
Incompatible propertiesIncompatible properties
Module methodsModule methods
“Code Advisor” a.k.a “FixIt”“Code Advisor” a.k.a “FixIt”
ConfigurationConfiguration
HTML summaryHTML summary
Extending theExtending the “Code “Code Advisor”Advisor”
Dim prpObj As Property'FIXIT: Declare 'vTmp' with an early-bound data type FixIT90210ae-R1672-R1B8ZEDim vTmp As Variant'FIXIT: Declare 'vNew' with an early-bound data type FixIT90210ae-R1672-R1B8ZE Dim vNew As Variant Dim frmProp As New frmProperty
Dim prpObj As Property'FIXIT: Declare 'vTmp' with an early-bound data type FixIT90210ae-R1672-R1B8ZEDim vTmp As Variant'FIXIT: Declare 'vNew' with an early-bound data type FixIT90210ae-R1672-R1B8ZE Dim vNew As Variant Dim frmProp As New frmProperty
Preparing VB 6 ProjectsPreparing VB 6 ProjectsVisual Basic 6.0 Code AdvisorVisual Basic 6.0 Code Advisor
1.) <'# condition'> not upgraded reliably to 1.) <'# condition'> not upgraded reliably to Visual Basic .NETVisual Basic .NET
11.) The use of <'enumeration'> is not valid 11.) The use of <'enumeration'> is not valid for the property being assignedfor the property being assigned
2.) <'item'> project item type is not 2.) <'item'> project item type is not supported in Visual Basic .NET and will supported in Visual Basic .NET and will not be upgradednot be upgraded
12.) There is no Line control in Visual 12.) There is no Line control in Visual Basic .NETBasic .NET
3.) <'object'> not upgraded to Visual 3.) <'object'> not upgraded to Visual Basic .NET by the Upgrade WizardBasic .NET by the Upgrade Wizard
13.) There is no Shape control in Visual 13.) There is no Shape control in Visual Basic .NETBasic .NET
4.) <'property / method / event'> has no 4.) <'property / method / event'> has no Visual Basic .NET equivalent and will not Visual Basic .NET equivalent and will not be upgradedbe upgraded
14.) UpDown controls are not upgraded to 14.) UpDown controls are not upgraded to Visual Basic .NET by the Upgrade WizardVisual Basic .NET by the Upgrade Wizard
5.) As Any is not supported in Visual 5.) As Any is not supported in Visual Basic .NET. Use a specific typeBasic .NET. Use a specific type
15.) Use Option Explicit to avoid implicitly 15.) Use Option Explicit to avoid implicitly creating variables of type Variantcreating variables of type Variant
6.) Changing ScaleMode at run-time is not 6.) Changing ScaleMode at run-time is not supportedsupported
16.) <'property'> is not a property of the 16.) <'property'> is not a property of the generic <'object'> object in Visual generic <'object'> object in Visual Basic .NET.Basic .NET.
7.) Replace DAO Data Binding with ADO7.) Replace DAO Data Binding with ADO 17.) Whenever possible replace ActiveForm 17.) Whenever possible replace ActiveForm or ActiveControl with an early-bound or ActiveControl with an early-bound variablevariable
8.) Replace <'variant'> function with 8.) Replace <'variant'> function with <'string'> function<'string'> function
18.) Declare <'variable'> with an early-bound 18.) Declare <'variable'> with an early-bound data typedata type
9.) Return has new meaning in Visual 9.) Return has new meaning in Visual Basic .NETBasic .NET
19) Keyword <'keyword'> not supported in 19) Keyword <'keyword'> not supported in Visual Basic .NetVisual Basic .Net
10.) The project relies on COM+ transactions 10.) The project relies on COM+ transactions that must be upgraded manuallythat must be upgraded manually
20). Non Zero lowerbound arrays are not 20). Non Zero lowerbound arrays are not supportedsupported
Issues Identified by the Code AdvisorIssues Identified by the Code Advisor
VB6 Code AdvisorVB6 Code Advisor
AgendaAgenda
Migration Strategy And PitfallsMigration Strategy And Pitfalls
VB .NET Language AidsVB .NET Language Aids
VB6 Code AdvisorVB6 Code Advisor
Migration WizardMigration Wizard
Amplifying the ApplicationAmplifying the Application
Before Upgrade WizardBefore Upgrade Wizard
MustMust be able to compile VB6 app be able to compile VB6 app
MustMust have design time license files have design time license files
MustMust have all referenced components have all referenced components (required for Interop assemblies)(required for Interop assemblies)
ShouldShould remove unused references, remove unused references, particularly for ActiveX controlsparticularly for ActiveX controls
Upgrade WizardUpgrade Wizard
EXE & DLLEXE & DLL
Copies projectCopies project
Creates reportsCreates reports
Links to HelpLinks to Help
Four LevelsFour LevelsIssueIssue No Automatic UpgradeNo Automatic UpgradeToDoToDo Requires Finishing Requires Finishing WarningWarning Possible Behavior ChangePossible Behavior ChangeNoteNote InformationalInformational
Upgrade WizardUpgrade WizardForm LayoutForm Layout
ActiveX ControlsActiveX Controls
ADO Data BindingADO Data Binding
CodeCode
Syntax ChangesSyntax Changes
COM LibrariesCOM Libraries
RES filesRES files
Behavior warningsBehavior warnings
Visual Basic .NET Visual Basic .NET Migration WizardMigration Wizard
AgendaAgenda
Migration Strategy And PitfallsMigration Strategy And Pitfalls
VB .NET Language AidsVB .NET Language Aids
VB6 Code AdvisorVB6 Code Advisor
Migration WizardMigration Wizard
Amplifying the ApplicationAmplifying the Application
Take Advantage of .NETTake Advantage of .NET
Replace ADO with ADO .NETReplace ADO with ADO .NET
Replace ActiveX controlsReplace ActiveX controls
Web-enableWeb-enable
Mobile front endMobile front end
ReflectionReflection
Web servicesWeb services
Adding an ASP.NET Adding an ASP.NET Front EndFront End
Looking Forward: VB 2005Looking Forward: VB 2005Upgrade MTS and COM+ projectsUpgrade MTS and COM+ projects• • Upgrade the following controls from VB6 to Windows Forms controls:Upgrade the following controls from VB6 to Windows Forms controls: WebBrowser, Toolbar, ImageList, TreeView, ListView, OleContainer, WebBrowser, Toolbar, ImageList, TreeView, ListView, OleContainer, RichTextEdit, ProgressBar, StatusBar, CommonDialog, MaskedEditRichTextEdit, ProgressBar, StatusBar, CommonDialog, MaskedEdit • • Upgrade code that uses string-based-keys in forms control collections Upgrade code that uses string-based-keys in forms control collections • • Upgrade code that changes the key value in the KeyPress event Upgrade code that changes the key value in the KeyPress event • • Upgrade to the BackgroundImageLayout property Upgrade to the BackgroundImageLayout property • • Upgrade the VB6 App object to the Whidbey My object Upgrade the VB6 App object to the Whidbey My object • • Upgrade Unload Mode Parameter of QueryUnload event to ClosingReason Upgrade Unload Mode Parameter of QueryUnload event to ClosingReason • • Upgrade forms to use the new Partial Type format Upgrade forms to use the new Partial Type format • • Upgrade default instance to use Whidbey's support for default instances Upgrade default instance to use Whidbey's support for default instances • • Upgrade the forms collection to the Whidbey forms collection Upgrade the forms collection to the Whidbey forms collection • • Upgrade VB6 Printers collection object to the My.Computer.Printers object Upgrade VB6 Printers collection object to the My.Computer.Printers object • • Upgrade VB6 clipboard object to the My.Computer.Clipboard Upgrade VB6 clipboard object to the My.Computer.Clipboard • • Upgrade LoadResString, LoadResData, LoadResPicture to use My.ResourcesUpgrade LoadResString, LoadResData, LoadResPicture to use My.Resources
Attend a free chat or web castAttend a free chat or web casthttp://www.microsoft.com/communities/chats/default.mspxhttp://www.microsoft.com/communities/chats/default.mspx http://www.microsoft.com/usa/webcasts/default.asphttp://www.microsoft.com/usa/webcasts/default.asp
List of newsgroupsList of newsgroupshttp://communities2.microsoft.com/http://communities2.microsoft.com/communities/newsgroups/en-us/default.aspxcommunities/newsgroups/en-us/default.aspx
MS Community SitesMS Community Siteshttp://www.microsoft.com/communities/default.mspxhttp://www.microsoft.com/communities/default.mspx
Locate Local User GroupsLocate Local User Groupshttp://www.microsoft.com/communities/usergroups/default.mspxhttp://www.microsoft.com/communities/usergroups/default.mspx
Community sitesCommunity siteshttp://www.microsoft.com/communities/related/default.mspxhttp://www.microsoft.com/communities/related/default.mspx
Q1:Q1: Overall satisfaction with the sessionOverall satisfaction with the session
Q2:Q2: Usefulness of the informationUsefulness of the information
Q3:Q3: Presenter’s knowledge of the subjectPresenter’s knowledge of the subject
Q4:Q4: Presenter’s presentation skillsPresenter’s presentation skills
Q5:Q5: Effectiveness of the presentationEffectiveness of the presentation
Please fill out a session evaluation on CommNetPlease fill out a session evaluation on CommNet
© 2004 Microsoft Corporation. All rights reserved.This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.