1 / 71

Migration nach VB .NET

Migration nach VB .NET. Jens Häupel Developer Platform & Strategy Group Microsoft Deutschland GmbH jensha@microsoft.com. Agenda. Top News - Was ist IN und was OUT Neuigkeiten, Änderungen Migration Bevor es losgeht Die Umstellung Technologien für den Teilupgrade

arnav
Télécharger la présentation

Migration nach VB .NET

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Migration nach VB .NET Jens Häupel Developer Platform & Strategy Group Microsoft Deutschland GmbH jensha@microsoft.com

  2. Agenda • Top News - Was ist IN und was OUT • Neuigkeiten, Änderungen • Migration • Bevor es losgeht • Die Umstellung • Technologien für den Teilupgrade • Gegenüberstellung VB6 – VB .NET • Performance • Produktivität

  3. VB .NET = VB6 + 1 = VB7? • Neues Konzept, neue Basis • Designed für .NET Framework • CLR, Base Class Library • Modernisierte und aufgeräumte Sprache • Neue Sprachfeatures • Komplett neue Architektur • Komplett objektorientiert Nein!

  4. VB .NET - Top News

  5. Neues aus der IDE • Eine IDE für alle Projekte/Solutions • Web Development • Desktop Development • Mobile Development • Start-Seite bietet Zugriff auf • Projekte • Online-Ressourcen • Server Explorer • SQL Server-Administration • Zugriff auf System-Ressourcen

  6. Neues aus der IDE • Eine IDE für alle .NET-Sprachen • MyProfile • Intelligente Code-Formatierung • Regions • Dynamische Hilfe • Aufgabenbereich • Syntaxfehler • Benutzerdefinierte Kommentare

  7. Neues aus der IDE • Klassenansicht • Floating Windows • XML Schema Designer • Visual Studio Installer • Custom Actions als .NET Code • Benutzerdefinierte Dialoge • Macro Explorer • Integrierter Internet Explorer

  8. Neue Features von VB .NET • Überladung von Funktionen • Verschiedene Signaturen • Überschreiben von Funktionen • Bsp: Ableiten von best. Control • Dock / Anchor - Properties Protected Overrides Sub WndProc(ByRef msg As Message) ' Do something ' Finally: Pass message to default handler: MyBase.WndProc(msg) End Sub

  9. Neue Features von VB .NET • Einfach verbindend: WebServices • ASP.NET – Code Behind Prinzip no more Visual Interdev • GDI+  Visuelle Effekte (Opacity) • Leichtere Lokalisierung • Visueller Menüeditor

  10. Neue Features von VB .NET • Common Type System • Identische Typen für alle Sprachen • Strukturierte Ausnahmebehandlung Try 'execute some code Catch ix As System.IO.FileLoadException 'Handle IO Exception Catch sx As System.Security.SecurityException 'Handle Security Exception Catch ex As System.Exception When Exp=True 'Handle general Exception Finally 'Execute this code always when Try block is being left End Try

  11. Neue Features von VB .NET • Attribute • Multithreading • Völlig neues Objektkonzept • Vererbung • Class Object: Die Mutter aller Objekte • Visual Tab Order Editing

  12. Sprachliche Änderungen • Array-Basis: 0 • Private i, x, y As Integer • i += 1, strName &= “Bob”, etc. • For i As Integer = 0 To 10 • ByRef / ByVal erforderlich • Datentypen • Byte : 8 Bit • Integer : 16 Bit • Long : 32 Bit in VB6 in VB .NET • Byte : 8 Bit • Short : 16 Bit • Integer : 32 Bit • Long : 64 Bit

  13. Ausgediente Controls • Spinner • Line und Shape • DirListBox, FileListBox, DriveListBox • CommonDialog • Image • Frame DomainUpDown, NumericUpDown System.Drawing Namespace OpenFileDialog, SaveFileDialog Color-, Font-, PageSetup-, PrintDialog PictureBox GroupBox, Panel

  14. Strengere Typüberprüfung= Knebelung des Programmierers? • Vermeidet Programmierfehler • Erzwingt explizite Konvertierung • Implizite Konvertierung Dim d1 As Double Dim s1 As String s1 = "12,3" d1 = s1 12,3 oder 123 ? Option Strict On

  15. Namespaces • Gruppieren verwandte Objekte • FileIO, Security, WinForms, … • Voll qualifizierte Namen für Objekte • MyGraphicLib.Drawing.Penvs.AnotherPersonsGraphicLib. Drawing.Pen • Vermeiden Namenskonflikte • Import von Namespaces • Imports System.IO

  16. Migration nach .NET-Bevor es losgeht

  17. Vorüberlegungen • Alles umstellen, teilweise oder gar nicht • Modular oder monolithisch? • Größe der Projekte • Abgeschlossen oder in ständiger Weiterentwicklung • Art der Projekte • Verwendete Technologien und Sprachelemente • Codequalität

  18. Auswahl / Bewertung • Welche Vorteile bringt die Umstellung? • Standardisierung auf einer Plattform • Skalierbarkeit • Verbesserung der Architektur • Einfachere Weiterentwicklung • Bessere Interoperabilität mit anderen Sprachen • Neue Features, bessere Leistung • Aufwand bewerten • Schritte planen

  19. Upgrade Überlegungen • Nicht-upgradebare Technologien

  20. Wie herangehen? • Aufspalten in Teilprojekte • COM Komponenten weiter verwenden COM Interop • Abhängigkeitshierarchie(Client  Middle Tier  Server) COM Interop COM .NET Server COM Interop COM .NET Middle Tier .NET Client .NET .NET

  21. Migration: Vorbereitung • Code vor dem Konvertieren analysieren • Alte Konstrukte beseitigen • DefInt, DefStr, Def*… • GoTo, GoSub .. Return • VarPtr, ObjPtr, StrPtr, Lset • Option Base <> 0 • Strings fester Länge • Implizite Deklaration Private Sub Test() Variable1 = "Test" Variable1 = Varialbe1 & "-Lauf" Debug.Print Variable1 End Function

  22. Migration: Vorbereitung • Alte Konstrukte beseitigen • Implizite Typkonvertierung • Late Binding • Werte für Konstanten • Variants Me.MouseCursor = 3 Private Function Test(x, y) Test = x + y End Function

  23. Migration: Vorbereitung • Implizite Erstellung von Instanzen Dim c as MathLib.MyClass Set c = New MathLib.MyClass c.CallAMethod Set c = Nothing c.CallAMethod VB6 ' RunTime Error Dim c as New MathLib.MyClass c.CallAMethod Set c = Nothing c.CallAMethod VB6 ' will execute

  24. VB6 Code Advisor • Migrationsanalyse in VB6 • Download URL:http://www.microsoft.com/downloads/details.aspx?familyid=A656371A-B5C0-4D40-B015-0CAA02634FAE&displaylang=en

  25. Migration nach .NET-Die Umstellung

  26. VB .NET Upgrade Wizard • VB6 und VB .NET installiert • Ebenso: verwendete Controls • Keine gegen-seitigeBeeinflussung

  27. VB .NET Upgrade Wizard • Es ist Ihr Code! • Struktur bleibt erhalten • Kommentare ebenso • Microsoft.VisualBasic.Compatibility Prinzipien

  28. VB .NET Upgrade Wizard

  29. Nach dem Auto-Upgrade • UpgradeReport.htm • Inline Kommentare • Log File • UpgradeSupport.VB • Referenzen • Alte COM Controls • TypeLibraries • Microsoft.VisualBasic.Compatibility

  30. UpgradeReport

  31. Code-Änderungen • Kommentare im Code • UPGRADE_ISSUE • UPGRADE_TODO • UPGRADE_WARNING • UPGRADE_NOTE

  32. UpgradeSupport.vb • Friend-Objekte • DAO, RDO, …

  33. Upgrade Sample Demo: Upgrade eines VB6-Programmes

  34. Endziele • Verzichten auf die Compatibility Lib • .NET Befehle verwenden • Keine ActiveX Controls • .NET Controls einsetzen • Keine Win32 APIs • .NET Klassen verwenden

  35. Code Snippet Tool • Visual Studio .NET IDE Tool • Teilupgrade per Snippet • Cut & Paste • Type Code

  36. Technologien für den Teilupgrade

  37. IUnknown IDispatch .NET object .NET object IUnknown CCW COM object IDispatch COM object RCW Hello COM - .NET is calling • COM Components in .NET • .NET Components in COM

  38. COM in .NET • Runtime Callable Wrapper (RCW) • Erzeugen / Binden an COM Objekt • Bedient COM Interfaces und übernimmt Transformation in managed Code • Data Marshaling • Lifetime Managment des COM Objekts • COM HRESULT  .NET Exceptions • Beachten Sie • Datentypen (variants, ...) • Primary Interop Assemblies (PIA) • Deployment

  39. .NET in COM • COM Callable Wrapper (CCW) • Erzeugen / Binden an managed Objekt • Simuliert COM interfaces (IUnknown and IDispatch) • Data Marshaling • Lifetime Managment der .NET Komponente • .NET Exception  COM HRESULT • Beachten Sie • Datentypen (Variants, ...) • Default constructor • Deployment

  40. A.ocx AxInterop.AxA.DLL Windows Form Interop.AxA.DLL • COM Interop • Translation • Extended properties Upgrade von ActiveX Controls • Einige Controls werden nicht supported • Einige Controls wurden ersetzt in .NET • Alle anderen per Wrapper-Klassen

  41. VB6 - VB .NET-Gegenüberstellung

  42. Eventhandling in VB6 • Ein Eventhandler für jedes Objekt

  43. Eventhandling in VB .NET • Eine Routine behandelt mehrere gleiche Events • Handles-Klausel • Signatur

  44. Menüs in VB .NET • Wysiwyg Menü-Editor • Eventhandler Private Sub OnClickHandler(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles mnuProp.Click End Sub

  45. Context-Menüs in VB .NET • Anzeigen des Menüs • Eventhandler Private Sub MouseUpHandler(ByVal sender As Object, _ ByVal e As System.Windows.Forms.MouseEventArgs) _ Handles MyBase.MouseUp If e.Button = MouseButtons.Right Then ContextMenu1.Show(Me, New Drawing.Point(e.X, e.Y)) End If End Sub Private Sub MenuOnClickHandler(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles mnuSendMail.Click Dim mnuItem As MenuItem = DirectCast(sender, MenuItem) ' Do something End Sub

  46. File IO in VB6 4,2 s für 1000 Durchläufe

  47. .NET-Methode Traditionelle VB-Methode File IO in VB .NET 2,6 s 1,3 s für 1000 Durchläufe

  48. Drag & Drop Target Control Source Control DragEnter e.Effect DragDrop e.Data.GetData() MouseDown DoDragDrop() DragDropResult

  49. Drag & Drop Demo: Drag & Drop eines Bitmap

  50. Drucken in VB.NET Globales Printer Object wird ersetzt durch: • PrintDocument • PrintDialog • PrintPreview • (sichtbar) • PrintPreviewDialog MSDN: .NET Framework QuickStarts  .NET Samples - Windows Forms: Printing

More Related