Title: ISV Community Day
1ISV Community Day
- Verktyg och alternativ för konvertering
Per Ahlberg Developer Evangelist Developer
Platform Evangelism Microsoft Sweden
2Agenda
- Migration Strategy And Pitfalls
- VB .NET Language Aids
- VB6 Code Advisor
- Visual Basic 6 to .NET Assessment tool
- Migration Wizard
- Code Snippet Tool
- Amplifying the Application
- Migrate ASP till ASP.NET
3Visual Basic Language Changes
- Let and Set are not supported, so change
- Set MyObj1 MyObj2 to MyObj1 MyObj2
- No more default properties(except for indexed
properties), so change - MyString as string Textbox1 to MyString as
string Textbox.text - Integer data types have been changed to match the
runtime and other languages - Integers are now 32 bit (old long integer size)
- Longs are now 64 bit
4Visual Basic Language Changes
- Use structured error handling
- (try catch block) instead of On Error
- (On Error still works)
- Must cast data types explicitly
- Response.Write (Count CStr(MyCount)) or
- Response.Write(Count CType(MyCount, String))
- Error handling
- Try Catch Finally replaces On Error Resume
Next - And More
- Short-circuiting conditionals,
- , Early Binding etc
5Visual Basic Language Changes
- Must have spaces around , so change
- Property Get, Property Set, and Property Let are
not supported anymore, so instead use
x str1str2 to x str1 str2
Public Property MyCount as Integer Get
MyCount InternalValue End Get
Set(value as Integer)
InternalValue value End Set End
Property
6Not 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
7Tools help migration
VB6 Application
VB6
Prepare for upgrade VB6 Code Advisor
VB6
VB6
VB6
VB6
VB.NET
Upgrade and fix issues Migration Wizard
Enhance with new features
8Micro Issues are 88
- Simple to fix.
- Create Noise
- Five issues represent 88 of all upgrade issues
9Strongly 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 myTe
xtBox.Text "Hey There"
10Latebound Variables
- 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"
11Choice Of Solutions
- Solution 1 Prepare in Visual Basic 6.0
- Solution 2 Fix after upgrading
As TextBox
Dim myTextBox myTextBox "Hey There"
Dim myTextBox As Object 'UPGRADE_WARNING
Couldn't resolve default property of object
myTextBox. myTextBox.Text "Hey There"
.Text
12Macro Issues
13Using COM From .NET
Common Language Runtime
ComServer
Object
Runtime CallableWrapper
ReferenceCounted
14Exposing 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
15.NET from COM
Common Language Runtime
COM Client
COM CallableWrapper
IFoo
Server
Client
16VisualBasic.Compatibility.dll
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.
Class DirListBoxEx Inherits Microsoft.VisualBasi
c.Compatibility.VB6.DirListBox End Class
17Prepare VB6 code
- Strongly type variables
- Null Propagation
- Non zero lower bound arrays
- Replace values with Enums
- Incompatible properties
- Module methods
18Code 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
19Issues Identified by the Code Advisor
20Visual Basic 6 to .NET Assessment tool
- New tool!
- Analyses VB6 projects
- Create extensive reports
- Cost and Time
- Problems
- What to do
- In with order
- Dependences
- And much more
21Before 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
22Upgrade Wizard
- EXE DLL
- Copies project
- Creates reports
- Links to Help
- Four Levels
- Issue No Automatic Upgrade
- ToDo Requires Finishing
- Warning Possible Behavior Change
- Note Informational
23Upgrade Wizard now also upgrade!
- MTS and COM projects
- VB6 to Windows Forms controls
- WebBrowser, Toolbar, ImageList, TreeView,
ListView, OleContainer,RichTextEdit, ProgressBar,
StatusBar, CommonDialog, MaskedEdit - Code that uses string-based-keys in forms control
collections - Code that changes the key value in the KeyPress
event - Upgrade to the BackgroundImageLayout property
- VB6 App object to the My object
- Unload Mode Parameter of QueryUnload event to
ClosingReason
24Upgrade Wizard now also upgrade!
- Unload Mode Parameter of QueryUnload event to
ClosingReason - Forms to use the new Partial Type format
- Default instance to use VS support for default
instances - Forms collection to the VS forms collection
- VB6 Printers collection object to the
My.Computer.Printers object - VB6 clipboard object to the My.Computer.Clipboard
- Upgrade LoadResString, LoadResData,
LoadResPicture to use My.Resources
25Upgrade Wizard
Form Layout
ActiveX Controls
ADO Data Binding
RES files
Code
Syntax Changes
COM Libraries
Behavior warnings
26Code Snippet Tool
- Visual Studio .NET IDE tool
- Piecemeal alternative to full project upgrade
- Not available in C
27Code Snippet Tool
- Usage Scenarios
- Paste in existing Visual Basic 6.0 code
- Leverage existing Visual Basic 6.0 code without
doing a full upgrade - Type in Visual Basic 6.0 style code
- Ideal for learning the Visual Basic .NET
equivalent of a familiar syntax
28Code Snippet Tool
- Steps For Using the Tool
- Place cursor where you want to insert code
- Open Upgrade Visual Basic 6.0 Code tool
- Paste Visual Basic 6.0 code, or type Visual Basic
6.0 syntax - Add references to COM components
- Click Upgrade
- COM references added to project References
- Microsoft.VisualBasic.Compatibility
29Take Advantage of .NET
- Replace ADO with ADO .NET
- Replace ActiveX controls
- Web-enable
- Mobile front end
- Reflection
- Web services
30Migrate ASP to ASP.NET
- Run side-by-side
- Integrate
- Use both ASP and ASP.NET
- Use common components
- COM, written in VB6 or .NET
- Run in same application
- Total migration
- Move everything to .NET
- Including data layer Components
31How can ASP ASP.NET coexist?
- Separate worlds!
- File extensions (asp vs. aspx)
- Configuration (metabase registry vs.
web.config) - Processing engines (asp.dll vs. aspnet_wp.exe)
- Can be combined in one application
- Allows for
- partial conversion
- conversion as updates are needed
- just adding new features written in .NET
- Coexistence issues
- Sharing info
- Sessions and applications dont work
- Database, XML, get post do work
- Performance
- Running two engines obviously takes more
resources then running just one
32Changes in Core objects
- Request object changes
- Request(item), Request.QueryString(item), and
Request.Form(item) now return a name value
collection - In classic ASP, they return an array of strings
- Use Response.Write with caution
- It will output results at the top of the page
- before the ltHTMLgt tag
- Instead
- Use server controls (placeholder)
- Use lt gt tags if you want the output to appear
in the right place - Each of the core objects now have many new
properties and methods.
33Changes in Structure
- One page one language
- No mixing of languages in single page
- A page can have only one server-side Form tag
- and it must submit to the same page
- An ASPX page may contain
- Directives lt_at_ Directive gt
- Server controls lttag runatservergt
- Code blocks ltscript runatservergt
- Data binding expressions lt gt
- Server-side comments lt-- --gt
- Server-side includes lt!-- include --gt
- Render code lt gt and lt gt
34Changes in Structure
- Code blockrelated changes
- You cannot declare functions inside lt gt tags
- Declare all your functions and variables inside
the server-side ltSCRIPTgt blocks
ltScript runatserver languagevbgt dim gVar
as String Page level variable private sub
MySubRoutine() Label1.Text gVar End
Sub lt/Script gt
35Changes in Structure
- No Render functions permited
lt MyRenderFunction Sub MyRenderFunction() gt
lth1gt Hi there! lt/h1gt ltend subgt
lt Call MyRenderFunction()gt ltscript
runatserver languagevbgt
Response.Write(Hi there!) lt/scriptgt
36Changes in Application Configuration
- ASP.NET application settings are stored in XML
configuration files - Types of configuration files
- Machine.config
- Contains machine-wide settings
- Web.Config
- Contains project/application-wide settings
- Easy programmatic access to the data in these
files - Some of the settings in the IIS snap-in are
ignored - For example application protection level,
session state
37Changes in Security
- The IIS part of the security remains same
- New robust and flexible security model is based
on the security sections in the configuration
files - New authentication modes
- Windows uses Windows Authentication
- Forms uses cookie-based custom logon forms
- Passport uses the Microsoft .NET Passport
Service - None no authentication
- Authorization modes permit you to control access
to resources - File authorization
- URL authorization
- Permit and deny users access to the application
38(No Transcript)