0% found this document useful (0 votes)
9 views10 pages

Unit 1

.NET Framework is a managed environment that includes components like Common Language Runtime (CLR), Framework Class Library (FCL), and supports multiple programming languages such as C# and VB.NET. CLR provides services like memory management, security, and Just-In-Time (JIT) compilation, enabling efficient execution of .NET applications. The framework promotes cross-language interoperability and offers a rich set of libraries for various application functionalities.

Uploaded by

2303466160421
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views10 pages

Unit 1

.NET Framework is a managed environment that includes components like Common Language Runtime (CLR), Framework Class Library (FCL), and supports multiple programming languages such as C# and VB.NET. CLR provides services like memory management, security, and Just-In-Time (JIT) compilation, enabling efficient execution of .NET applications. The framework promotes cross-language interoperability and offers a rich set of libraries for various application functionalities.

Uploaded by

2303466160421
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

.

NET Architecture with its Diagram

Ans: .NET Framework is a managed environment. The


components are Common language runtime (CLR), Framework
Class Library (FCL), common component model, and common
types. It promotes C#, Visual Basic .NET, and many more .NET-
compatible languages.
● Managed Languages and Common Language Specification
(CLS):-
● .NET provides a platform for managed and unmanaged
programming languages. The applications which are run under the
.net platform are called managed environments and the
applications which are run outside the .net framework are called
unmanaged languages. Managed languages, such as C# and
VB.NET.
● Common Language Specification (CLS) is used to specify the
languages of .net ramework. It provides cross language
interoperability which is a subset of CTS. So, two or more
languages can be used in the same application using the .net
compatible.
● Common Language Runtime (CLR)
● .Net Framework provides an execution environment called
Common Language Runtime (CLR). It executes all the .net
programs under the .net environment. The code which runs under
the CLR is called a Managed Code. A common language runtime
provides an environment in which programs are executed. It is
responsible for process such as memory management and
reference counting of objects.
● Another feature is the garbage collector. CLR allocates the
memory for scope and de-allocates the memory if the scope is
completed.

● Common Type System (CTS)


● The Common Type System (CTS) is a catalog of .NET
types.System.Int32, System. Decimal, System. Boolean, and so
on. users have no need to use these types directly.
● In C# int n Var=0 there are two types of CTS: value types and
reference types. Value types are primitive types, which are
inherited from System.ValueType namespace and then System.
Object. Value types—are derived from System. Object, either
directly or indirectly. Value types are used as stack types of
memory. Objects are allocated on the stack. Reference types are
pointers and allocated on the heap type of memory.
● .NET Framework Class Library (FCL)
● The .NET Framework Class Library (FCL) provides system
services, File input/output; sockets, database access, remoting,
and XML. FCL has 7000 managed classes. For the classes of
input/output this can be found using the namespace “System.IO''.
FCL namespaces are nested types. It is delaminated with the dot
like System.Runtime.InteropServices,
System.Security.Permissions, and System.Windows.Forms are
examples of nested namespaces. The System namespace
provides classes for console input/output.

Describe the role for CLR.

CLR (Common Language Runtime) is basic component of .NET


Framework. It provides an environment to run .NET applications
on targeted machine. CLR provides environment for all .NET
languages compilers for converting source code into a common
language known as IL or MSIL or CIL.

CLR provides multiple services to execute processes, like memory


management service and security services. CLR performs multiple
tasks to manage the execution of .NET applications. Following
responsibilities of CLR are given below:

1. Automatic memory management


2. Code access security
3. Garbage collection
4. JIT compilation

1) Automatic memory management


CLR calls various predefined functions of .NET framework to
allocate and de-allocate memory of .NET objects. So that,
developers need not to write code to explicitly allocate and de-
allocate memory.

2) Code access security

CLR allows access to code to perform only those tasks for that it
has permission. It also checks user’s permissions using
authentication and configuration files of .NET applications.

3) Garbage collection

GC is used to prevent memory leaks or holes. Garbage collector


of CLR automatically determines the best time to free the memory,
which is allocated to an object for execution.

4) JIT compilation

JIT stands for Just In Time. It is also an important part of


Common Language Runtime (CLR), JIT compiler converts MSIL
code to targeted machine code for execution.

List out the features of .NET programming language.

1. Common Executive Environment:-

All .NET applications run under a common execution environment,


called the Common Language Runtime. The CLR facilitates the
interoperability between different .NET languages such as C#,
Visual Basic, Visual C++, etc. by providing a common environment
for the execution of code written in any of these languages.

2. Common Type System:-

The .NET framework follows types of systems to maintain data


integrity across the code written in different .NET compliant
programming languages. CTS ensures that objects of the
programs that are written in different programming languages can
communicate with each other to share data.

CTS prevents data loss when a type in one language transfers


data to its equivalent type in one language transfer data to its
equivalent type in other languages. For example, CTS ensures
that data is not lost while transferring an integer variable of visual
basic code to an integer variable of C# code.
The common type system CTS defines a set of types and rules
that are common to all languages targeted at the CLR. It supports
both value and reference types. Value types are created in the
stack and include all primitive types, structs, and enums. In
contrast, reference types are created in the managed heap and
include objects, arrays, collections, etc.

2. Multi-language support:-

.NET provides multi-language support by managing the compilers


that are used to convert the source to intermediate language (IL)
and from IL to native code, and it enforces program safety and
security.

The basis for multiple language support is the common type


system and metadata. The basic data types used by the CLR are
common to all languages. There are therefore no conversion
issues with the basic integer, floating-point and string types.

All languages deal with all data types in the same way. There is
also a mechanism for defining and managing new types.

3. Tool Support:-

The CLR works hand-in-hand with tools like visual studio,


compilers, debuggers, and profilers to make the developer's job
much simpler.
4. Security:-

The CLR manages system security through user and code identity
coupled with permission checks. The identity of the code can be
known and permission for the use of resources granted
accordingly. This type of security is a major feature of .NET. The
.NET framework also provides support for role-based security
using windows NT accounts and groups.

5. Automatic Resource Management:-

The .NET CLR provides efficient and automatic resource


management such as memory, screen space, network
connections, database, etc. CLR invokes various built-in functions
of
.NET framework to allocate and de-allocate the memory of .NET
objects.

Therefore, programmers need not write the code to explicitly


allocate and de-allocate memory to the program.

6. Easy and rich debugging support:-


The .NET IDE (integrated development environment) provides an
easy and rich debugging support. Once an exception occurs at run
time, the program stops and the IDE marks the line which contains
the error along with the details of that error and possible solutions.
The runtime also provides built-in stack walking facilities making it
much easier to locate bugs and error.

7. Simplified development:-

With .NET installing or uninstalling, a window-based application is


a matter of copying or deleting files. This possible because .NET
components are not referenced in the registry.

8. Framework class library:-

The framework class library (FCL) of the .NET framework contains


a rich collection of classes that are available for developers to use
these classes in code Microsoft has developed these classes to
fulfill various tasks of applications, such as working with files and
other data storages, performing input-output operations, web
services, data access, and drawing graphics.

The classes in the FCL are logically grouped under various


namespaces such as system, System.collections,
system.diagnostics, system.Globalization, system.IO, system.text
etc.

9. Portability:-

The application developed in the .NET environment is portable.


When the source code of a program written in a CLR compliant
language complies, it generates a machine-independent and
intermediate code. This was originally called the Microsoft
Intermediate Language(MSIL) and has now been renamed as the
common Intermediate Language (CIL). CIL is the key to portability
in .NET.

CLR Execution.

 Source code is written in any language that targets for. Net


framework is fed into the compiler
● The code which is run by CLR is called managed code.
● Here, Metadata is needed for the runtime to work with managed
code and the metadata generator generates this metadata
separately. The metadata contains details about the types, members
and references in the code. This information is most helpful to CLR
to locate classes, generate native code and provide security.
● MSIL file is in binary form and not in the form of machine code.
This format is the required one, to part any system running the .Net
framework.
● The output from MSIL is passed to the linker to generate physical
executable or portable executable files.
● The portable executable file is passed to the class loader and
output of this loader is verified and fed into the JIT compiler.
● At the same time classes required by the program are supplied by
the base class library to the class loader.
● Finally, the JIT compiler produces managed native code which is
passed on to the .NET runtime manager.
● JIT compilation process, which converts IL code to native code for
execution.

Figure- CLR Execution

Features of CLR:

1. .NET Framework Class Library support: Contains built-in types


and libraries to manage assemblies, memory, security, threading,
and other runtime system support
2. Debugging: Facilities for making it easier to debug code.
3. Exception management: Allows you to write code to create and
handle exceptions.
4. Execution management: Manages the execution of code
5. Garbage collection: Automatic memory management and garbage
collection
6. Interop: Backward-compatibility with COM and Win32 code.
7. Just-In-Time (JIT) compilation: An efficiency feature for ensuring
that the CLR only compiles code just before it executes
8. Security: Traditional role-based security support, in addition to
Code Access Security (CAS)
9. Thread management: Allows you to run multiple threads of
execution
10. Type loading: Finds and loads assemblies and types
11. Type safety: Ensures references match compatible types, which is
very useful for reliable and secure code.

Benefits of CLR:

● It improves the performance by providing a rich interact between


programs at run time.
● Enhance portability by removing the need of recompiling a
program on any operating system that supports it.
● Security also increases as it analyzes the MSIL instructions
whether they are safe or unsafe. Also, the use of delegates in
place of function pointers enhance the type safety and security.
● Support automatic memory management with the help of Garbage
Collector.
● Provides cross-language integration because CTS inside CLR
provides a common standard that activates the different
languages to extend and share each other’s libraries.
● Provides support to use the components that developed in other
.NET programming languages.
● Provide language, platform, and architecture independence.
● It allows easy creation of scalable and multithreaded applications,
as the developer has no need to think about the memory
management and security issues.

Difference between OOP, POP, Event Driven programming.


C# IDE layout
Integrated Development Environment (IDE) provides inbuilt compiler, debugger,
editors, and other easy development tools.
● Menu bar:
● Menu bars have commands of menus and sub menus to create code. It is
commonly used as buttons. It is customized so that as per the requirement
the buttons can be added.
● Tool Box:
● Tool Box contains Controls, Containers, Menu controls, Crystal Report
Controls, Data Controls, Dialogs boxes, Printer controls which are used to
design, form and interact with applications.
● Solution Explorer:
● Solution Explorer list of all the files associated with a project. It has options to
switch the design view to code view, form design, and refresh listed files.
Other project files are well maintained in a tree-like structure which is used in
Windows based GUI applications.
● Properties Window:
● Windows form properties lists the properties of a selected object. Users can
view the properties in alphabetical order and customized wise.
● Visual Basic Forms:
● To develop application visual basic forms are used; it also contains the coding
as well as the controls embedded in it. Forms are created by default when a
Project is created with a default name Form1. Each and every form has its
own Properties, Methods and Events. As per the requirement the form
properties name, caption can be changed. Multiple forms will be used in a
Project.
● Server Explorer:
● The Server Explorer used in the project to connect with the database and also
it can be accessed with resources. For example, connect to, view and access
the following resources:
o Database Connections
o Servers
o Crystal Reports
o Event Logs
o Message Queues
o Performance Counters
o Windows Services
Define: Namespace and write down the namespace classes.

Ans:In C#, namespaces are used to logically arrange classes,


structs, interfaces, enums and delegates. The namespaces in C#
can be nested. That means one namespace can contain other
namespaces also. The .NET framework already contains number
of standard namespaces like System, System.Net, System.IO etc.
In addition to these standard namespaces the user can define their
own namespaces.

Declaring a Namespace
The C# language provide a keyword namespace to create a user
defined name space. The general form of declaring a namespace
is as follows.

namespace <namespace_name>
{
// Classes and/or structs and/or enums etc.
}
The following are some of the standard namespaces in .NET framework.
● System: Contain classes that implement basic functionalities like mathematical
operations, data conversions etc.
● System.IO: Contains classes used for file I/O operations.
● System.Net: Contains class wrappers around underlying network protocols.
● System.Collections: Contains classes that implement collections of objects
such as lists, hashtable etc.
● System.Data: Contains classes that make up ADO.NET data access
architecture.
● System,Drawing: Contains classes that implement GUI functionalities.
● System.Threading: Contains classes that are used for multithreading
programming.
● System.Web: Classes that implement HTTP protocol to access web pages.
● System.Xml: Classes that are used for processing XML data.

You might also like