Presentation is loading. Please wait.

Presentation is loading. Please wait.

DEV341 Visual Basic: Migrating and Upgrading Lessons Learned Jay Roxe Product Manager Microsoft.

Similar presentations


Presentation on theme: "DEV341 Visual Basic: Migrating and Upgrading Lessons Learned Jay Roxe Product Manager Microsoft."— Presentation transcript:

1 DEV341 Visual Basic: Migrating and Upgrading Lessons Learned Jay Roxe Product Manager Microsoft

2 Agenda Migration Strategy And Pitfalls VB.NET Language Aids VB6 Code Advisor Migration Wizard Amplifying the Application

3 Not Everything Gets Migrated Inventory and evaluate applications Education: Get some VB.NET Experience Target a few small applications Pick Carefully! Evaluate the apps first Migrate one piece at a time Horizontal Slice: UI or Middle Tier Vertical Slice: Bank forms New Application Development

4 Tools help migration VB6 Application VB6 VB6 VB.NET Prepare for upgrade VB6 Code Advisor Upgrade and fix issues Migration Wizard Enhance with new features VB6 VB6 VB6 Replace ADO with ADO.NET Replace ActiveX controls ReflectionWeb-enable Mobile front end Add graphics

5 Micro Issues are 88% Simple to fix. Create “Noise” Five issues represent 88% of all upgrade issues Default properties 52% Property/method not upgraded 13% Property/method different behavior 12% Module methods of COM objects 7% Null/IsNull4%

6 Strongly Typed Variables Visual Basic 6.0 code After upgrade Result: works perfectly Dim myTextBox As TextBox myTextBox = "Hey There" Dim myTextBox As System.Windows.Forms.TextBox myTextBox.Text = "Hey There"

7 Visual Basic 6.0 code After upgrade Result: Runtime error Dim myTextBox myTextBox = "Hey There" Dim myTextBox As Object 'UPGRADE_WARNING: Couldn't resolve default property of object myTextBox. myTextBox = "Hey There" Latebound Variables

8 Choice Of Solutions Solution 1: Prepare in Visual Basic 6.0 Solution 2: Fix after upgrading Dim myTextBox myTextBox = "Hey There" Dim myTextBox As Object 'UPGRADE_WARNING: Couldn't resolve default property of object myTextBox. myTextBox.Text = "Hey There" As TextBox.Text

9 Macro Issues ActiveX Documents DHTML Pages UserControls. Leave in VB6, Navigate to VB.NET StrPtr, ObjPtr, VarPtr Memory pinning Graphics Use GDI+ Deterministic finalization Dispose Use GC methods RDO/DAO data binding Use ADO, ADO.NET TransactionsSystem.EnterpriseServices GoSubProcedures

10 Agenda Migration Strategy And Pitfalls VB.NET Language Aids VB6 Code Advisor Migration Wizard Amplifying the Application

11 Using COM From.NET Runtime Callable Wrapper IFoo IUnknown Common Language Runtime ComServer Client Reference Counted Object

12 Best Practice Use Primary Interop Assemblies Produced by COM API owner May be modified for correctness or managed client friendliness Recognized by Visual Studio.NET Ensure consistent identity for Interop types Visual Studio ships with PIAs C:\Program Files\Microsoft.NET\Primary Interop Assemblies Office 2003 PIAs also available http://msdn.microsoft.com/library/default.asp?url=/downlo ads/list/office.asp http://msdn.microsoft.com/library/default.asp?url=/downlo ads/list/office.asp

13 Exposing Managed APIs to COM Many unmanaged clients/hosts exist Internet Explorer Office Windows shell Every managed object is a COM object Has a class factory Implements IUnknown, IDispatch Type library can be generated using tlbexp.exe (Type Library Exporter) CCW (COM Callable Wrapper) takes care of all this during runtime

14 .NET from COM IFoo IDispatch IUnknown COM Callable Wrapper Server IFoo Common Language Runtime Client COM Client

15 Problems Not all the features of managed objects are exposable to COM Static (shared) methods not exposed Parameterized constructors not exposed Overloaded methods are renamed COM Visibility Types are visible to COM by default; so what? Are they usable from COM by default? Maybe not!.NET Framework Examples System.Math contains only static methods System.Collections.BitArray does not have a default constructor

16 COM Interop

17 VisualBasic.dll Collection Collection Constants ( vbCancel, vbCrLf… Constants ( vbCancel, vbCrLf… ControlChars ( CrLf, Tab,… ControlChars ( CrLf, Tab,… DateAndTime ( DateAdd… DateAndTime ( DateAdd… ErrObject ErrObject FileSystem FileSystem Information ( IsDate, IsDBNull, … Information ( IsDate, IsDBNull, … VBMath VBMath

18 VisualBasic.Compatibility.dll Class DirListBoxEx Inherits Microsoft.VisualBasic.Compatibility.VB6.DirListBox End Class Class DirListBoxEx Inherits Microsoft.VisualBasic.Compatibility.VB6.DirListBox End 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.

19 Agenda Migration Strategy And Pitfalls VB.NET Language Aids VB6 Code Advisor Migration Wizard Amplifying the Application

20 Prepare VB6 code Strongly type variables Null Propagation Non zero lower bound arrays Replace values with Enums Incompatible properties Module methods

21 “Code Advisor” a.k.a “FixIt” Configuration HTML summary Extending the “Code Advisor” Dim prpObj As Property 'FIXIT: Declare 'vTmp' with an early-bound data type FixIT90210ae-R1672-R1B8ZE Dim 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-R1B8ZE Dim vTmp As Variant 'FIXIT: Declare 'vNew' with an early-bound data type FixIT90210ae-R1672-R1B8ZE Dim vNew As Variant Dim frmProp As New frmProperty

22 Preparing VB 6 Projects Visual Basic 6.0 Code Advisor 1.) not upgraded reliably to Visual Basic.NET 11.) The use of is not valid for the property being assigned 2.) project item type is not supported in Visual Basic.NET and will not be upgraded 12.) There is no Line control in Visual Basic.NET 3.) not upgraded to Visual Basic.NET by the Upgrade Wizard 13.) There is no Shape control in Visual Basic.NET 4.) has no Visual Basic.NET equivalent and will not be upgraded 14.) UpDown controls are not upgraded to Visual Basic.NET by the Upgrade Wizard 5.) As Any is not supported in Visual Basic.NET. Use a specific type 15.) Use Option Explicit to avoid implicitly creating variables of type Variant 6.) Changing ScaleMode at run-time is not supported 16.) is not a property of the generic object in Visual Basic.NET. 7.) Replace DAO Data Binding with ADO 17.) Whenever possible replace ActiveForm or ActiveControl with an early-bound variable 8.) Replace function with function 18.) Declare with an early-bound data type 9.) Return has new meaning in Visual Basic.NET 19) Keyword not supported in Visual Basic.Net 10.) The project relies on COM+ transactions that must be upgraded manually 20). Non Zero lowerbound arrays are not supported Issues Identified by the Code Advisor

23 VB6 Code Advisor

24 Agenda Migration Strategy And Pitfalls VB.NET Language Aids VB6 Code Advisor Migration Wizard Amplifying the Application

25 Before Upgrade Wizard Must be able to compile VB6 app Must have design time license files Must have all referenced components (required for Interop assemblies) Should remove unused references, particularly for ActiveX controls

26 Upgrade Wizard EXE & DLL Copies project Creates reports Links to Help Four Levels IssueNo Automatic Upgrade ToDoRequires Finishing WarningPossible Behavior Change NoteInformational

27 Upgrade Wizard Form Layout ActiveX Controls ADO Data Binding Code Syntax Changes COM Libraries RES files Behavior warnings

28 Visual Basic.NET Migration Wizard

29 Agenda Migration Strategy And Pitfalls VB.NET Language Aids VB6 Code Advisor Migration Wizard Amplifying the Application

30 Take Advantage of.NET Replace ADO with ADO.NET Replace ActiveX controls Web-enable Mobile front end Reflection Web services

31 Adding an ASP.NET Front End

32 Looking Forward: VB 2005 Upgrade 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, MaskedEdit RichTextEdit, 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.Resources Upgrade LoadResString, LoadResData, LoadResPicture to use My.Resources

33 Attend a free chat or web cast http://www.microsoft.com/communities/chats/default.mspx http://www.microsoft.com/usa/webcasts/default.asp List of newsgroups http://communities2.microsoft.com/ communities/newsgroups/en-us/default.aspx MS Community Sites http://www.microsoft.com/communities/default.mspx Locate Local User Groups http://www.microsoft.com/communities/usergroups/default.mspx Community sites http://www.microsoft.com/communities/related/default.mspx

34 Q1:Overall satisfaction with the session Q2:Usefulness of the information Q3:Presenter’s knowledge of the subject Q4:Presenter’s presentation skills Q5:Effectiveness of the presentation Please fill out a session evaluation on CommNet

35 © 2004 Microsoft Corporation. All rights reserved. This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.


Download ppt "DEV341 Visual Basic: Migrating and Upgrading Lessons Learned Jay Roxe Product Manager Microsoft."

Similar presentations


Ads by Google