Many people always get confused with Visual Studio .NET (VS.NET) and .NET technology. VS.NET is just an editor, provided by Microsoft to help developers to write .NET programs easily. VS.NET editor automatically generates lot of code, allow developers to drag and drop controls to a form, provide short cuts to compile and build the application etc. [Read more…] about What is Visual Studio .NET
HOW CLR PROVIDES CROSS LANGUAGE INTERACTION
A component can be called by any .NET-based language regardless the original language of that component. The cross-language compatibility is possible because objects created in different .NET languages agree on a common set of types and features. These common types and features are spelled out in the Common Language Specification (CLS).
Let’s take a look how CLR provide cross language interaction:
1. Every .NET based language compiler translates source language program into MSIL code.
2. The CLR also defines, the format’ of storing assembly metadata and this means all assemblies whatever language they were written in, share a common format for storing Metadata. ‘
3. All .NET based language follow Common Language Specification (CLS). CLS specifies a set of features that every .NET complaint language has to follow. A .NET complaint language may have its own unique features but it must follow the common set of features specified in CLS.
Because the target code of each .NET based compiler is represented in same language. The metadata is expressed in same language ‘and all sources language confirms to follow a set of features so the codes written in two different languages can interoperate.
Type of .NET Languages
To help create languages for the .NET Framework, Microsoft created the Common Language Infrastructure specification (CLI). The CLI describes the features that each language must provide in order to use the .NET Framework and comm6n language runtime and to interoperate with components written in other languages. If a language implements the necessary functionality, it is said to be .NET-compliant.
Every .NET-compliant language supports the same data types, uses the same .NET Framework classes, compiles to the same MSIL, and uses a single common language runtime to manage execution. Because of this, every .NET-compliant language is a first-class Microsoft .NET citizen.-Developers are free to choose the best language for a particular component without losing any of the power and freedom of the platform. In addition, components written in one language can easily interoperate with components written in another language. For example, you can write a class in C# that inherits from a base class written in Visual Basic.
The .NET Framework was developed so that it could support a theoretically infinite number of development languages. Currently, more than 20 development languages work with the .NET Framework. C# is the programming language specifically designed for the .NET platform, but C++ and Visual Basic have also been upgraded to fully support the .NET framework. The following are the commonly used languages provided by the Microsoft:
• VC++
• VB.NET
.C#
• J#
• JScript .NET
Many third parties are writing compilers for other languages with .NET support. With CLR, Microsoft has adopted a much liberal policy. Microsoft has them selves evolved/ developed/ modified many of their programming languages which compliant with .NET CLR.
VC++
Although Visual C++ (VC++) , has undergone changes to incorporate .NET; yet VC++ also maintains its status being a platform dependent programming. Many new MFC classes have been added a programmer can choose between using MFC and compiling the program into a platform specific executable file; or using .NET framework classes and compile into platform independent MISL file. A programmer can also specify (via directives) when ever he uses “unsafe” (the code that by passes CLR, e.g. the use of pointers) code.
VB.NET
Out of ALL .NET languages, Visual Basic.NET (VB.NET) is one language that has probably undergone into the most of changes. Now VB.NET may be considered a complete Object- Oriented Language (as opposed to its previous “Half Object Based and Half Object Oriented” status).
Visual Basic .NET provides substantial language innovations over previous versions of visual basic. Visual Basic .NET supports inheritance, constructors, polymorphism, constructor overloading, structured exceptions, stricter type checking, free threading, and many other features. There is only one form of assignment: noLet of set methods. New rapid application development (BAD) features, such as XML Designer, Server Explorer, and Web Forms designer, are available in Visual Basic from Visual Studio .NET. With this release, Visual Basic Scripting Edition provides full Visual Basic functionality.
C#
Microsoft has also developed a brand new programming language C# (C Sharp). This language makes full use of .NET. It is a pure object oriented language. A Java programmer may find most aspects of this language which is identical to Java. If you are a new comer to Microsoft Technologies – this language is the easiest way to get on the .NET band wagon. While VC++ and VB enthusiast would stick to VC.NET and VB.NET; they would probably increase their productivity by switching to C#. C# is developed to make full use of all the intricacies of .NET. The learning curve of C# for a Java programmer is minimal. Microsoft has also come up with a The Microsoft Java Language Conversion Assistant-which is a tool that automatically converts existing Java-language source code into C# for developers who want to move their existing applications to the Microsoft .NET Framework.
J#
Microsoft has also developed J# (Java Sharp). C# is similar to Java, but it is not entirely’ identical. It is for this reason that Microsoft has developed J# – the syntax of J# is identical to Visual J++. Microsoft’s growing legal battle with Sun, over Visual J++ – forced Microsoft to discontinue Visual J++. So J# is Microsoft’s indirect continuation of Visual J++. It has been reported that porting a medium sized Visual J++ project, entirely to J# takes only a few days of effort.
JScript.NET
Jscript.NET is rewritten to be fully .NET aware. It includes support for classes, inheritance, types and compilation, and it provides improved performance and productivity features. JScript.NET is also integrated with visual Studio .NET. You can take advantage of any .NET Framework class in JScript .NET.
Third-party languages
Microsoft encourages third party vendors to make use of Visual Studio. Net. Third, party vendors can write compilers for different languages ~ that compile the language to MSIL
(Microsoft Intermediate Language). These vendors need not develop their own development environment. They can easily use Visual Studio.NET as an IDE for their .NET compliant language. A vendor has already produced COBOL.NET that integrates with Visual Studio.NET and compiles into MSIL. Theoretically it would then be possible to come up with Java compiler that compiles into MSIL, instead of Java Byte code; and uses CLR instead of JVM. However Microsoft has not pursued this due to possible legal action by Sun.
Several third party languages are supporting the .NET platform. These languages include APL, COBOL, Pascal, Eiffel, Haskell, ML, Oberon, Perl, Python, Scheme and Smalltalk.
User and Program Interface
The .NET framework provides the following tools for manag1ng user and application interfaces:
• Windows forms
• Web Forms
• Console Applications
• Web Services
These tools enable users to develop user-friendly desktop-based as well as web-based applications using a wide variety of languages on the .NET platform.
Window Forms
Windows forms (also called Win Forms) ate used to create GUI-for Windows desktop applications. The idea of Win Form has been borrowed from Windows Foundation Classes (WFC) which was used for Visual J++. Win Form provide an integrated and unified way of developing -GUI. It has a rich variety of windows controls and user interface support.
Numerous classes and functions were used by programmers to handle GUT. MFC in VC++, direct API in C++ and VB Forms Engine in VB are just a few examples of different ways of handling GUI.
Simply Win Form is just another group of wrapper classes that deal specifically with GUI. Win Form classes encapsulate the Windows Graphical APIs. Now the programmers would not need to use the Windows Graphical APIs directly; and since Win Form has been made apart of .NET. Class Framework; all the programming languages would use the same Win Form classes. This would rid the programmers of the need to learn different· GUI classes/tools. Win Forms in the part of the namespace System Winforms.
With Win Forms we can make a single user interface, and use it in VC++, VB, C#. Using
Visual Studio. NET simply designs the GUI, by dragging the controls on a form (something that all VC++ and VB programmers are well familiar with). Now you can use the same form either in VB, VC++ or in C#. And this is all made possible because Visual Studio.NET uses the System. Winforms namespace to draw the GUI. And any language that has the appropriate CLS compliance can use this form directly.
Web Forms
Just as the Win Forms provide a unified way of developing GUI for desktop application, the Web Forms provide similar tool for web applications. Web Forms has been introduced in .NET as a part of ASP.NET. Web’ Forms are a form engine, that provides a browser-based user interface.
To appreciate Web Forms you may consider how GUI is rendered in current Web applications. The GUI is rendered by using HTML tags. (e.g. <input type=text name=editboxl maxlength=10 size=10 >, will draw an edit box on the web page) Web Forms can also have the intelligence to use HTML, DHTML, and WML etc. to draw the controls on the web page based on the browser’s capabilities. Web Forms can also incorporate the logic behind these controls. It’s like hooking up the code to a GUI control. Just like in your VB application, you can associate a code with a button on the web page; this code will be run on the server when the button is pressed. This is in contrast to the scripts that run on the clients when a button is pressed.
This approach is different to the Java approach. In Java a programmer can simulate this functionality through JavaScript and Servlets. But with Web forms this is done transparently.
A Java programmer may consider as if each HTML control has its dedicated “Servlets” running in the background. Every time the control receives any event of interest (e.g. button pressed, selection changed etc.) this specific “Servlets” is called. This results in much cleaner code and an excellent logic separation between presentation and business logic layers.
Web Forms consist of two parts – a template, which contains HTML-based layout information for all the GUI elements and a Component which contains all the logic to be hooked to the controls or GUI elements. This provides a neat presentation layer and application logic layer separation.
The GUI will be rendered on the client side, while the code that has been hooked to the GUI elements will run on the server side (very ‘much likes a button being pressed on a JSP and a Servlets being called in response. But with Win Forms this has been made extremely easy). The incorporation of Web Forms in ASP.NET is an attempt to take ASP to a new level where it can seriously challenge JSP.
Another good feature of Web Forms is that it can be built to have enough intelligence to support a vast variety of browsers. The same ASP page would render itself using DHTML, if the browser is IE 5.5. But if the browser is Netscape the web page will be rendered using HTML tags; if the’ page is being accessed through a WAP device the same page will render itself using WML tags.
One of the obvious disadvantages of ASP over Java was that there was that an ASP code was a maintenance nightmare. While a Java programmer can use Java Beans, Tags and also Servlets to achieve presentation and business layer separation – no such mechanism was present to an ASP programmer. With ASP.NET Microsoft ‘has provided such presentation business, layer separation – by introducing the concept of Web Forms:
1. ASP.NET Web Forms provide an easy and to build dynamic Web UI.
2. ASP.NET Web Forms pages can target any browser client (there are no script library or. cookie requirements).
3. ASP.NET Web Forms pages· provide syntax compatibility with existing ASP pages.
4. ASP.NET server controls provide an easy way to encapsulate common functionality.
5. ASP.NET ships with 45 built-in server controls. Developers can also use controls built by third parties.
6. ASP.NET templates provide an easy way to customize the look and feel of list server controls.
7. ASP.NET validation controls provide an easy way to do declarative client ·or server data validation.
Console Application
Console applications are command line oriented applications that allow user to read characters from the· console, write characters to the console.
Console applications are typically designed without graphical user interface and are compiled in a stand-alone executable file.
A console application is run from the command line with input and output information being exchanged between the command prompt and the running application. Because information can be written to and read from .the console window, this makes the console application a great way to learn new programming techniques without having to be concerned with the user interface.
Web Services
A web service is an extension of ActiveX. Those programmers, who have used ASP and JSP both, know the apparent shortcomings of ASP. JSP has been enriched with the concepts of Beans. And Tags. ASP equivalent for Beans and Tags was ActiveX Controls. and ActiveX automation servers. Let me take a minute to explain this point a bit further. Web Services is NOT a Microsoft proprietary standard. It is a W3Consortium standard, and has been developed by Microsoft, IBM and many other big names of the industry.
Functions are of two types. The ASP built-in functions and the programmer defined implemented functions. In order to use the built in functions you just need to pass the appropriate parameters and make a simple call to these functions. The functions are implemented by the ASP itself. The string manipulation functions, Number conversion functions are an, example of built in functions.
The user-defined functions are the functions that are defined and implemented by the programmer. A programmer can either write these functions in the same asp file or can write them in another file. If the function code resides in the same asp file then the programmer can directly call that function. In case the function resides in another file, say “func.asp”; then the programmer needs to include that file by writing a statement like <!- #include file=”func.asp” ->; and now the programmer can use the function. The programmers can also make ActiveX automation servers, and call various functions of these ActiveX servers, But one limitation is very obvious – no matter which type of function you use, the function MUST physically reside on the same machine. For example your ActiveX automation server must be implemented either as a .dll or as an .exe and then must also be registered in Windows Registry before an asp code can call its functions.
In a world where the Intemet has become not only a necessity but also a way of life – it is obvious that this limitation is a strong one; Microsoft’s answer to this problem is “Web Services”. The idea goes something like this:
1. The Web service provider develops a useful function(s), and publish/advertise it. The
Web Service provider uses Web Service Description Language (WSDL) standard to describe the interface of the function(s). This is much like the Type Libraries (TLB) and Object Description Language files (ODL) that needs to be generated with the ActiveX automation servers.
2. The programmer/client who needs the function does a lookup by using a process called
– Web Service Discovery or SOAP Discovery (also called DISCO for Web Service DISCOvery)
3. The Actual communication between the client program and the web service takes place through a protocol called Simple Object Access Protocol (SOAP) -SOAP is an XML based light weight protocol used for communication in a decentralized distributed environment.
UNIFIED CLASSES (Base Class Library)
The term .NET framework refers to the group of technologies that form the development foundation for the Microsoft .NET platform. The key technologies in this group are the run time and the class libraries.
The Unified Classes (Base Class Library) is a set of classes that provide useful functionality to CLR programmers. The .NET Framework class library exposes features of the runtime and simplifies the development of .NET-based applications. In addition, developers can extend classes by creating their own libraries of classes. All applications (Web, Windows, and XML Web services) access the same .NET Framework class libraries, which are held in namespaces. All .NET-based languages also access the same libraries.
The run time is responsible for managing your code and providing services to it while it executes, playing a role similar to that of the Visual Basic 6.0 run time.
The .NET programming languages including Visual Basic .NET, Microsoft Visual C# and C++ managed extensions and many other programming languages from various vendors utilize .NET services and features through a common set of unified classes.
The .NET unified classes provide foundation of which you build your applications, regardless of the language you use. Whether you simply concating a string, or building a windows Services or a multiple-tier web-based applications, you will be using these unified classes.
The unified classes provide a consistent method of accessing the platforms functionality. Once you learn to use the class library, you’ll find that all tasks follow the same uniform architecture, you no longer need to learn and master different API architecture to write your applications.
By building your applications on a unified, integrated framework, you maximize your return on the time you spend learning this framework, and you end up with more robust applications that are easy to deploy and maintain.
Class Libraries
The .NET Framework has an extensive set of class libraries. This includes classes for:
• Data Access: High Performance data· access classes for connecting to SQL Server or any other OLEDB provider.
• XML Supports: Next generation XML support that goes far beyond the functionality of MSXML.
• Directory Services: Support for accessing Active directory/LDPA using ADSI.
• Regular Expression: Support for above and beyond that found in Perl 5.
• Queuing Supports: Provides a clean object-oriented set of classes for working with MSMQ.
These class libraries use the CLR base class libraries for common functionality.
Garbage Collection
When you initialize a variable using the new operator, you are in fact asking the compiler to provide you some memory space in the heap memory. The compiler is said to “allocate” memory for your variable. When that variable is no longer needed, such as when your program closes, it (the variable) must be removed from memory and the space it was using can be made available to other variables or other programs. This is referred to as garbage collection. In the past, namely in C/C++, this was a concern for programmers because they usually had to remember to manually delete such a variable (a pointer) and free its memory.
The .NET Framework solves the problem of garbage collection by letting the compiler “clean” memory after you. This is done automatically when the compiler judges it necessary so that the programmer doesn’t need to worry about this issue.
Garbage collection is a mechanism that allows the computer to detect when an object can no longer is accessed. It then automatically releases the memory used by that object (as well as calling a clean-up routine, called a “finalizer,” which is written by the user). Some garbage collectors like the one used by .NET, compact memory and therefore decrease your program’s working set.
For most programmers, having a garbage collector (and using garbage collected objects) means that you never have to worry about deallocating memory, or reference counting objects, even if you use sophisticated .data .structures. It does require some changes in coding style, however, if you typically deallocate system resources (file handles, locks, and so forth) in the same block of code that releases the memory for an object. With a garbage collected object you should provide a method that releases the system resources deterministically (that is, under your program control) and let the garbage collector release the memory: when it compact the working set.
Just in Time Compiler(JIT)
Machines cannot run MSIL directly. JIT compiler turns MSIL into native code, which is CPU specific code that runs on the same computer architecture as the JIT compiler. Because the common. Language runtime supplies a JIT compiler for each supported CPU architecture, developers can write a set of MSIL that can be JIT-compiled and run on computers with different architectures.
However, your managed code will run only on a specific operating system if it calls platform specific native APIs, or a platform-specific class library.
JIT compilation takes into account the fact that some code might never get called during execution. Rather than using time and memory to convert all the MSIL in a portable executable (PE) file to native code, it converts the MSIL as needed during execution and stores the resulting native code so that it is accessible for subsequent calls.
The loader creates and attaches a stub to each of a type’s methods when the type is loaded. On the initial call to the method, the stub passes control to the JIT compiler, which converts the MSIL for that method into native code and modifies the stub to direct execution· to the location of the native code. Subsequent calls of the JIT -compiled method proceed directly to the native code that was previously generated, reducing the time it takes to JIT-compile and run the code.
Managed and Unmanaged Code
Managed code is code that is written to target the services of the common language runtime. In order· to target these services, the code must provide a minimum level of information (metadata) to the runtime. All C#, Visual Basic .NET, and JScript .NET code is managed by default. Visual Studio .NET C++ code is not managed by default, but the compiler can produce managed code by specifying a command-line switch (/CLR).
Microsoft Intermediate Language (MSIL)
A .NET programming language (C#, VB.NET, J# etc.) does not compile into executable code; instead it compiles into an intermediate code called Microsoft Intermediate Language (MSIL). As a programmer one need not worry about the syntax of MSIL – since our source code in automatically converted to MSIL. The MSIL code is then send to the CLR (Common Language Runtime) that converts the code to machine language which is then run on the host machine.
MSIL is similar to Java Byte code. A Java program is compiled into Java Byte code (the .class file) by a Java compiler, the class file is then sent to JVM which converts it into the host machine language.
Common Language Specification (CLS))
One of the obvious themes of .NET is unification and interoperability between various programming languages. In order to achieve this; certain rules must be laid and all the languages must follow these rules. In other words we can not have languages running around creating their own extensions and their own fancy new data types. CLS is the collection of the rules and constraints that every language (that seeks to achieve .NET compatibility) must follow.
The Common Language Specification is a set of basic language features (constructs and constraints) that serves as a guide for library writers and compiler writers. It allows libraries to be fully usable from any language supporting the CLS, and for those languages to integrate with each other. The Common Language Specification is a subset of the common type system. The CLS is actually a set of restrictions on the CTS. The CLS defines not only the types allowed in external calls, but the rules for using them, depending on the goal of the user.
Informally CLS is a simply a contract between programming language designers and class library authors. The CLS is basically just a subset of the entire set of features supported by the CLR. The CLS includes things such as calling virtual methods, overloading methods and does not include things such as unsigned types. CLS is weighted very heavily in favor of the library designers.
The Common Language Specification describes a common level of language functionality. The CLS is a set of rules that a language compiler must adhere to in order to create .NET applications that run in the CLR. Anyone who wants to write a .NET·-compliant compiler needs simply to adhere to these rules and that’s it. The relatively high minimum bar of the CLS enables the creation of a club of CLS-compliant languages. Each member of this club enjoys dual benefits: complete access to .NET framework functionality and rich interoperability with other compliant languages. For example a VB class can inherit from a C# class and override its virtual methods.
The common language specification (CLS) is a collection of rules and restrictions that allow interoperation between languages. Even though the CLI does not require compilers to follow CLS, code that follows the CLS rules is compatible with all other languages that follow the CLS rules.
Microsoft has defined three level of CLS compatibility/compliance. The goals and objectives of each compliance level have been set aside. The three compliance levels with their brief description are given below:
Compliant producer
The component developed in this type of language can be used by any other language.
Consumer
The language in this category can use classes produced in any other language. In simple words this means that the language can instantiate classes developed in other language. This is similar to how COM components can be i:=1stantiated by your ASP code.
Extender
Languages in this category can not just use the classes as in CONSUMER category; but can also extend classes using inheritance.
Languages that come with Microsoft Visual Studio namely Visual C++, Visual Basic and
C#; all satisfy the above three categories. Vendors can select any of the above categories as the targeted compliance level(s) for their languages.
Common Type System (CTS)
The language interoperability, and .NET Class Framework, are not possible without all the language sharing the same data types. What this means is that an “int” should mean the same in VB, VC++, C# and all other .NET compliant languages. Same idea follows for all the other data types. This is achieved through introduction of Common Type System (CTS).
Common type system (CTS) is an important part of the runtimes support for cross language integration. The common type system performs the following functions:
• Establishes a framework that enables cross-language integration, type safety, and high performance code execution.
• Provides an object-oriented model that supports the complete implementation of many programming languages.
The common type system supports two general categories of types:
1. Value types
Value types directly contain their data, and instances of value types are either allocated on the stack or allocated inline in a structure. Value types can be built-in, user-defined or enumerations types.
2. Reference types
Reference types stores a reference to the value’s memory address, and are allocated on the heap. Reference types can be self-describing types, pointers types, or interface types. The type of a reference type can be determined from values of self-describing types. Self-describing types are further split into arrays and class types are user-defined classes, boxed value types, and delegates.
CTS, much like Java, define every data type as a Class. Every .NET compliant language must stick to this definition. Since CTS defines every data type as a class; this means that only Object-Oriented (or Object-Based) languages can achieve .NET compliance. Given below is a list of most commonly used CTS supported data types:
Common Language Runtime (CLR)
The Common Language Runtime (CLR) is a very important part of the .NET Framework. At the base level, it is the infrastructure that executes applications, and allows them to interact with the other parts of the Framework. It also provides important capabilities in optimizing, securing, and providing many robust capabilities such as application deployment and side-by-side execution.
The CLR provides a number of services that include:
• Code management (loading and execution)
• Application memory isolation
Verification of type safety
• Conversion of IL to native code
• Access to metadata (enhanced type information)
• Managing memory for managed objects
• Enforcement of code access security
• Exception handling, including cross-language exceptions
• Interoperation between managed code, COM objects, and pre-existing DLLs (unman aged code and· data)
• Automation of object layout
• Support for developer services (profiling, debugging, and so on)
The activity of CLR is shown in figure that goes on when application is executed. The source code is compiled to IL (also refer as MSIL) while the metadata engine creates metadata information. IL and metadata are linked with other native code if required and the resultant code is saved. During execution IL, the IL code and any requirement from the base class library are brought together by the class loader. The’ combined code is tested for type-safety and then compiled by the JIT compiler to produce native machine code, which is sent to the runtime manager (code manager) for code execution.
Components of CLR
The common language runtime simplifies application development, provider a robust and secure execution environment, supports multiple language and simplifies application deployment and management. The environment is also referred to as a managed environment, one in which common services, such as garbage collection and security, are automatically provided. The common language runtime features are described in the following table:
Common Language Infrastructure (CLI)
The Common Language Infrastructure (CLI) is an open specification developed by Microsoft that describes the executable code and runtime environment that allows multiple high-level languages to be used on different computer platforms without being rewritten for specific architectures. CLR is Microsoft Commercial implementation of Common Language Infrastructure (CLI).
The Common Language Infrastructure (CLI) is a theoretical model of a development platform that provides a device and language independent way to express data and behavior of applications.
While the CLI primarily supports Object Oriented Programming (OOP) languages, procedural and functional languages are also supported. Through the CLI, languages can interoperate with each other and make use of a built-in garbage collector, security system, exception support, and a powerful framework.
What is Dot Net Framework
Microsoft officially defined .NET Framework as follows:
The .NET Framework is the heart of Microsoft .NET. The .NET Framework is a software development platform of Microsoft .NET. Like any platform, it provides a runtime, defines functionality in some libraries, and supports a set of programming languages. The .NET Framework provides the necessary compile-time and run-time foundation to build and run .NET-based applications.
The .NET Framework consists of:
• Common Language Runtime
• Class Libraries
• Support for Multiple Programming Language
The common language runtime (CLR) (also refer as runtime). The Common Language
Runtime is the core of Microsoft’s .NET vision. This is said to be the execution engine of .NET platform. The runtime (CLR) handles runtime services, including language integration, security, and memory management. During development, the runtime (CLR) provides features that are needed to simplify development.
Class libraries: Class libraries provide reusable code for most common tasks, including data access, XML Web service development, and Web and Windows Forms. The CLR Software Development Kit (SDK) provides the programming APIs in the form of a set of classes for building .NET applications. Collectively, they are referred to the Base Class Library, or BCL.
Through the classes in the BCL, we can interact with the runtime, influencing the way that the runtime’s services are provided to us. In addition to giving us an “in” to the runtime, the BCL classes provide a large number of useful utilities. These include things like a new database access library (ADO.NET), ASP.NET, and an XML parser with support for the latest XML specifications. In addition, developers can extend classes by creating their own libraries of classes. All applications (Web, Windows, and XML Web services) access the same .NET Framework class libraries, which are held in namespaces.
Support for multiple programming languages. Having a set of libraries and a runtime is good, but neither one of them is useful if you can’t write programs to take advantage of them. In order to do that, you need to use some programming language with a compiler that is runtime-aware. Microsoft currently lists over twenty different languages with which it will be possible to write software that targets the CLR. Microsoft itself ship support for five languages with the SDK: C#, Visual Basic.NET, IL, C++, and JScript.NET. Of these, C# and Visual Basic.NET are likely to be the languages most often used to develop software for this new platform. Any language that conforms to the Common Language Specification (CLS) can run with the common language runtime. Relying on the common language runtime, code compiled with compilers of .NET based languages can interoperate. All .NET-based languages also access the same libraries.
Features of .NET Framework
• It is a platform neutral framework.
• It is a layer between the operating system and the programming language.
• It supports many programming languages, including VB.NET, C# etc.
• .NET provides a common set of class libraries, which can be accessed from any .NET based programming language. There will not be separate set of classes and libraries for each language. If you know anyone .NET language, you can write code in any .NET language.
• In future versions of Windows, .NET will be freely distributed as part of operating system and users will never have to install .NET separately.
Application Development and Execution
Developing application:
Since Microsoft .NET is a Multilanguage platform then any.NET based language can be chosen to develop applications. Comfort ability of application programmers, specific requirement of applications may be the major factors in selection of language.
Choosing a Compiler
According to the language we can choose its run time aware compiler for .NET platform. Because it is a Multilanguage execution environment, the runtime supports a wide variety of data types and language features.
Compiling to MSIL
When compiling your source code, the compiler translates it into an intermediate code represented in Microsoft intermediate language (MSIL). Before code Can be run, MSIL code must be converted to CPU-specific code, usually by a just-in-time (JIT) compiler. When a compiler produces MSIL, it also produces metadata. Metadata includes following information.
• Description of the types in your code, including the definition of each type,
• The signatures of each type’s members,
• The members that your code references,
• Other data that the runtime uses at execution time.
The MSIL and metadata are contained in a portable executable (PE) file that is based on and extends the published Microsoft PE and common object file format (COFF) used historically for executable content. This file format, which accommodates MSIL or native code as well as metadata, enables the operating system to recognize common language runtime images.
The presence of metadata in the file along with the MSIL enables your code to describe itself. This composite file serves as a self describing unit to the .NET Framework Runtime is called Assembly. The runtime locates and extracts the metadata from the file as needed during execution.
JIT Compilation to Native code:
The MSIL code is compiled into native code by component of CLR named JIT Compiler.
JIT compiler intelligently guesses and compiles the intermediate code on piece by piece basis. This piece may be a method or a set of methods. Before a method can be run, it must be compiled to processor-specific code. Each method for which Microsoft intermediate language (MSIL) has been generated is just-in-time-compiled (JIT-compiled) when it is called for the first time, and then run. The next time the method is run, the existing JIT -compiled native code is run. The process of JIT -compiling and then executing the code is repeated until execution is complete.
Type Safety Checking
As part of compiling MSIL to native code, code must pass a verification process unless an administrator has established a security policy that allows code to bypass verification. Verification examines MSIL and metadata to find out whether the code is type safe, which means that it only accesses the memory locations it is authorized to access. Additionally, verification inspects code to determine whether the MSIL has been correctly generated, because incorrect MSIL can lead to a violation of the type safety rules .
The runtime relies on the fact that the following statements are true for code that is verifiably type safe:
• A reference to a type is strictly compatible with the type being referenced.
• Only appropriately defined operations are invoked on an object.
• Identities are what they claim to be.
If type-safe code is required by security policy and the code does not pass verification, an exception is thrown when the code is run.
Code execution under CLR
The common language runtime is responsible for providing following low-level execution services, such as garbage collection, exception handling, security services, and runtime type safety checking. Because of the common language runtime’s role in managing execution, programs that target the .NET Framework are sometimes called “managed” applications.
What is Dot Net
INTRODUCTION
The .NET is the technology from Microsoft, on which all other Microsoft technologies will be depending on in future. It is a major technology change, introduced by Microsoft, to catch the market from the SUN’s Java. Few years back, Microsoft had only VC++ and VB to compete with Java, but Java was catching the market very fast. With the world depending more and more on the Internet/ Web and java related tools becoming the best choice for the web applications, Microsoft seemed to be loosing the battle. Thousands of programmers moved to java from VC++ and VB. To recover the .market, .Microsoft announced .NET.
But Microsoft has a wonderful history of starting late but catching up quickly. This is true in case of .NET too. Microsoft put their best men at work for a secret project called Next Generation Windows Services (NGWS)., under the direct supervision of Mr. Bill Gates.
The outcome of the project is what we now know as .NET. Even though .NET has borrowed most of it’s ideas from Sun’s J2EE, it has really outperformed their competitors.
Microsoft’s VC++ was a powerful tool. But it was too complex. It has too many data types, and developers had to learn many libraries including Windows SDK, MFC, ATL, COM etc. There were many data type compatibility issues while exchanging data between different layers. Visual Basic was too easy, and many serious programmers hated it just for that reason. Even though Visual basic was very easy to use, it was not very flexible to develop serious applications. SUN’s Java became a very good choice for these reasons. It had the flexibility and power of C++ and at the same time easy enough to catch the attention of VB programmers.
Microsoft recognized these factors and they introduced the .NET considering all these factors. All unwanted complexities are eliminated and a pure object oriented programming model was introduced. This makes programmer’s life very easy.
.NET is said to be Microsoft development model in which software becomes platform and device independent and data becomes available over the internet. Due to this vision Microsoft .NET is also called Microsoft strategy for connecting systems, information and devices through web services so people can collaborate and communicates effectively.
The Microsoft .NET vision
The idea that all devices will some day be connected by a global broadband network
(Internet) and that software will become service provided over this network. “.NET” has been applied to everything from the next version of the Windows operating system to development tools.
Major Problems before .NET:
The following are the major problems in previous Microsoft Technologies faced by the developers for application development and deployment, which has been solved by the .NET:
Registration of COM components. COM components had to be registered on the target machine before they could be used by the application. The application had to look up the Windows registry to locate and load the COM components.
• Unloading COM components. COM objects also required a special logic for freeing up the objects from memory. This method is known as reference counting of COM objects. It is used to keep track of the number of active references. When an object’s reference count reaches zero, the object is removed from memory. The major problem that arises out of this situation is that of circular reference. If circular references exist between two COM components, they would not be freed from memory.
• Versioning Problem (DLL hell). Whenever applications that use COM components were installed on a machine, the installation process would update the registry with the COM components information. Thus, there was a chance that these DLLs would be overwritten when some other applications were installed on the same computer. Therefore, an application that had been referring to one particular DLL would refer to the wrong DLL. This caused a major problem when an application was referring to particular version of a DLL.
THE .NET PLATFORM
The .NET platform is a set of technologies. Microsoft .NET platform simplify software development (Windows or WEB) by building applications of XML Web services.
The.NET platform consists of the following core technologies:
• The .NET Framework
• The .NET Enterprise Servers
• Building block services
• Visual Studio .NET
A programming model (.NET Framework) that enables developers to build Extensible Markup Language (XML) Web services and applications.
A set of .NET Enterprise Servers, including Windows 2000, Microsoft SQL Server., and Microsoft BizTalk® Server, that integrate, run, operate, and manage XML Web services and applications.
The .NET Framework must run on an operating system. Currently, the .NET Framework is built to run on the Microsoft Win32® operating systems, such as’ Windows 2000, Windows XP, and Windows 98. When .NET Framework running on Windows 2000 then application services (such as Component Services, Message Queuing, Internet Information Services (IIS), and Windows Management Instrumentation (WMI) ) are available to the developers. The .NET Framework exposes application services through classes in the .NET Framework class library.
There are some client software such as Windows XP and Windows CE, which helps developers deliver a comprehensive user experience across a family of devices. A set of building block services that are a user-centric set of XML Web services that move control of user data from applications to users. For example, Microsoft Passport is a core component of the .NET initiative that makes it easier to integrate various applications.
XML Web services are programmable Web components that can be shared among applications on the Internet or the intranet. The .NET Framework provides tools and classes for building, testing, and distributing XML Web services.
Visual Studio .NET is a tool, which can be used to develop XML Web services and
Windows and Web applications for an enriched user experience.