Microsoft.NET platform. Architecture and Features Overview

Good day. Alexey Gulynin is in touch. In the last article, we learned about ways to pass arguments to a method in C#. In this article I would like to tell you again (more in simple words), which is .Net Framework and Visual Studio. This article is a continuation of the Visual Studio description and .Net Framework articles .Net Framework is a CLR (Common Language Runtime) environment. core component of the .Net Framework), which ensures the execution of managed code. The CLR manages this code. What is managed code? Code written for the platform. NET Framework is compiled not into final machine code, but into an intermediate language (the so-called IL - Intermediate Language). Then this assembly is transmitted to the user (the machine must have the .Net Framework installed), loaded into memory and translated IL commands into actions that need to be performed.

What's the point of intermediate language IL?

Firstly, it is platform independent, not tied to a specific processor.

Secondly, its presence allows the CLR to control the operation of your program, i.e. do not allow her to do any unacceptable things (for example, memory manipulation).

Second important component after CLR is Class Library. The .NET Framework includes a large number of classes, divided into namespaces, that provide all the basic functionality. This is the functionality that your program may require, for example, working with files, the network, processes, and the graphics subsystem.

Third component are Development Frameworks (in other words, development libraries). This includes libraries such as WPF (Windows Presentation Foundation), ASP.NET, Entity Framework, WCF (Windows Communication Foundation), Windows Store, etc. In fact, these are also classes. The difference is that these classes are designed to solve specific problems:

  • WPF - for working with graphical applications
  • ASP.NET - for working with web applications
  • WCF - for working with the network and creating distributed (client-server) applications
  • Entity Framework - for working with the database.

At the time of writing this article latest version is .Net Framework 4.6

The main development environment recommended by Microsoft is Visual Studio. Microsoft usually has this situation: how does it turn out? new version.NET Framework, then after a while a new version of Visual Studio comes out. What's included in Visual Studio (basic):

  1. Text editor with syntax code highlighting
  2. IntelliSence help system (called automatically or by a combination Ctrl keys+ Space (space)
  3. Compilers from different languages
  4. Rapid Application Development (RAD)
  5. Visual designer of interfaces, diagrams
  6. Component for working with servers and databases
  7. IIS web server and SQL server Express option
  8. Debuggers, profilers, components that allow you to handle errors
  9. MSDN Help System

As of this writing, the latest version is Visual Studio 2015.

How the concept of programs works in Visual Studio. In the studio there is the concept of “Project” and “Solution”. A project is a unit of compilation. It consists of a set of files. The entire project is usually compiled into an assembly (exe file or dll file). Projects can be grouped into Solution. A Solution is simply a collection of projects that may or may not be related to each other (usually they are).

One of the main principles of .NET can be expressed as follows: "Change whatever you want, using any means." The .NET platform is a completely new model for creating Windows applications. Let us briefly list the main provisions of .NET.

  • All possibilities of interaction with existing code. COM binaries work well with .NET binaries.
  • Complete and absolute interlingual interaction. Unlike classic COM, .NET supports cross-language inheritance, cross-language exception handling, and cross-language debugging.
  • A common runtime environment for any .NET application, no matter what language it was written in. And what's important is that all languages ​​use the same set of built-in data types.
  • A base class library that hides all the complexities associated with using API calls and provides a complete object model for all programming languages ​​that support .NET.
  • You can forget about the intricate COM structures! Interfaces IClassFactory, IUnknown, IDL code, and variant data types are not available in .NET programs.
  • Truly simplifying the application deployment process. In .NET, you do not need to register types in the registry. Moreover, .NET allows different versions the same DLL module can peacefully coexist on the same computer.

Advantages

  1. The entire .NET platform is based on a single object-oriented model. What does it mean? The fact is that all the services, interfaces and objects that the platform provides to the developer are combined into a single class hierarchy. In other words, everything you might need when creating applications for the .NET platform will always be at your fingertips. Moreover, all this is grouped very conveniently and intuitively.
  2. An application written in any .NET-compatible language is cross-platform (ideally). Why ideal? The fact is that an application written, say, in C#, does not depend on the platform on which it will be executed, but depends on the availability of the .NET platform. But you must admit that it is much easier to port the .NET architecture to any system once, and then run absolutely any .NET application without any problems. But at the moment, the .NET platform has been ported only to the Windows family of operating systems, including MS Windows mobile systems.
  3. The .NET platform includes the so-called. a "garbage collector" that frees resources. This way, applications are protected from memory leaks and the need to free resources. This makes programming easier and safer.
  4. .NET applications use metadata, which prevents them from using system registry Windows.
  5. Any .NET application is autonomous, in the sense that it does not depend on other programs, in particular on the OS. Installing an application written in one of the .NET languages ​​can be done by simply copying files (with the exception of creating shortcuts in Start and other places).
  6. .NET applications use safe types, which improves their reliability, compatibility, and cross-platform functionality.
  7. An application written in any .NET language interacts with a single error handling model, which greatly simplifies this tedious process.
  8. Applications written in different languages ​​can easily interact. For example, the server part can be written in C#, and the client part in Visual Basic.
  9. .NET applications can be certified for security. This is a feature of the intermediate code into which all .NET applications are converted.
  10. Absolutely all errors are processed by the exception mechanism. This avoids the friction that sometimes arose when programming under Win32.
  11. Code reuse has become even more convenient. This is because the intermediate language MSIL is independent of the programming language. For example, you can write a program in C#, and write a patch for it in, say, J#.

Flaws

Anyone software product has its drawbacks, and so does the .NET platform. You need to know them too.

  1. As is often the case, convenience comes at the cost of speed, and that’s what happened with .NET. Applications written for the .NET platform are slower, that's a fact. In some cases, the speed may drop by 15%, which is sometimes unacceptable (for example, when creating 3D applications where they fight for every FPS). Delays in execution are associated with the intermediate language MSIL, because it also takes time to compile it into an executable file. Of course, the application is not compiled all at once, but in parts, evenly as the program runs.
  2. Not every language can create .NET applications. The fact is that initially .NET was “tailored” for C/JAVA-like languages. This has created some difficulties in creating .NET compilers for other languages ​​(especially exotic and highly specialized ones). As a result, some functions had to be solved in non-trivial ways, which had a negative impact on performance. But gradually this disadvantage disappears, because Compiler developers have realized the importance of the .NET platform and are trying to make decent tools for their languages.
  3. The FrameWork library is required. This disadvantage eliminated with exit Windows Vista, because This library is built into the system by default.

You can pay attention to the fact that .NET has more advantages than disadvantages. Of course, this is not a reflection of reality. This indicates a good marketing campaign carried out by Microsoft.

The .NET Framework is one of the components Windows systems. It allows you to create and use next-generation applications. Purpose of the platform .NET Framework :

  • creation of a holistic object-oriented programming environment allowing various implementation options: the code can be stored and executed locally; be executed locally and distributed over the Internet; or performed remotely;
  • providing a code execution environment in which the number of deployment conflicts software and version control will be kept to a minimum;
  • ensuring the security of code execution in the environment - including code created by an unknown or partially trusted developer;
  • providing a code runtime environment to address performance issues in scripting or interpretation-based environments;
  • unification of the work of developers in completely different applications: as in Windows applications, and in web applications;
  • the use of industry standards in all areas of data exchange and, as a result, ensuring the compatibility of code created in the .NET Framework with other programs.

Annotation: Microsoft .NET Initiative. Compatibility, reliability and reuse components. .NET Framework. Common Language Runtime Environment (CLR). Pseudo-machine language CIL (controlled by assembler). JIT compiler. Programming languages. Assemblies. Metadata. Garbage collector. .NET Framework Class Library

Problems of developing modern information systems

Integration problems

  • Modules written in different languages, using different APIs (or API versions) or different data representation formats;
  • Programs developed for various platforms within a single software package;
  • Systems using different software models.

Integration problems with legacy code are especially common. When solving integration problems, incompatibility problems arise.

Portability issues

Increasingly, programs are required to support multiple platforms (for example, the ability to work with the program on the Windows and Mac OS platforms).

Version issues

Windows developers are aware of a version compatibility problem known as DLL hell. This "hell" occurs when components installed for a new application replace components of the old application. As a result, the old application starts to work incorrectly or stops working.

Resource Management

One of the problems of programming is the management and correct release of resources, files, memory, screen space, network connections, database resources, etc. Incorrect management of these resources can lead to incorrect program execution.

Type safety

When they mention a type safety problem, they mean incorrect handling of data types: attempts to access memory areas outside the boundary of the type, attempts to call methods that are not present on the type, or attempts to call a method that takes type A as a parameter and pass it as a parameter object type B.

Failure Handling

When developing Windows applications using the Win32 API, some functions return exceptions, others return status codes, and others return HRESULTs. Thus, there is no consistent mechanism for handling failures and it is possible to ignore some exceptions, which makes the code unsafe.

These and other development problems information systems The Microsoft .NET platform helps solve this problem.

Solving problems of developing information systems in .NET

One way to solve the problem of heterogeneity is to develop and support standard software interfaces, facilitating the task of transferring applications to servers of various platforms. However, applications may use databases, communications, and other services whose interfaces are not components of the programming language or environment. Another method used by manufacturers to solve the problem of heterogeneity is to support standard protocols. Systems supporting the same protocol can communicate with each other, even if they rely on different machine architectures and operating systems.

Technology. NET is a software development and deployment method that uses widely used standards such as HTTP and XML to enable program interoperability and provide access to numerous software services over the Internet. Technology includes. NET Framework is a platform for developing and executing applications that simplifies and speeds up development and supports full object-oriented programming for the Web, eliminates many types of the most common software errors, provides a common API for all languages.

What makes up Microsoft .NET

NET Framework - application development infrastructure. Its main components are the Common Language Runtime and a class library. NET Framework Class Library.

Common Language Runtime

Common Language Runtime (CLR) - a common language runtime that abstracts services operating system and executing managed applications, any action of which must be authorized by the CLR.

All code for the .NET platform is converted by the CLR to CIL intermediate code. Therefore, developers can easily integrate code written for .NET in various programming languages. Anything that can be done in one .NET-compatible language (with rare exceptions) can be done in any other. Code in these languages ​​is compiled into code in one language - CIL.

The CLR sits on top of the operating system and provides a virtual environment for managed applications. Code for the .NET platform is either executed by the CLR or is allowed to be executed outside of it.

The code for the CLR is in the form of Common Intermediate Language (CIL) pseudo-machine language commands. These instructions are compiled into machine code for the appropriate processor type on a just-in-time basis at runtime. Typically, a method is compiled once, the first time it is called. The result is then cached in memory to avoid delays in repeated calls. The JIT compiler optimizes code specifically for the processor on which the code is executed.

By converting CIL instructions into processor instructions, the JIT compiler verifies the code for type safety.

It is virtually impossible to execute a command that accesses an area of ​​memory that the command does not have permission to access. A managed application eliminates the problem of misinitialized pointers by preventing a type from being converted to something it is not, which is a type safety violation. The CLR does not allow methods to be called with a destroyed stack frame.

Resources allocated by managed code are freed by the garbage collector. In other words, the programmer only allocates memory, but does not free it - the CLR does this. The garbage collector keeps track of all references to objects created by the program, and destroys these objects when the memory they occupy is needed elsewhere. This resolves the problem of memory leaks in managed code applications.

Code verification is also the basis of the CLR's ability to run multiple applications within a single process. The process is divided into virtual compartments - application domains. This improves the efficiency of memory allocated to processes. Application domains are no less secure than processes because their boundaries cannot be violated by managed applications.

.NET Framework Class library (FCL)

.NET includes class library assemblies. NET Framework Class library (FCL), containing definitions of several thousand types, each of which provides some functionality. Sets of "related" types are collected into separate namespaces. Thus, the System namespace contains a base class, Object, from which all other types are ultimately derived.

Thus, every entity in. NET is an object with its own fields and methods.

In addition, System contains types for integers, characters, strings, exception handling, console input/output, a group of types for safe conversion from one type to another, data formatting, generation random numbers and performing mathematical operations. All applications use types from the System namespace.

To modify an existing FCL type, you can create your own derived type. You can create your own namespaces. All this will strictly comply with the principles proposed by the platform. NET

Here are some of the most common namespaces and brief description types contained there.

Basic FCL namespaces
Namespace Content
System Fundamental data types and helper classes
System.Collections Hash tables, variable arrays, and other containers
System.Data ADO .NET Classes for Data Access
System.Drawing Classes for graphics output (GDI+)
System.IO File and Stream I/O Classes
System.Net Classes for working with network protocols, for example with HTTP
System.Reflection Classes for reading and writing metadata
System.Runtime.Remoting Classes for distributed applications
System.ServiceProcess Classes for creating Windows services
System.Threading Classes for creating and managing threads
System.Web HTTP Support Classes
System.Web.Services Classes for developing web services
System.Web.Services. Classes for developing web service clients Protocols
System.Web.UI Main classes used by ASP .NET
System.Web.UI. WebControls ASP .NET Server Controls
System.Wndows.Forms Classes for GUI Applications
System.Xml Classes for reading and entering data in XML format

All managed applications use

Because. NET Framework is a powerful platform for application development, it makes it possible to develop applications of completely different types.

Desktop applications (applications that run on local computer user);

· web applications (applications that run within a web server and are accessible to the user through a browser under the HTTP/HTTPS protocol);

· web applications with rich user interface(applications that are delivered to the user via the HTTP/HTTPS protocol within the browser and executed on client side);

· web services (program code that runs on the server side and can be called from the client to receive any data or perform an operation);

· mobile applications (applications that run on mobile devices Oh).

For each of the following types of applications in the composition. NET Framework there are corresponding technologies that allow you to create applications. Besides, . NET Framework contains common libraries that can be used in different types applications. These libraries include the following libraries:

· for working with strings;

· for working with mathematical functions;

· for working with graphics;

· access to data;

· for working with files and other input/output operations;

· to perform cryptographic operations;

· to organize data synchronization between data sources;

· And huge amount other libraries.

Let's take an overview of each type of application. As noted above, for each type of application within the platform. NET Framework there are special project templates.

Desktop Applications differ in that they are launched directly on the user’s computer. This is the most common type of application. Desktop applications usually have access to the user's computer resources, such as hard drive, sound equipment, etc. The advantages of this type of application include interactivity user interface and the ability to operate the application regardless of network connection Internet and other resources. However, for such applications to work, they must be installed on the local computer.

Desktop applications can be divided into three types - window applications, console applications and services. Windows. Windowed applications have a graphical interface. Console applications usually look like command line, A interface Such applications are textual rather than graphical. Finally, the services Windows do not have a user interface at all, but work in the background.

To build applications with a windowed graphical interface within the platform. NET Framework technologies can be used Windows Forms (available starting from. NET Framework 1.0) and Windows Presentation Foundation(available starting from. NET Framework 3.0). The latest technology is newer and more promising.


Web Applications They differ from desktop ones in that they work remotely on a web server. User uses the capabilities of web applications via browser and protocol HTTP/HTTPS. The advantage of this type of application is that there is no need to install them on computer each user – application need to be installed on the web server, after which it becomes available to all users. However, the disadvantage of such applications is the limited ability to build user interfaces. This happens because user interface is based on formats HTML, CSS and JavaScript, which are quite limited. Therefore, the functionality of user interfaces is usually quite limited.

Since web applications have a serious drawback - limited capabilities By formation of the user interface - appeared new type applications called rich internet applications or Internet applications with a rich user interface (Rich Internet Applications, RIA). The ideology of these applications is that in browser special integration addition(plugin), which is capable of displaying additional content type. After this, when user opens the page in the browser, it is transmitted to the client side program code, which works within this add-on. Since in this case all the code runs on the client side, developers have more options By creating user interfaces.

There are several technologies available for building this type of application. One of the most famous technologies is Adobe technology Flash. In addition, there is also technology Microsoft Silverlight, which allows you to most conveniently integrate with other technologies within the framework. NET Framework.

Another type of application is services(or web services). Services are a certain program code that is located on the server and runs By request from the user. For example, you can create a set of services By working with data from databases, stored on the server. Typically, other types of applications (desktop applications, web applications, etc.) access services in order to perform some operation on the server or retrieve data from the server.

Within the platform. NET Framework there are a number of technologies that allow you to create services. The oldest technology is A.S.P..NET Web Services. It allows you to create simple web services that work By protocol HTTP/HTTPS. Further development was the technology Windows Communication Foundation(WCF). This platform is the most powerful and flexible tool that supports various types channels ( HTTP, TCP, named pipes, etc.) and significantly expands the developer’s capabilities By creation of services.

There are also additional branches of the WCF project - this is WCF Syndication Extensions (WCF REST) ​​and ADO.NET Data Services. These projects are designed to make it possible to conveniently build data access services.

Finally, the last type of application is mobile applications. Mobile applications work within mobile devices based on the operating system Windows Mobile . There are also implementations for a subset of capabilities for mobile devices. NET Framework, which is called. NET Compact Framework.

Thus, the entire range of technologies within the platform. NET Framework can be represented by the following diagram.

Share