Visual Studio.NET and the.net Framework Magnus Österberg Matriculation #24488 Department of Computer Science Åbo Akademi University FIN-20520 Turku Finland e-mail: magnus.osterberg@abo.fi URL: http://www.abo.fi/~ magnus.osterberg
Table of contents 1. Introduction 1.1 Abstract..3 1.2 Keywords..3 1.3 Classification..3 2..NET Overview 2.1.NET in general.4 2.2 Microsoft.NET..5 2.3 The.NET platform 6 2.4 Language integration and language independence 7 2.5 Deployment and installation of.net software.7 3. The.NET Framework 3.1 The.NET Framework architecture 8 4. Development using the.net architecture 4.1 One language one API.9 4.2 A few.net code examples 11 4.2.1 Hello World in Java..11 4.2.2 Hello World in C++..11 4.2.3 Hello World in VB.NET 12 4.2.4 Hello World in C#... 13 4.2.5 Hello World in Managed C++ 13 4.3 Conclusion.13 5. References 14 Appendix A: Common acronyms 15
1. Introduction 1.1 Abstract This paper will discuss Microsoft s.net technology, the architecture behind.net, programming in the.net environment, and the framework enabling a language independent project management philosophy. I will try to cover a wide area of the architecture. Due to limitations in length of similar papers, some things will be discussed only briefly. References and links will be provided where there is need. My website 1) will contain downloadable example applications, the source code will also be available. 1.2 Keywords Keywords defining this paper: Visual Studio.NET,.NET architecture,.net Framework, Common Language Infrastructure, Common Language Runtime, Common Language Specification, Dynamically Linked Library, Extensible Markup Languag, XML 1.3 Classification The classifications given below assists the reader in finding more information on this topic. Classification by ACM: D.3.3 Language Constructs and Features Frameworks http://www.acm.org/class/1998/d.3.3.html Classification by SIG: Special Interest Group on Programming Languages http://www.acm.org/sigplan/ 1) http://www.abo.fi/~magoster/studies/seminarium/
2..NET overview This chapter presents the.net architecture in a general perspective and serves as an introduction for the reader to the rest of this paper. 2.1.NET in general Microsoft Corporation announced its.net project in July 2001. The.NET project is a massive area of Microsoft's current interests in the computing industry today. It consists of a wide area of separable blocks, forming a new way of thinking in computing and data management of today..net brings with it a lot of new tools and techniques, but also incorporates existing techniques. Example of existing techniques that have been allowed to live on in the.net world is COM/COM+ and ASP. New techniques are, among others, a strong commitment to open standards, such as XML, HTTP and SOAP. A better support for object-oriented programming design and focus on the Internet is also to be found in.net. The.NET platform can be separated into four product groups: 1. Development tools the.net languages - Visual Basic.NET - C# ("CSharp") - Managed C++ - J# ("JSharp") - IL (Intermediate Language, the.net bytecode) A set of development tools, mainly Visual Studio.NET and a number of smaller utilities related to this An extensive class library serving as a base for the.net architecture, namely the.net Framework CLR, the Common Language Runtime, which executes code built within the framework mentioned above
2. Server and storage tools A set of specialized application server and storage tools targeting the.net architecture. These are meant to offer advanced business-to-business, data storage and presentation capabilities with a learning curve that is not steep. These tools will not be covered more deeply in this text, but a listing is provided below. - Application Center 2000 - BizTalk Server 2000 - Commerce Server 2000 - Exchange Server 2000 - Host Integration Server 2000 - Internet Security and Acceleration Server 2000 - SQL Server 2000 3. Web Services Microsoft (MS) sets out to be the main provider of commercial web services. Developers pay MS an amount of money and are provided with proved MS techniques such as user identification and transaction management. For example Hotmail and the Passport user management technique used extensively at Microsoft's web sites. 4. Devices Diverse electronically driven devices, mostly non-pc devices such as terminals, game boxes (X-Box) and cell phones. All these have a.net-style programmatic interface. 2.2 Microsoft.NET Microsoft's main idea behind.net is to enable software to be provided as a service. But.NET is much more than that, MS stays with the following designs and trends within the software industry: Distributed computing MS has realized that open standards are a key concept in modern information and data management..net uses open Internet standards, such as HTTP, XML and SOAP. Componentization Integration and easy re-use of software components, in the MS world mainly known as COM. But COM component deployment is too complex and error-prone..net provides a more logical and a simpler way to build and, especially, deploy software components.
Enterprise services MS provides tools that take care of transaction handling, transaction pooling and security issues. See the list of server tools mentioned earlier. This leaves room for the developers to be able to concentrate on the business logic when building large-scale business systems. Modern and logical use of the Internet Developing web-based applications has changed form over the years. In the early stages of the Web, focus was on the connectivity layer (TCP/IP), later evolving to the presentation layer (HTML etc.). Nowadays, the focus is on scalability and programmability, made real through communication interfaces such as XML and object communication protocols such as SOAP and Corba. 2.3 The.NET platform The platform consists of these components: Figure 2-1 - The.NET platform The Common Language Specification (CLS), Common Type System (CTS) and the Common Language Runtime (CLR) are meant to enable any language on any platform to be written using the.net Framework API. You, as the developer, would write code using the Visual Studio.NET Integrated Development Environment (IDE). Code, targeting the CLR and conforming with the rules specified by the CTS and the CLS. As can be see in Figure 2-1, Perl is mentioned as a valid programming language in the.net environment. Why is this? Perl is not a programming language with Microsoft's copyright. But,.NET enables Perl code to be executed as a regular Windows Portable
Executable (PE) program file. Obviously the Perl code need to be compiled with a compiler targeting the CLR. Such a compiler is not available on the market today, but since the CLS is an open, free-of-charge specification, anybody could write one. 2.4 Language integration and language independence Programmers and application developers are as people are most, people have opinions and see things differently. What does this mean when doing things such as writing a computer program? It means that there are as many ways of doing it as there are programmers. Software needs to be re-used and updated, but the wheel does not need to be re-invented. This tells us that there is a need for standards and specifications. However, there is also a need for such things as independence for a programmer to use the language he/she knows best. One of the cornerstones of COM is language independence, a COM component can be written in any language, as long as it meets the rules stipulated by the COM specification..net takes this a step further, enabling language integration. One can inherit from classes, throw/catch exceptions and use object-oriented techniques such as polymorphism, across different languages. The main pieces in the.net architecture enabling this are, the CLR, the CLS, the CTS, and the Common Language Infrastructure (CLI). The CLI is a subset of the CLR. MS has submitted the full CLI specification to the ECMA. (1 1) ECMA is an international industry association founded in 1961 and dedicated to the standardization of information and communication systems.
2.5 Deployment and installation of.net software In the Windows world there is such a thing as DLL Hell. This is when an installation program copies a DLL file to the computer, and overwrites an existing DLL with the same name. If these two DLLs are dissimilar in their external interfaces, it might cause an existing application to stop working or to execute incorrectly. This version conflict dilemma has over the years been the most severe problem when developing Windows applications. MS tried to fix this with its release of Windows 2000, using a caching technique which maintains the original DLLs. This works to some extent, but is still not a completely acceptable solution..net introduces a new concept, assemblies. This can be referred to Java's technique with JAR files and manifest files containing versioning details. In.NET, a shared DLL must be registered in the Global Assembly Cache (GAC) before use. A (shared) DLL must also have a unique hash value, public key, locale and version number. This ensures that a.net executable will be executed using the same DLL with which it was built. This is, in my opinion, one of the biggest advantages of the.net architecture. 3. The.NET Framework 3.1 The.NET Framework architecture Figure 3-1 - The.NET Framework architecture The.NET Framework is an Application Programming Interface (API), similar to other standard APIs such as STL, MFC, ATL and Java's API collection.
The section named Base Class Library contains code for basic things such as inputoutput, string manipulation, security, threading, reflection and collections. This is code which is to be found in every similar collection of code. On top of this layer is the Data and XML layer. This layer consists of code supporting data management and communication using XML. These classes are extensively used when building client-service applications and when databases are involved. The topmost layer consists of three distinguishable class hierarchies, extending the first and the second layer. This separation into three blocks is new. Earlier there was not as clear a separation of these as within the.net Framework This is explained more below. 4. Development using the.net architecture This chapter exemplifies the advantages within programming against one API over the old-fashioned way of having one API for every language. 4.1 One language one API There are 5-15 different programming languages in frequent use these days. A majority of these have evolved from completely different companies. This means that although the general idea behind every language is more or less the same, there are still many differences. These are mostly related to which programming paradigm serves as a base for the particular language and for what main purpose the language is to be used. Almost every language is shipped with its own collection of low-level code and data structures. This is the API. The API serves as a layer laying on top of the OS and the compiler/interpreter and beneath the compiled language code. Figure 4-1 The Visual Studio 6.0 API architecture
In Visual Studio.NET's predecessor Visual Studio 6.0 a programmer has not much advantage in knowing e.g Visual Basic's API if there is a need to do something in Visual C++. The APIs are different. Figure 4-2 One API for every language Figure 4-2 further illustrates the text in the section above. There is as many APIs as there are languages. There are, of course, not only disadvantages with this. An API can be very specific for some particular task, and enable some miscellaneous programming task to be done smoothly using this particular API. One could, for example, have an API specialized for parallel programming, or an API for programming following some specific specification technique. Figure 4-3 One API for all languages
Figure 4-3 illustrates the idea behind the.net API. All languages can use the same API. Obviously there need to be a language-specific compiler targeting the CLR, as mentioned earlier. 4.2 A few.net code examples This section shows the advantages of using the same classes and method names across different.net languages, over using differing classes and method names in other languages. The well-known "Hello World"-example will be used to demonstrate purposes. 4.2.1 Hello World in Java Java has an extensive API. It is in my opinion a very good one. This is how a "Hello World" program would be written in Java. Figure 4-4 Hello World in Java 4.2.2 Hello World in C++ C++ is also a very popular language, with a lot of usage areas. I find the syntax to be difficult to read fast and that program development is a lengthy operation in C++. However, there is no doubt that the fastest running applications are written using C++. This is how a "Hello World" program would be written in C++. (compiled using MS Visual C++ 6.0) Figure 4-5 Hello World in C++
4.2.3 Hello World in VB.NET Figure 4-6 Hello World in VB.NET In this example VB.NET-application, and in the two following, one and the same class and associated method will be used. Namely the Console class and its WriteLine method. This class belongs to the namespace called System. (Namespaces should be familiar to C++ coders.) 4.2.4 Hello World in C# Figure 4-7 Hello World in C# Note that the only thing that differs the C# code from the VB.NET code is the way the code line is marked as finished. (The ";"-sign in C# and the absence of it in VB.NET) Method invoking on objects is also done in the same way, using the "."-notation. (Console.WriteLine) C#'s syntax is very much a Java-look-a-like. Microsoft has "loaned" the best ideas from Java, added some of their own ideas, and created a powerful object-oriented programming language. A large part of the.net Framework is written in C#.
4.2.5 Hello World in Managed C++ Figure 4-8 Hello World in Managed C++ Using the same namespace, System, gives us once again access to the Console class. The method invocation differs from the other two major.net languages. Managed C++ uses the standard ANSI C++ syntax; Class::Method. The word managed in Managed C++ represents the extensions MS has added to its previous C++ standard, in order to fit in with the rest of the.net architecture. 4.3 Conclusion The.NET architecture, the.net Framework API and the development tools in Visual Studio.NET seems to be an effective way of developing enterprise applications for the MS platform. The major advantage lies in the language integration and language independence enabled by the Common Language Runtime. One other major step forward made are the improvements made in deployment of especially shared code. A disadvantage is that all systems made using elder techniques might not fully conform with the.net architecture. There will be a lot of work to update these systems, although a Visual Basic 6.0 Upgrade Wizard is provided. Since.NET is new on the market, one has to wait and see what all good and bad it brings with itself.
5. References A list of books and web sites read during the writing of this paper and points to valuable resources for the reader wishing to get a closer look at the.net architecture. Books: [TL01] Thuan Thai, Hoang Q. Lam:.NET Framework Essentials, O'Reilly, 2001 [RPL01] Steven Roman, Ron Petrusha, Paul Lomax: VB.NET Language In A Nutshell, O'Reilly, 2001 [U01] Craig Utley: A Programmer's Introduction to Visual Basic.NET, Sams Publishing, 2001 Web sites: 1. Microsoft's Visual Studio repository http://msdn.microsoft.com/vstudio/ 2. Microsoft.NET in general http://www.microsoft.com/net/ 3..NET Development at MSDN http://msdn.microsoft.com 4. An extensive.net FAQ http://www.andymcm.com/dotnetfaq.htm 5. Fortran for Microsoft.NET http://www.codeproject.com/dotnet/intro_fortran.asp 6. Python for.net http://starship.python.net/crew/mhammond/dotnet/index.html 7. A comparison between the.net Framework and Sun's J2EE http://www.codeproject.com/dotnet/dotnet.asp
Appendix A: Common acronyms Appendix A lists used acronyms and terms used in this paper, as well as terms that occur frequently in texts within this context Term ATL CLI CLR CLS COM CTS DCOM DLL EXE IDE IDL IID IL Inproc MFC MSDN MSIL Out of proc PE RAD SDK SOAP STL TLB URT VB VBRUN Visual Studio 6.0 Visual Studio 7.0 VS.NET Visual Studio.NET Web Forms Description Active Template Library Common Language Infrastructure. A open subset of the CLR, a thirdparty vendor could us this as a base when building a.net runtime on another platform. Common Language Runtime Common Language Specification Component Object Model. An architecture used frequently when developing language independent software components. Common Type System Distributed COM Dynamically Linked Library. A way of grouping code when developing for the Windows platform. A source for many versioning conflicts and hard to maintain. Executable file. Integrated Development Environment. Interface Definition Language Interface Identifier Intermediate Language Code running in in-process mode, typically a DLL. Microsoft Foundation Classes. A predecessor of the.net Framework. Microsoft Developer Network, an online documentation repository. Microsoft Intermediate Language Code running in out-of-process mode, typically an EXE. Portable Executable. A.NET executable file. Rapid Application Development. Program development using tools such as Visual Basic, Delphi or other GUI-centered tools. Software Development Kit. I.e Sun's development kit for Java. Simple Object Access Protocol Standard Template Library Type Library Universal Runtime. Deprecated, the accepted term is the.net Framework. Visual Basic Visual Basic Runtime Layer A collection of development tools, such as Visual Basic, Visual C++, Visual Interdev and variety of smaller application testing, deployment and documentation utilities. Deprecated term for Visual Studio.NET Deprecated term for Visual Studio.NET The.NET version of the Visual Studio family. Interactive web pages made using ASP.NET. Not covered in this paper.
Term Web Services Windows Forms XML XSD XSL Description Communication between software components using open techniques and protocols such as HTTP, SOAP, SMTP and XML. Not covered in this paper. Form-based application development in the.net environment, typically done using VB.NET form modules. Not covered in this paper. Extensible Markup Language XML Schema Definition Extensible Stylesheet Language