Common Application Types
After you have made the decision to upgrade, we recommend you to use chapter 4 to learn about the possible VB and .NET application types and how each type should be upgraded. Remember that your first goal is to achieve functional equivalence between the legacy and upgraded versions, and being aware of potential problem areas can lessen the impact those problem areas will have on your VB to .NET application migration. For example, when executing an ASP to ASP.NET migration, take into account that Microsoft provides a free tool for automatically upgrading ASP pages to ASP.NET, and although the tool does not automatically convert all of the ASP features, it can simplify the project by automating some of the steps.
Common Application Types
Desktop and Web Applications
Porting the ASP Application to ASP.NET
Common Application Types
What types of Visual Basic 6.0 application does the Visual Basic Upgrade Wizard support?
The Visual Basic Upgrade Wizard supports different Visual Basic 6.0 application types, including standard executables (.exes), ActiveX components, and Internet Information Services (IIS) applications. Depending on the original project type, the upgrade wizard generates a .NET project whose output is a Windows-based application (.exe) or a class library (a dynamic link library, or DLL).
How can I get the most out of the services and features in the .NET platform?
It is very important that you evaluate the architecture and type of your upgraded application. For example, you can transform a highly coupled or monolithic desktop application into an application that includes several independent components in well-defined tiers and takes advantage of technologies provided by Visual Basic .NET.
Desktop and Web Applications
What are Desktop and Web Applications?
Desktop and Web applications are two basic frames that include all of the components and source code that make up an application. When you upgrade a desktop or Web application, you should consider the components and their interconnections, the structure of each component, and the overall application architecture.
A desktop application can require considerable effort to upgrade to the .NET Framework. One of the difficulties in upgrading an application is because Visual Basic has been completely redesigned for the .NET Framework, and functions and controls do not correspond exactly to their counterparts in Visual Basic 6.0.1
What approaches are recommended to upgrade a Desktop/Web application?
You may need to approach the upgrade by using one of the following two approaches:
- Vertical upgrade. This approach requires that you isolate and replace a piece of your application through all n tiers.
- Horizontal upgrade. This approach requires that you replace an entire tier of your application.
What are Single-Tier Applications?
Single-tier (or monolithic) applications are applications in which most or all of the code for a given feature is contained in a single source code file. In Visual Basic, this usually means that all of the functional logic is in the control event handler subroutines. All necessary components and functionality are included in a group of forms, making them the conceptual units for the application features. In such applications, development tends to be driven by the user interface.
This kind of application is highly coupled because all components are closely tied together, usually in the same file or procedure, with many shared structures and connection points. A single-tier application also has low cohesion, which means that the mechanisms that constitute different conceptual entities are so closely tied together that conceptual barriers are obscured. This makes modifying functionality difficult because making a change can affect more than just the intended functional behavior.
What is the best strategy to upgrade a Single-Tier Application?
The best strategy is to redesign the application and separate its functionality into distinct parts. This approach provides modularity and functional cohesion, making it easier to modify pieces of the application, add or remove functionality, or make functionality available to other applications.
Using a vertical strategy to upgrade parts of your application to the new architecture provides an effective test bed for the new design. The .NET Framework provides architectural support that makes it much easier to build on an upgraded base.
What is a Two-Tier Application?
A two-tier application is composed of a first tier — the user interface tier — that contains a user interface and business logic, and a second tier — the data tier — that contains all of the data access components.
The user interacts with the interface tier, and uses it to perform all application-specific functions. The data tier contains all data sources and manages them so that they can provide all necessary data services to the user interface tier.
How can I upgrade a Two-Tier Application?
A two-tier application can be upgraded horizontally or vertically. If you select a horizontal strategy, you can update an entire tier and leave the remaining tier unchanged. The upgraded tier can use interoperability features to work with the tier that was not upgraded. You can then upgrade the remaining tier and integrate it into the target application as time and budget permits. Alternatively, you can use a vertical upgrade strategy.
When you upgrade a two-tier application, the upgrade wizard produces a Visual Basic .NET project that contains files and references similar to those produced for a single-tier application. The main difference is that a data access class is included in the project files. This class is independent of the other classes and provides services that can be used by any other class.
What is a Three-Tier Application?
A three-tier application maximizes component cohesion and minimizes tier coupling. This architecture uses three different tiers for the different aspects of the application: a user interface tier, a business logic tier, and a data tier.
Additionally, it allows you to take advantage of specialized skills that your developers may have, and have them work in parallel. For example, one developer or development team could work on modular user interface components while other developers upgrade and adjust the components in the business logic and data access tiers.
What is the difference between a three-Tier and a Two-Tier application?
The difference between a three-tier and a two-tier application is the addition of a business logic tier.
The business logic tier contains application rules and algorithms; therefore, the user interface tier is only responsible for managing the interaction between the user and the application.
How do I create a Visual Basic 6.0 Desktop Application?
You start by using the standard executable project template. By default, this template starts with an empty form that becomes one of the primary interfaces. The Visual Basic 6.0 integrated development environment (IDE) allows you to include supplementary components and references to take advantage of existing functionality.
What characteristics can be found in a Visual Basic 6.0 Desktop Application?
In general, a desktop application had the following characteristics:
- Intended usage: The application has many visual cues or aids and provides a complex interaction with the user.
- Architecture: The application architecture is flexible: for example, it can be a single tier, fully coupled application or a completely modular application with well-defined business logic and data access tiers.
- Necessary capabilities: The application requires user interface components, basic services, and data access functionality. Multithreading capability may be required, but synchronized process distribution is rarely needed unless the application uses the distributed component object model (DCOM) or COM+.
What architecture-related issues should be considered in upgrading a desktop application?
Language issues. You may need to perform additional manual upgrading to resolve language issues, such as external DLL function declarations or thread safety. This work can include creating or changing classes so that they provide basic API services or synchronization among objects. You can upgrade external declarations to .NET Framework classes and new interface classes. In addition, you may need to add references. Note that Visual Basic .NET components (including UserControls) are not inherently thread-safe. Multiple threads are allowed to access a component simultaneously. As a result, code that is thread safe in Visual Basic 6.0 can be unsafe when it is upgraded to Visual Basic .NET.
This change will affect you if you are running your component in a multithreaded environment such as Internet Explorer, Internet Information Services, or COM+.2 In this case, you must include new synchronization mechanisms to ensure thread safety.
Form issues. Dynamic data exchange (DDE) and drag-and-drop functionality can cause upgrade issues. Neither Visual Basic .NET nor the .NET Framework support DDE. Because Visual Basic drag-and-drop is considered an outdated feature, the upgrade wizard does not upgrade drag-and-drop – related code.
Instead, it preserves the Visual Basic 6.0 drag-and-drop code in the upgraded Visual Basic .NET project. The code will not compile; therefore, you must either delete it and remove the drag-and-drop functionality or change the code to use OLE drag and drop.
ActiveX control upgrade. The upgrade wizard supports most ActiveX components. The upgrade of these components takes advantage of the interoperability that can be built around the original component. However, if an application control is not supported, you must reimplement and re-architect some application functionality, particularly in the user interface. In applications that make extensive use of complex third-party controls, you should perform limited upgrade tests with a simplified user interface. This will help you to determine how many controls are fully or partially supported.
How do I deploy an upgraded .NET desktop application?
To deploy an upgraded .NET desktop application, you must do the following:
- Install the application executable and library files on the client computer.
- Use the .NET Framework Assembly Registration Utility (regasm) to register the.NET Framework library assemblies that are shared by different applications.
- If the application contains ActiveX components, register these components on each client computer.
- Distribute all the corresponding ActiveX wrapper assemblies.
What technologies are generally used to build a Web Site or Web Application with Visual Basic 6.0?
In most cases, you would use the following technologies:
- Active Server Pages (.asp). This is a server-side scripting run-time environment used to create interactive Web server applications. An .asp file can include HTML sections, script commands, and COM components that execute on the Web server and render a Web page for the client.
- Internet Information Server (IIS) projects. These are applications composed of WebClasses that run on the Web server and respond to HTTP requests from Chapter 4: Common Application Types 119 clients. WebClasses can handle state information for the application.
Can ASP and ASP.NET coexist on the same Web server?
Yes. However, they are executed as different, non-communicating processes. A Web application within a site can contain both ASP.NET pages and ASP pages. This offers some advantages if you need to move a large, functionally disjointed and rapidly changing site to ASP.NET one piece at a time. You can upgrade different sections of the application that do not depend on each other to ASP.NET, and they can coexist with the rest of the application. If you are transitioning to ASP.NET as a long-term strategy, you should use this opportunity to make as many architectural and design improvements as you can.
What are the main advantages of upgrading my existing ASP pages to ASP.NET?
- Increased performance. Independent tests have shown that ASP.NET applications can handle two to three times the requests per second as classic ASP applications.
- Increased stability. The ASP.NET runtime closely monitors and manages processes. If a process malfunctions (for example, if it leaks or deadlocks), ASP.NET can create a new process to replace it. This helps to keep your application available to handle requests.
- Increased developer productivity. Features such as server controls and event handling in ASP.NET can help you to build applications more rapidly and with fewer lines of code. It is also easier to separate code from HTML content.
Is there a way to automatically convert ASP Pages to ASP.NET?
Yes. Microsoft provides a free tool for automatically converting ASP pages to ASP.NET. The tool does not automatically convert all of the ASP features, but it can simplify an upgrade project by automating some of the steps. To download the migration assistant, see “ASP to ASP.NET Migration Assistant” in the Microsoft ASP.NET Developer Center on MSDN.
If you are upgrading an enterprise application that uses ASP, you may need to use two different upgrade assistants. If the application has a business logic tier, user-defined classes in the data access tier, and additional components that run on an application server, you should use the Visual Basic Upgrade Wizard. After you successfully upgrade these foundation components, you can convert the ASP code by using the ASP to ASP.NET Migration Assistant.
Porting the ASP Application to ASP.NET
How can I incorporate the features of ASP.NET into the existing ASP Application?
You can approach this work in one of two ways:
- You can run the migration assistant on the ASP pages, and then apply manual changes.
- You can re-architect the application and use many of the features of .NET, including ASP.NET Web controls, ADO.NET, and the .NET Framework classes.
What Key Considerations should be contemplated when upgrading ASP pages to ASP.NET?
When you upgrade existing ASP pages to ASP.NET pages, you should also be aware of the following:
- Core API changes: The core ASP APIs have a few intrinsic objects (Request, Response, Server, and so on) and their associated methods. With the exception of a few simple changes, these APIs continue to function correctly under ASP.NET.
- Structural changes: Structural changes are those that affect the layout and coding style of ASP pages. You need to be aware of several of these to ensure that your code will work in ASP.NET.
- Visual Basic language changes: There are some changes between VB Script and Visual Basic .NET script that you should prepare for before you upgrade your application.
- COM-related changes: COM has not been changed at all. However, you need to understand how COM objects behave when you use them with ASP.NET.
- Application configuration changes: In ASP, all Web application configuration information is stored in the system registry and the IIS metabase, while in ASP.NET each application has it own Web.config file.
- State management issues: If your application uses the Session or Application intrinsic object to store state information, you can continue to use these in ASP.NET without any problems. As an added benefit, ASP.NET provides additional options for your state storage location.
- Base class libraries: The base class libraries (BCL) provide a set of fundamental building blocks that you can use in any application you develop, whether your application is an ASP.NET application, a Windows Forms application, or a Web service. You can significantly improve your application by using the BCL.
What types of COM components can I create with Visual Basic 6.0?
You can create the following types of COM components:
- ActiveX code libraries. You can compile these components as COM executable programs or as DLLs. These libraries include classes that you use by creating instances in the client application. In Visual Basic 6.0, the project templates you use to create these COM components are referred to as ActiveX executables and ActiveX DLLs.
- ActiveX controls. These controls are standard interface elements that allow you to rapidly assemble reusable forms and dialog boxes.
- ActiveX documents. ActiveX documents are COM components that must be hosted and activated within a document container. This technology permits generic shell applications, such as Internet Explorer, to host different types of documents.
What is an Assembly?
An assembly is the primary building block of a .NET Framework – based application. It is a component library that is built, versioned, and deployed as a single implementation unit. Every assembly contains a manifest that describes that assembly.
What Versioning Problems may occur with Win32 applications?
Currently two versioning problems occur with Win32 applications:
- Versioning rules cannot be expressed for pieces of an application and enforced by the operating system. The current approach relies on backward compatibility, which is often difficult to guarantee.
- There is no way to maintain consistency between sets of components that were built together and the set that is present at run time.
These versioning problems combine to create DLL conflicts, where installing one application can inadvertently break an existing application because a certain software component or DLL was installed that was not fully backward compatible with a previous version.
How can Assemblies help solve Versioning Problems?
The .NET CLR provides assemblies as a means to achieve the following goals:
- Enable developers to specify version rules between different software components.
- Provide the infrastructure to enforce versioning rules.
- Provide the infrastructure to allow multiple versions of a component to be run simultaneously (this is called side-by-side execution).
What can you tell me about the Interoperability Capabilities of the .NET CLR?
When you upgrade application components from Visual Basic 6.0 to Visual Basic .NET, you should take into consideration the interoperability capabilities of the .NET CLR. For example, you can upgrade a third-party component through different mechanisms, including interoperability wrappers, upgrading to .NET Framework components, and upgrading to third-party components designed for Visual Basic .NET. You should select the appropriate option for your application by considering the effort required, the expected results, the available resources, your future application development plans, and other factors.
How do I create a COM wrapper?
- Use the Regsvr32 tool (Regsvr32.exe) to register the original COM component on the target computer.
- Use the Type Library Importer utility (Tlbimp.exe) to create an interoperability wrapper.
- If the component is an ActiveX control, generate a Windows Forms ActiveX control importer by using the Windows ActiveX Control Importer utility (Aximp.exe).
What benefit do I get from putting an assembly in the global assembly cache?
There are several reasons why you might want to put an assembly in the global assembly cache:
- The global assembly cache provides a central location for shared assemblies. If an assembly will be used by multiple applications, it should be put in the global assembly cache.
- The global assembly cache can improve file security. Administrators often protect the WINNT directory by using an access control list (ACL) to control write and execute access. Because the global assembly cache is installed in the WINNT directory, it inherits that directory’s ACL.
- The global assembly cache allows side-by-side versioning. The global assembly cache can maintain multiple copies of assemblies with the same name, but different version information.
- The global assembly cache is the primary CLR search location. The common language runtime checks the global assembly cache for an assembly that matches the assembly request before probing or using the code base information in a configuration file.
What is an ActiveX Control?
An ActiveX control is a COM component with user interface elements. ActiveX controls were previously known as OLE controls or OCX controls. These controls can be used in the same way as any of the standard built-in controls, and provide an extension to the Visual Basic 6.0 toolbox. ActiveX controls created in Visual Basic can be used in different container applications, including Visual Basic applications, Microsoft Office documents, and Web pages ccessed through a Web browser like Microsoft Internet Explorer.
How can I insert ActiveX Controls in Web Pages?
You can insert ActiveX controls in Web pages by using the <Object> HTML tag. This tag receives a ClassId parameter that corresponds to the ActiveX component identifier. The identifier is required so that the component can be registered on the client computer and instantiated and displayed correctly by the Web browser.
You can achieve functional equivalence for an upgraded Web application by leaving embedded controls inside Object tags. If the original ASP application included server-side components, you can wrap these components by using the interoperability feature.
What are ActiveX Documents?
ActiveX documents are COM components that must be hosted and activated within a document container. They provide the application functionality; they also provide the ability to persist and distribute copies of the data intrinsic to the application.
These components can be used on HTML pages or as alternatives to HTML pages, and they can be deployed so that users can navigate transparently between ActiveX documents and other pages in the application or Web site.
What is a Distributed Application?
A distributed application is one in which some of the application components are executed on remote computers and there is interaction between local and remote components. To have an effective interaction between these components, you must use numerous basic services, such as communication protocols, security, and resource locator services. A distributed application offers important advantages for the enterprise environment, including improved scalability, reliability and failure tolerance.
What is the main function of DCOM Application?
The distributed component object model (DCOM) extends the component object model (COM) to support communication between objects on different computers on a local area network (LAN), a wide area network (WAN), or even the Internet.
With DCOM, your application can be distributed to any location that makes sense to your users and to the application.
What advantages does using COM to Upgrade a Distributed Application will bring me?
This alternative has the following advantages:
- It provides an easy and fast upgrade implementation: The new COM wrapper classes only need to provide a communication link between the DCOM infrastructure and Visual Basic .NET.
- It provides upgrade path flexibility: Because this solution does not need extensive resources, you can use multiple stages to implement it if your application is complex.
- It allows early testing of component interaction: You can schedule early testing of these components in parallel with other upgrade tasks.
What disadvantages does using COM to Upgrade a Distributed Application will bring me?
The main disadvantages of this approach are:
- Additional communication requirements: The new intermediary classes and interoperability wrappers consume more communication and processing resources.
- Adoption of new technologies is limited: Because of the dependency on legacy technologies, adoption of new features and services offered by the .NET Framework are limited.
- Reduced maintainability: The new classes increase the complexity of the application.
Understanding the possible application types that you may need to upgrade will help you to better understand how each type should be upgraded. Each type has features that are easy to upgrade and features that are hard to upgrade. Being aware of potential problem areas before you begin can lessen the impact those problem areas will have on your upgrade process.