COM-Schnittstellen optimal einsetzen Michael Willers [email protected] Microsoft GmbH.
Migration nach VB.NET Jens Häupel Developer Platform & Strategy Group Microsoft Deutschland GmbH...
-
Upload
parsifal-schnider -
Category
Documents
-
view
109 -
download
0
Transcript of Migration nach VB.NET Jens Häupel Developer Platform & Strategy Group Microsoft Deutschland GmbH...
Migration nach VB .NET
Jens Häupel
Developer Platform & Strategy Group
Microsoft Deutschland GmbH
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 .NETPerformance
Produktivität
VB .NET = VB6 + 1 = VB7?
Neues Konzept, neue BasisDesigned für .NET Framework
CLR, Base Class Library
Modernisierte und aufgeräumte SpracheNeue Sprachfeatures
Komplett neue Architektur
Komplett objektorientiert
VB .NET - Top News
Neues aus der IDE
Eine IDE für alle Projekte/SolutionsWeb Development
Desktop Development
Mobile Development
Start-Seite bietet Zugriff aufProjekte
Online-Ressourcen
Server ExplorerSQL 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 FunktionenVerschiedene Signaturen
Überschreiben von FunktionenBsp: 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
Protected Overrides Sub WndProc(ByRef msg As Message) ' Do something ' Finally: Pass message to default handler: MyBase.WndProc(msg) End Sub
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 SystemIdentische 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
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
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
Byte : 8 Bit
Integer : 16 Bit
Long : 32 Bit
Byte : 8 Bit
Short : 16 Bit
Integer : 32 Bit
Long : 64 Bit
in VB6in VB .NET
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
Strengere Typüberprüfung
= Knebelung des Programmierers?
Vermeidet Programmierfehler Erzwingt explizite Konvertierung
Option Strict OnOption Strict On
Implizite Konvertierung
Dim d1 As DoubleDim s1 As Strings1 = "12,3"d1 = s1
Dim d1 As DoubleDim s1 As Strings1 = "12,3"d1 = s1
12,3 oder 123 ?12,3 oder 123 ?
Namespaces
Gruppieren verwandte ObjekteFileIO, Security, WinForms, …
Voll qualifizierte Namen für ObjekteMyGraphicLib.Drawing.Pen
vs.AnotherPersonsGraphicLib. Drawing.Pen
Vermeiden Namenskonflikte
Import von NamespacesImports 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 Empfehlung
Visual Basic 6.0 drawing model In VB6 belassen oder in GDI+ neu
DAO and RDO data binding Update nach ADO oder ADO.NET
Dynamic Data Exchange (DDE) In VB6 belassen oder alternate Methode verwenden
OLE Container Control In VB6 belassen
Visual Basic 5.0 controls Upgrade nach Visual Basic 6.0 bzw. Danach nach Visual Basic .NET
DHTML Applications Leave; can work with .NET
Microsoft® ActiveX® Arbeitet über COM interop mit .NET
Property pages In VB6 belassen
UserControls In VB6 belassen - can work with .NET
WebClasses In VB6 belassen - can work with .NET
Wie herangehen?
Aufspalten in Teilprojekte COM Komponenten weiter verwenden
COM Interop Abhängigkeitshierarchie
(Client Middle Tier Server)
ClientClient
Middle TierMiddle Tier
ServerServer
COM InteropCOM Interop
COM InteropCOM Interop
.NET.NET
.NET.NET
.NET.NET
COMCOM
COMCOM
.NET.NET
.NET.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 Variable1End Function
Private Sub Test() Variable1 = "Test" Variable1 = Varialbe1 & "-Lauf" Debug.Print Variable1End Function
Migration: Vorbereitung
Alte Konstrukte beseitigenImplizite Typkonvertierung
Late Binding
Werte für Konstanten
Variants
Private Function Test(x, y) Test = x + yEnd Function
Private Function Test(x, y) Test = x + yEnd Function
Me.MouseCursor = 3
Me.MouseCursor = 3
Migration: Vorbereitung
Implizite Erstellung von Instanzen
Dim c as MathLib.MyClassSet c = New MathLib.MyClassc.CallAMethodSet c = Nothingc.CallAMethod
Dim c as MathLib.MyClassSet c = New MathLib.MyClassc.CallAMethodSet c = Nothingc.CallAMethod
Dim c as New MathLib.MyClassc.CallAMethodSet c = Nothingc.CallAMethod
Dim c as New MathLib.MyClassc.CallAMethodSet c = Nothingc.CallAMethod
' RunTime Error ' RunTime Error
' will execute ' 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-seitigeBeeinflussung
VB .NET Upgrade Wizard
Es ist Ihr Code!Struktur bleibt erhalten
Kommentare ebenso
Microsoft.VisualBasic.Compatibility
Prinzipien
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
.NET object
COM object RCW
IUnknown
IDispatch
.NET Components in COM
COM object CCW
.NET object
IUnknown
IDispatch
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.Interop.AxA.DLLDLL
AxInterop.AxA.AxInterop.AxA.DLLDLL
Windows Windows FormForm
• COM InteropCOM Interop• TranslationTranslation
• Extended Extended properties properties
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, _Private Sub OnClickHandler(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles mnuProp.ClickByVal e As System.EventArgs) Handles mnuProp.Click
End SubEnd Sub
Context-Menüs in VB .NET
Private Sub MouseUpHandler(ByVal sender As Object, _Private Sub MouseUpHandler(ByVal sender As Object, _ ByVal e As System.Windows.Forms.MouseEventArgs) _ByVal e As System.Windows.Forms.MouseEventArgs) _ Handles MyBase.MouseUpHandles MyBase.MouseUp
If e.Button = MouseButtons.Right ThenIf e.Button = MouseButtons.Right Then ContextMenu1.Show(Me, New Drawing.Point(e.X, e.Y))ContextMenu1.Show(Me, New Drawing.Point(e.X, e.Y)) End IfEnd If
End SubEnd Sub
Private Sub MenuOnClickHandler(ByVal sender As System.Object, _Private Sub MenuOnClickHandler(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles mnuSendMail.ClickByVal e As System.EventArgs) Handles mnuSendMail.Click
Dim mnuItem As MenuItem = DirectCast(sender, MenuItem)Dim mnuItem As MenuItem = DirectCast(sender, MenuItem) ' Do something' Do something
End SubEnd Sub
Eventhandler
Anzeigen des Menüs
File IO in VB6
4,2 s für 1000 Durchläufe4,2 s für 1000 Durchläufe
File IO in VB .NET
.NET-Methode
Traditionelle VB-Methode
2,6 s2,6 s
1,3 s für 1000 Durchläufe1,3 s für 1000 Durchläufe
DoDragDrop()DoDragDrop()
Drag & Drop
MouseDownMouseDown
DragEnterDragEnter
DragDropDragDrope.Effecte.Effect
e.Data.GetData()e.Data.GetData()
Target ControlTarget ControlSource ControlSource Control
DragDropResultDragDropResult
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
MSDN:.NET Framework QuickStarts .NET Samples - Windows Forms: Printing
Drucken: Prinzip
PrintPage Event:
Win32 APIs bzw. Pinvoke
Aufruf von unmanaged System Code
Pinvoke in VB .NET
Win32 APIs in VB6
Kein 'As Any' Type mehr in .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
ActiveX Data Objects
Vielzahl von Datenquellen
Connected und disconnected
XML Support enthalten
COM-basierend
Native .NET Komponente
Vielzahl von Datenquellen
Entwickelt für ver-bindungslosen Zugriff
Von vorn herein für XML entwickelt
.NET-basierend
ADOADO ADO.NETADO.NET
ADO versus ADO.NET
Demo:
Migration von ADO-Projekten
Angebot
VB Resource Kit (im Web) Special Offer:
VB Res Kit + VS .NET Trial Version60 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 @ MSDNhttp://msdn.microsoft.com/vbasichttp://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.htmhttp://www.microsoft.com/mspress/books/index/6510.asphttp://www.dotnetbooks.com/http://www.kofler.cc/vbnet.htmlhttp://www.amazon.de/exec/obidos/search-handle-form/ref=sr_sp_go_as/028-7168974-2906165
Communityhttp://www.microsoft.com/germany/ms/msdncommunity/Newsgroups auf msnews.microsoft.com
For More Information…
101 Visual Basic Code Samplesmsdn.microsoft.com/vbasic/downloads/samples/
For Windows developerswindowsforms.net (TaskVision)
For Web developerswww.asp.net (ASP.NET Starter Kits)
Time Tracker Reporting
eCommerce (IBuySpy store)
Portal (IBuySpy portal)
Community
Upgradingmsdn.microsoft.com/vbasic/techinfo/articles/
upgrade/
Training and Training and EventsEvents
MSDN Webcasts, MSDN Online MSDN Webcasts, MSDN Online Seminars, Tech·Ed, PDC, Developer DaysSeminars, Tech·Ed, PDC, Developer Days
MSDN
Essential Resources for Developers
Subscription Subscription ServicesServices
OnlineOnlineInformationInformation
MembershipMembershipProgramsPrograms
Print Print PublicationsPublications
Library, OS, Professional, Enterprise, Library, OS, Professional, Enterprise, Universal Delivered via CD-ROM, DVD, WebUniversal Delivered via CD-ROM, DVD, Web
MSDN Online, MSDN Flash, How-to MSDN Online, MSDN Flash, How-to Resources, Download CenterResources, Download Center
MSDN User GroupsMSDN User Groups
MSDN Magazine MSDN Magazine MSDN NewsMSDN News
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 .NETVisual Studio .NET MSDN SubscriptionsMSDN Subscriptions
NE
W
ProfessionalProfessional• Tools to build applications Tools to build applications
and XML Web services for and XML Web services for Windows and the WebWindows and the Web
MSDN ProfessionalMSDN Professional
MSDN EnterpriseMSDN Enterprise
MSDN UniversalMSDN Universal
Enterprise DeveloperEnterprise Developer• Enterprise lifecycle toolsEnterprise lifecycle tools• Team development supportTeam development support• Windows Server 2003 and Windows Server 2003 and
SQL Server™SQL Server™
Enterprise ArchitectEnterprise Architect• Software and data modelingSoftware and data modeling• Enterprise templatesEnterprise templates• Architectural guidanceArchitectural guidance
Where Can I Get MSDN?
Visit MSDN Online atmsdn.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 seminarsmsdn.microsoft.com/training/seminars
Attend more MSDN events
Microsoft Press®
Essential Resources for Developers
Microsoft Visual Studio .NET is here!Microsoft Visual Studio .NET is here!This is your chance to start building the next big This is your chance to start building the next big
thing. Develop your .NET skills, increase your thing. Develop your .NET skills, increase your productivity with .NET books from Microsoft Pressproductivity with .NET books from Microsoft Press
www.microsoft.com/mspresswww.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 accessTo locate a training provider for this course, please access
www.microsoft.com/traincertwww.microsoft.com/traincert Microsoft Certified Technical Education Centers Microsoft Certified Technical Education Centers
are Microsoft’s premier partners for training servicesare Microsoft’s premier partners for training services
Basics of Visual Basic .NET
.NET Framework and Tools
Operating SystemOperating System
Common Language RuntimeCommon Language Runtime
Base Class LibraryBase Class Library
ADO .NET and XMLADO .NET and XML
ASP .NETASP .NETWeb Forms Web ServicesWeb Forms Web Services
Mobile Internet ToolkitMobile Internet Toolkit
WindowsWindowsFormsForms
Common Language SpecificationCommon Language Specification
Visual Visual BasicBasic C++C++ C#C# MicrosoftMicrosoft®®
Visual J#Visual J#®® …… Mic
ros
oft
Mic
ros
oft
®® Vis
ua
l Stu
dio
Vis
ua
l Stu
dio
®® .NE
T .N
ET
© 2003 Microsoft Corporation. All rights reserved.© 2003 Microsoft Corporation. All rights reserved.This presentation is for informational purposes only. Microsoft makes no warranties, express or implied, in this summary.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 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 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.of their respective owners.