1. Visual Studio .NET Basics
Visual Studio .NET is designed as the tools component in the Microsoft .NET framework. It consists of Visual Basic .NET, Visual C++ .NET, and Visual C# .NET. You use this environment to develop source code in any .NET-compliant language that targets the .NET framework (class libraries). This results in a software component that you can use in any higher level application or Web service -- creating an open architecture.
However, with Visual Studio .NET, Microsoft changed the underlying technology on which their software is based. Instead of the COM model used by Visual Studio 6.0, Visual Studio .NET builds on SOAP and XML.
SOAP is a lightweight protocol built on XML for exchanging information in a decentralized, distributed environment. XML is a data language technology, and an increasingly popular standard, developed through the open Internet standards groups (w3c.org). It provides data and information and describes the nature of data or the data type. With XML, you can use information in multiple applications or configure it appropriately within a Web browser or other display. SOAP is smaller and easier to implement than COM and most of the previous protocols because of its ability to call existing XML Parsers and HTTP libraries. By using SOAP (based on XML) instead of COM, you can link to disparate systems both internal and external to your organization.
Because of the integrated nature of the environment, you can access several tools and features from all .NET languages. The look and feel within all the languages is similar in the Visual Studio .NET environment. For example, you can access the toolbox and object browser from Visual Basic 6.0 in any .NET language. Because of this, you can easily explore Visual Studio .NET projects, references, and external libraries.
NI currently offers several products that have integrated XML features. With our test management software, National Instruments TestStand, you can generate XML-based test reports, which provide great flexibility for displaying test data in a variety of formats. You can also take advantage of the Database Connectivity Toolset for XML capabilities with NI LabVIEW and LabWindows/CVI. We discuss NI and Visual Studio .NET product compatibility later in this article.
Know the Basics of Microsoft.NET
LabVIEW Database Connectivity
World Wide Web Consortium
2. Visual Basic .NET Highlights
Microsoft built Visual Basic .NET from the ground up instead of retrofitting the existing code base to run on top of the .NET Framework. They made many changes to the Visual Basic environment to increase its performance and functionality, including:
- Structured exception handling
- XML Web services
Let's discuss these additions.
Microsoft designed Visual Basic .NET to be an easy and productive tool for creating .NET applications, including Windows applications, Web services, and Web applications. One new feature added to the Visual Basic language is Inheritance, which means classes can share methods with each other and provide method overloading. This means a class can have multiple methods of the same name using the parameter lists to distinguish which underlying code to call.
Visual Basic .NET also provides structured exception handling capabilities for improved error handling. With free threading, you can call any method or function from any thread at any time offering increased flexibility and helping make Visual Basic an object-oriented programming language. Visual Basic .NET integrates with the .NET framework and the Common Language Runtime (CLR), which together provide language interoperability, simplified deployment, enhanced security, and improved version support. You can also convert Visual Basic code modules into XML Web services, so you can invoke them across the Internet, from any language running on any operating system.
3. Migrating Your Visual Basic 6.0 Applications to Visual Basic .NET
While these new features (listed above) enhance the Visual Basic programming language, they are significant changes. Therefore, you may encounter some challenges upgrading to Visual Basic .NET from Visual Basic 6.0. In addition, you may experience some difficulty as a result of syntactical changes to the language itself.
Use Conversion Wizard
To help you migrate, Microsoft provides a tool (wizard) to assist with many of the incompatibilities between the two versions. The conversion wizard runs automatically when a Visual Basic 6.0 project is opened in Visual Studio .NET. This tool converts many of the previous Visual Basic data types to the new data types used in Visual Basic .NET.
For example, when opening a Measurement Studio 6.0 example that was written in Visual Basic 6.0 with the Visual Basic .NET wizard, you notice that the ActiveX controls are placed in an ActiveX wrapper. You can see an example of this below. This is the same behavior that you can expect to see with most ActiveX controls.
Figure 1. Microsoft's Visual Studio .NET Conversion Wizard -- Measurement Studio 6.0 Example in the Visual Basic .NET Environment
While the conversion wizard takes care of most of the object updates for you, it does not convert and translate all syntactical changes -- especially the variant data type. In addition, the conversion wizard only updates projects. If you have a project group or n-tier application, you need to first upgrade the client component and ensure its functionality. Once that is complete, continue upgrading each component in the hierarchy tree until you have upgraded the 'topmost' component.
Solve Remaining Errors
The conversion wizard can only upgrade about 95 percent of your application. You need to address any remaining errors manually before compiling the application. The majority of the modifications you should expect to encounter are behavioral and syntactical. For example, anything listed as 'Upgrade_ISSUE' is probably a compiler error and something you need to fix before compiling. If you see a warning in the task list, it normally indicates a behavioral error. You should address this as well. You may also encounter some architectural errors signifying that you need to architecturally change the component needs. These errors would result from using AutoRedo in Visual Basic 6.0, using Visual Basic 6.0 printing methods, or using form collections in your Visual Basic 6.0 application.
Follow Architectural Recommendations
To minimize the manual changes when upgrading in the future, Microsoft advises that Visual Basic developers begin following the set of suggested architectural recommendations and practices. Some suggested practices include -- using early binding of variables by accessing components in other applications at compile time rather than runtime, avoiding null propagation by including tests in your code to check for passing null values, using ActiveX Data Objects (ADO) for data access, avoiding the 'double' data type for storing dates, avoiding fixed-length strings in user-defined types, as well as using constants instead of underlying values.
Note that Microsoft has completely removed some unintuitive and inconsistent methods, such as GoSub/Return and DefInt, from the language. There is also a list of features that do not work at all in Visual Basic .NET. For example, the OLE control container does not work in Visual Basic .NET -- you need to replace it. Neither the ActiveX DTML nor the ActiveX Documents page applications can be translated into Visual Basic .NET. No migration paths exist for these functions. For a complete list of these incompatible features, see Microsoft's Visual Basic .NET Upgrade Recommendations below.
Finally, keep in mind that you don't have to migrate everything. If it works, keep it; integrate it whole into your system. Then, for new projects, you can begin development in the Visual Studio .NET environment and avoid any migration issues.
4. NI Product Compatibility
NI Measurement Studio -- a components package that delivers integrated, native tools designed for measurement and automation into the Visual Studio environment -- offers Visual Studio .NET test and measurement programming components. Measurement Studio provides a collection of measurement controls designed to build virtual instrumentation systems inside Visual Basic or other ActiveX control containers. Measurement Studio also delivers an interactive design approach for developing measurement and automation systems inside Visual C++.
Because Measurement Studio is tightly integrated in the Visual Studio environment, it is naturally the NI product most closely aligned with Microsoft technology, and therefore the first to release native .NET tools. The Measurement Studio for Visual C++ .NET update includes all new application building wizards, new environment add-in tools to help you easily modify your Measurement Studio for Visual C++ .NET projects, and a new set of libraries compatible with the new versions of the Visual C++ .NET run-time libraries. Visual Basic .NET and Visual C# .NET work with controls in most cases. Because the .NET framework is not based on ActiveX technology, these controls are placed in a wrapper to function correctly within the Visual Studio .NET environment. For more information on Measurement Studio 6.0 controls in Visual Studio .NET, download our white paper, "Using Measurement Studio ActiveX Controls in Visual Studio .NET".
Figure 2. NI Measurement Studio 6.0 Controls within the Visual C# .NET Development Environment
There is currently a wealth of knowledge and resources available on ni.com. Example programs, application notes, knowledge bases, and white paper resources are all tools available to help you in your evaluation of the latest Microsoft technology. If you have any questions, comments, or ideas about Visual Studio .NET and the creation of measurement and automation applications, you can contact us directly, search the KnowledgeBase, or post a question in our online community.