Migration nach VB .NET Jens Häupel Developer Platform & Strategy Group Microsoft Deutschland GmbH [email protected].

Download Report

Transcript Migration nach VB .NET Jens Häupel Developer Platform & Strategy Group Microsoft Deutschland GmbH [email protected].

Migration nach VB .NET

Jens Häupel Developer Platform & Strategy Group Microsoft Deutschland GmbH [email protected]

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

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

VB .NET - Top News

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

Neues aus der IDE

     

Eine IDE für alle .NET-Sprachen MyProfile Intelligente Code-Formatierung Regions Dynamische Hilfe Aufgabenbereich

Syntaxfehler

Benutzerdefinierte Kommentare

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

Neue Features von VB .NET

 

Überladung von Funktionen

Verschiedene Signaturen Überschreiben von Funktionen

Bsp: Ableiten von best. Control

Protected Overrides Sub WndProc(ByRef msg As Message) ' Do something ' Finally: Pass message to default handler: MyBase.WndProc(msg) End Sub 

Dock / Anchor - Properties

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

Neue Features von VB .NET

 

Common Type System

Identische Typen für alle Sprachen Strukturierte Ausnahmebehandlung Try 'execute some code Catch Catch Catch ix sx ex As As As System.IO.FileLoadException

'Handle IO Exception System.Security.SecurityException

'Handle Security Exception System.Exception When Exp=True 'Handle general Exception Finally 'Execute this code always when Try block is being left End Try

Neue Features von VB .NET

    

Attribute Multithreading Völlig neues Objektkonzept Vererbung

Class Object: Die Mutter aller Objekte Visual Tab Order Editing

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

Long : 64 Bit

Ausgediente Controls

Spinner

Line und Shape

DirListBox, FileListBox, DriveListBox

CommonDialog

Image

Frame

Strengere Typüberprüfung

= Knebelung des Programmierers?

Implizite Konvertierung Dim d1 As Double Dim s1 As String s1 = "12,3" d1 = s1 12,3 oder 123 ?

Option Strict On

 

Vermeidet Programmierfehler Erzwingt explizite Konvertierung

Namespaces

  

Gruppieren verwandte Objekte

FileIO, Security, WinForms, … Voll qualifizierte Namen für Objekte

MyGraphicLib.Drawing.Pen

vs.

AnotherPersonsGraphicLib. Drawing.Pen

Vermeiden Namenskonflikte Import von Namespaces

Imports System.IO

Migration nach .NET

Bevor es losgeht

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

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

Upgrade Überlegungen

Nicht-upgradebare Technologien Technologie Visual Basic 6.0 drawing model DAO and RDO data binding Dynamic Data Exchange (DDE) OLE Container Control Visual Basic 5.0 controls DHTML Applications Microsoft ® ActiveX ® Property pages UserControls WebClasses Empfehlung In VB6 belassen oder in GDI+ neu Update nach ADO oder ADO.NET

In VB6 belassen oder alternate Methode verwenden In VB6 belassen Upgrade nach Visual Basic 6.0 bzw. Danach nach Visual Basic .NET

Leave; can work with .NET

Arbeitet über COM interop mit .NET

In VB6 belassen In VB6 belassen - can work with .NET

In VB6 belassen - can work with .NET

Wie herangehen?

  

Aufspalten in Teilprojekte COM Komponenten weiter verwenden

COM Interop Abhängigkeitshierarchie (Client

Middle Tier

Server) Client .NET

Middle Tier .NET

Server .NET

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

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

Migration: Vorbereitung

Implizite Erstellung von Instanzen Dim c as MathLib.MyClass

Set c = New MathLib.MyClass

c.CallAMethod

Set c = Nothing c.CallAMethod

' RunTime Error Dim c as New MathLib.MyClass

c.CallAMethod

Set c = Nothing c.CallAMethod

' will execute

VB6 Code Advisor

Migrationsanalyse in VB6

Download URL: http://www.microsoft.com/downloads/details.aspx?familyid=A656371A-B5C0 4D40-B015-0CAA02634FAE&displaylang=en

Migration nach .NET

Die Umstellung

VB .NET Upgrade Wizard

  

VB6 und VB .NET installiert Ebenso: verwendete Controls Keine gegen seitige Beeinflussung

VB .NET Upgrade Wizard

Prinzipien

Es ist Ihr Code!

Struktur bleibt erhalten

Kommentare ebenso

Microsoft.VisualBasic.Compatibility

VB .NET Upgrade Wizard

Nach dem Auto-Upgrade

    

UpgradeReport.htm

Inline Kommentare Log File UpgradeSupport.VB

Referenzen

Alte COM Controls

 

TypeLibraries Microsoft.VisualBasic.Compatibility

UpgradeReport

Code Änderungen

Kommentare im Code

UPGRADE_ISSUE

UPGRADE_TODO

UPGRADE_WARNING

UPGRADE_NOTE

UpgradeSupport.vb

Friend-Objekte

DAO, RDO, …

Upgrade Sample

Demo: Upgrade eines VB6-Programmes

Endziele

  

Verzichten auf die Compatibility Lib

.NET Befehle verwenden Keine ActiveX Controls

.NET Controls einsetzen Keine Win32 APIs

.NET Klassen verwenden

Code Snippet Tool

 

Visual Studio .NET IDE Tool Teilupgrade per Snippet

Cut & Paste

Type Code

Technologien für den Teilupgrade

Hello COM - .NET is calling

COM Components in .NET

COM object IUnknown IDispatch RCW

.NET Components in COM IUnknown IDispatch COM object CCW .NET object .NET object

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

.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

Upgrade von ActiveX Controls

Einige Controls werden nicht supported

Einige Controls wurden ersetzt in .NET

Alle anderen per Wrapper-Klassen A.ocx

Interop.AxA.

DLL AxInterop.AxA

.DLL

• •

COM Interop Translation

Extended properties Windows Form

VB6 - VB .NET

Gegenüberstellung

Eventhandling in

VB6

Ein Eventhandler für jedes Objekt

Eventhandling in

VB .NET

  

Eine Routine behandelt mehrere gleiche Events Handles-Klausel Signatur

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

Context Menüs in VB .NET

Anzeigen des Menüs 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

Eventhandler 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

File IO in VB6

4,2 s für 1000 Durchläufe

File IO in VB .NET

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

Drag & Drop

Source Control Target Control DragEnter e.Effect

DragDrop e.Data.GetData() MouseDown DoDragDrop() DragDropResult

Drag & Drop

Demo: Drag & Drop eines Bitmap

Drucken in VB.NET

Globales Printer Object wird ersetzt durch:

PrintDocument

PrintDialog

PrintPreview

(sichtbar)

PrintPreviewDialog MSDN: .NET Framework QuickStarts .NET Samples - Windows Forms: Printing

Drucken: Prinzip

PrintPage Event:

Win32 APIs bzw. Pinvoke

Aufruf von unmanaged System Code

Win32 APIs in VB6

Pinvoke in VB .NET

Kein 'As Any' Type mehr in .NET !!

PInvoke (advanced)

Attribute spezifizieren genauer

Win32 API

   

.NET Framework bieten Win32 API Funktionalität Leichter nutzbar als Win32 API Framework Class Library Beispiele

System.Diagnostics

System.Drawing

System.Environment

System.Win32

u.a.

ADO versus ADO.NET

ADO

    

ActiveX Data Objects Vielzahl von Datenquellen Connected und disconnected XML Support enthalten COM-basierend ADO.NET

    

Native .NET Komponente Vielzahl von Datenquellen Entwickelt für ver bindungslosen Zugriff Von vorn herein für XML entwickelt .NET-basierend

ADO versus ADO.NET

Demo: Migration von ADO-Projekten

Angebot

 

VB Resource Kit (im Web) Special Offer: VB Res Kit + VS .NET Trial Version

 

60 Tage testen Sample Apps: WinForms, Web, Data Access, WebServices

 

ComponentOne Studio Enterprise Free & Trial Components

 

Tech. Infos zum Upgrade nach VB .NET

Tools

Ressourcen

Ressourcen

   

VB @ MSDN http://msdn.microsoft.com/vbasic http://www.microsoft.com/germany/msdn/default.mspx

GotDotNet: The Microsoft .NET Framework Community http://www.gotdotnet.com

Bücher: http://www.microsoft.com/germany/ms/mspressnet/index.htm

http://www.microsoft.com/mspress/books/index/6510.asp

http://www.dotnetbooks.com/ http://www.kofler.cc/vbnet.html

http://www.amazon.de/exec/obidos/search-handle form/ref=sr_sp_go_as/028-7168974-2906165 Community http://www.microsoft.com/germany/ms/msdncommunity/ Newsgroups auf msnews.microsoft.com

For More Information…

   

101 Visual Basic Code Samples

msdn.microsoft.com/vbasic/downloads/samples/ For Windows developers

windowsforms.net

(TaskVision) For Web developers

www.asp.net

(ASP.NET Starter Kits)

   

Time Tracker Reporting eCommerce (IBuySpy store) Portal (IBuySpy portal) Community Upgrading

msdn.microsoft.com/vbasic/techinfo/articles/ upgrade/

MSDN

Essential Resources for Developers Subscription Services Online Information Training and Events Print Publications Membership Programs Library, OS, Professional, Enterprise, Universal Delivered via CD-ROM, DVD, Web MSDN Online, MSDN Flash, How-to Resources, Download Center MSDN Webcasts, MSDN Online Seminars, Tech·Ed, PDC, Developer Days MSDN Magazine MSDN News MSDN User Groups

How-to Resources

Simple, Step-by-Step Procedures

            

Embedded development How-to resources General How-to resources Integration How-to resources JScript .NET How-to resources Microsoft .NET development How-to resources Office development resources Security How-to resources Microsoft Visual Basic .NET How-to resources Microsoft Visual C# .NET How-to resources Microsoft Visual Studio .NET How-to resources Web development How-to resources (ASP, IIS, XML) Web services How-to resources Windows development How-to resources http://msdn.microsoft.com/howto

MSDN Webcasts

Interactive, Live Online Events

   

Interactive, synchronous, live online events Discuss the hottest topics from Microsoft Open and free for the general public Take place every Tuesday http://www.microsoft.com/usa/webcasts

MSDN Subscriptions

The Way to Get Visual Studio .NET

Visual Studio .NET

• • •

Enterprise Architect Software and data modeling Enterprise templates Architectural guidance

• • •

Enterprise Developer Enterprise lifecycle tools Team development support Windows Server 2003 and SQL Server™

Professional Tools to build applications and XML Web services for Windows and the Web MSDN Subscriptions MSDN Universal MSDN Enterprise MSDN Professional

Where Can I Get MSDN?

    

Visit MSDN Online at msdn.microsoft.com

Register for the MSDN Flash e-mail newsletter at msdn.microsoft.com/flash Become an MSDN CD subscriber at msdn.microsoft.com/subscriptions MSDN online seminars msdn.microsoft.com/training/seminars Attend more MSDN events

Microsoft Press

® Essential Resources for Developers Microsoft Visual Studio .NET is here!

This is your chance to start building the next big thing. Develop your .NET skills, increase your productivity with .NET books from Microsoft Press

www.microsoft.com/mspress

Microsoft Certified Solution Developer

  

What is MCSD?

Premium certification for professionals who design and develop custom business solutions How do I attain MCSD certification?

Certification requires passing four exams to prove competency with Microsoft solution architecture, desktop applications, distributed application development, and development tools Where do I get more information?

For more information about certification requirements, exams, and training options, visit www.microsoft.com/mcp

Training

Training Resources for Developers

Course Title:

Course Number: Application Upgrade and Interoperability with Visual Studio.NET

Availability: 2571

Detailed Syllabus: www.microsoft.com/traincert To locate a training provider for this course, please access www.microsoft.com/traincert Microsoft Certified Technical Education Centers are Microsoft’s premier partners for training services

Basics of Visual Basic .NET

.NET Framework and Tools Visual Basic C++ C# Microsoft ® Visual J# ® Common Language Specification … ASP .NET

Web Forms Web Services Mobile Internet Toolkit

ADO .NET and XML Windows Forms Base Class Library Common Language Runtime Operating System

© 2003 Microsoft Corporation. All rights reserved.

This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.

Microsoft, MSDN, Visual Basic, Windows, Visual J#, Visual Studio, Visual C#, Visual C++, IntelliSense, ActiveX, JScript, and Microsoft Press are either registered trademarks or trademarks of Microsoft Corporation in the United States and/or other countries. The names of actual companies and products mentioned herein may be the trademarks of their respective owners.