The first Virtualization for Developers event will be held in Redmond between December 12–14. The registration is still open at the Virtualization Developer Lab Series webpage. We’ve been working hard on the content for this labs, and we are really looking forward to this event.
In these events you will learn how to work with the Virtual Server 2005 COM API in great detail. Once you complete them, you’ll be able to script common management tasks, and incorporate API calls to your own management applications. You’ll also get an overview of Virtual Server capabilities, and you’ll see how the System Center Virtual Machine Manager can make your life easier. You can review the complete agenda on this webpage: Virtualization 3 day Lab Agenda Overview.
Planning and performing a Visual Basic 6.0 migration is not that straightforward. You need to keep track of many small details, and you need to keep in mind the complete migration process – in other words, always see the big picture. The tool I posted about yesterday, the Code Advisor and the Assessment Tool, are invaluable in the help that they provide during the planning stages of the project. For the complete upgrade process, however I have to recommend the Upgrading Visual Basic 6.0 Applications to Visual Basic .NET and Visual Basic 2005 guide from the patterns & practices Developer Center over at MSDN.
This guide was written as a joint effort between Microsoft and ArtinSoft, and details all the steps necessary to succesfully upgrade your applications to Visual Basic .NET. It also deals with the actual technical hurdles you normally face when performing these types of conversions. Overall it is very comprehensive, and should be in your library if you ar planning or performing one of these projects.
If you are using the VB Upgrade Companion, and decide to upgrade to C# instead, most information from the guide still applies. That is one of the beauties of the .NET Framework – the concepts from VB.NET work with C# as well.
Yesterday I blogged about the Code Advisor, that will pinpoint common programming practices that difficult the migration of a VB6 application. Well, another very important tool that you can add to your arsenal is the Visual Basic 6.0 Upgrade Assessment Tool. This tool was developed by ArtinSoft, and creates a spreadsheet with detailed information of actual upgrade issues that will be present in the .NET code after the migration.
This tool is also a free download from Microsoft’s website. You can also check out ArtinSoft Visual Basic to .NET page for more information on upgrading Visual Basic 6.0 applications.
If you are considering to upgrade your Visual Basic 6.0 application to Visual Basic .NET or C#, remember that the recommended first step is to run Microsoft’s Code Advisor. The Code Advisor, according to the website:
The Code Advisor for Visual Basic 6 is an add-in used to review your code to ensure that it meets predetermined coding standards. The coding standards are based on best practices developed by Microsoft to produce robust and easy-to-maintain code.
The Code Advisor detects issues that are not converted automatically during the automatic migration, increasing the manual work required after running the conversion tools. These include Variant variables, late binding, soft binding of different objects, and others.
Check it out: Code Advisor for Visual Basic 6.0
The Visual Basic Upgrade Companion allows you to convert calls to the Win32 API from Visual Basic 6 to C#. API calls in VB6 have the following syntax:
Public Declare Function RegOpenKey Lib "advapi32.dll" _
Alias "RegOpenKeyA" (ByVal hKey As Long, _
ByVal lpSubKey As String, phkResult As Long) As Long
The equivalent API call in C#, using platform invocation (p/invoke) is:
[DllImport("advapi32.dll">)]
extern public static int RegOpenKey(
IntPtr hKey, string lpSubKey, out IntPtr phkResult);
Even though the upgrade companion performs the conversion automatically, there are times when the protoype of the function may be slightly off. This happens mostly because of the changes in the data types between VB6 and C#. One example is when a string is sent to a method and its contents are modified in the call. String management is always tricky, and, in those cases, chances are that the VB Upgrade Companion will convert the VB6 fixed length string to a System.String object in C#. The correct conversion would be a System.StringBuilder object – remember that Strings are inmutable in C#, but StringBuilders are not, and they can be marshalled to the API as the strings that need to be modified.
If you ever have a doubt regarding the prototype of a Win32 API function in C#, I recommend that you check out PINVOKE.NET. This website contains the P/Invoke signatures for most methods of the API, classified by DLL. It is very complete, and can definitely save you lots of time if you are having problems with a particular methods.
If you are new to p/invoke, I also recommend that you check out this MSDN article on the subject.
One of the best features of the Visual Basic Upgrade Companion, Enterprise Edition, is the fact that it transforms your ADO code into ADO.NET. The Companion converts most of ADO features automatically, and it work correctly even if you choose to generate C# code.
One detail, though, is that the generated code by default uses the SQL Client for ADO.NET connections. This brings huge performance increases to the application, but we’ve run in to the situation in the past where the original datasource was not SQL Server. We’ve seen applications that used the Jet Database Engine, which is no longer supported by the latest version of MDAC, and is definitely not supported by ADO.NET’s SQL Client.
The solution for these scenarios is to use the Microsoft Access Upsizing Wizard. So far we haven’t seen any issues when upsizing the data, but there are other features that are not supported by the wizard. Once you upsize your database into a SQL Server installation (it even works with SQL Server 2005 Express Edition – which is great news for smaller installations), the final step in your application is to update the connection string used. The easiest way to get a hold of the new connection string is to create the connection inside Visual Studio 2005, and then copy the Connection String from the connection’s properties:
It is also important to mention that this and most other behaviors can be customized through our consulting services. We can also carry out the complete migration process as well.
The self-service portal is one of the best features of System Center Virtual Machine Manager (SCVMM – I have to say I can’t get used to the new name – Carmine still sounds more familiar), as it allows administrators to define policies for creating Virtual Machines, and then users themselves can create new VMs that comply with the limits set by IT (i.e.: Guest OS, amount of RAM, hard drive, etc). This greatly improves the efficiency of IT departments, and allows end-users to take control of the server and workstation provisioning process into their own hands.
During the development of our labs, we run into several issues with the Self-Service portal of SCVMM . After going through all the process to create templates and hardware and guest profiles, we kept running into issues with the template being disabled in the self-service portal. Well, it turns out that the issues had nothing to do with SCVMM itself, but with the configuration on the target Virtual Server. Here are some points in the Virtual Server configuration you should check if you ever run into similar problems (the error messages are not that descriptive):
- The host have enough RAM and disk space for the new VM
- The host must have a default path for Virtual Machines. You can check this one on the web management console of Virtual Server, under Server Properties->Search paths->Default virtual machine configuration folder.
- The host must have sufficient network adapters to support the amount specified in the template.
Our test Virtual Server installation, the default path was missing. Be sure to check these points out if you ever run into a similar situation!
Registration for the Virtualization labs we will be teaching next year is now open. The program will run from December, 2005 to May, 2006, and we will be presenting the content in Redmond, Spain, and several countries in Asia.
The labs are 3 days long, and in them we show you how to leverage the features of Virtual Server 2005 R2 SP1 from a developer perspective. You’ll learn how to script common management tasks, how to use Virtual Server 2005’s API to manipulate virtual machines and develop your own management applications, and how you can setup the System Center Virtual Machine Manager (a.k.a. Carmine) to manage Virtual Server installations.
You can see the complete schedule and sign up for the events at http://www.virtualizationevents.com/ .
A couple of weeks ago I made a post about pre-configured virtual machine images. Well, it turns out that the program is now official, and it is called VHD Test Drive. You can read about it in this press release. With this program, you can download virtual machine VHDs that contain pre-configured Microsoft’s server products, so you can try them out easily. Third party support for the program is expected later. From the press release:
These virtual machines, which are provided in Microsoft’s virtual hard disk image format, are pre-built and pre-configured so that they can be downloaded or distributed for easy setup and evaluation. This allows customers to evaluate software in a fraction of the time it usually takes, such as setting up SQL Server 2005 in minutes instead of hours.
The VHD Test Drive Program is a first for Microsoft software and the more than 7,000 software vendors who can now deliver pre-configured applications within Windows Server-based virtual machines to their customers. Today the program launches with the latest versions of Windows Server 2003 R2 Enterprise Edition, SQL Server 2005 Enterprise Edition SP1, Microsoft Exchange Server 2007 (32-bit beta) with Microsoft Office Live Communications Server 2005, and Internet Security & Acceleration (ISA) 2006 Standard Edition. Partners and customers can expect to see additional Microsoft software added to this program.
You can check out the press release here, and read more about the program on the VHD Test Drive page.
If you are a MSDN subscriber, you have access to Virtual Machine images that are preconfigured with most Microsoft’s products:
MSDN Subscribers have access to a series of Virtual Images containing a fully functional installation of Windows Server 2003, SQL Server 2005, Visual Studio 2005 Team Suite, and Visual Studio 2005 Team Foundation Server. These Virtual Images are a benefit of your MSDN subscription and are available for download from the MSDN Subscriber download area.
I copied the paragraph above from Visual Studio’s Evaluation page. You do need to have an MSDN subscription to access these images. They are a great way to evaluate Microsoft’s products without commiting a physical machine to the evaluation, or having to spend time installing and configuring a server.
This is another great example of how virtualization is making our lives easier!