Introduction DOT NET TECHNOLOGY: (RGPV/June2009)
Introduction DOT NET TECHNOLOGY: (RGPV/June2009)
Introduction DOT NET TECHNOLOGY: (RGPV/June2009)
Unit-01/Lecture-01
Introduction to .NET Technology
Introduction DOT NET TECHNOLOGY: [RGPV/June2009]
The .NET platform is an integral component of the Microsoft Windows operating system for
building and running next generation software applications and Web services. The .NET
development framework provides a new and simplified model for programming and deploying
applications on the Windows platform. It provides such advantages as multiplatform
applications, automatic resource management, and simplification of application deployment. As
security is an essential part of .NET, it provides security support, such as code authenticity
check, resources access authorizations, declarative and imperative security, and cryptographic
security methods for embedding into the user’s application.
. .NET provides a simple object-oriented model to access most of the Windows application
programming interfaces (APIs). It also provides mechanisms by which you can use the existing
native code. In addition, it significantly extends the development platform by providing tools
and technologies to develop Internet-based distributed applications
Microsoft started development of .NET Framework in the late 1990s, originally under the name
of Next Generation Windows Services (NGWS). By late 2000, the first beta versions of .NET 1.0
were released.
Version 3.0 of .NET Framework is included with Windows Server 2008 and Windows Vista.
Version 3.5 is included with Windows 7 and Windows Server 2008 R2, and can also be installed
on Windows XP and Windows Server 2003.[2] On 12 April 2010, .NET Framework 4 was released
alongside Visual Studio 2010.
Unit-01/Lecture-02
Introduction to VB.NET
Microsoft currently supplies two main editions of IDE for developing in VB.NET: Microsoft
Visual Studio 2013, which is commercial software and Visual Studio Express Edition 2013,
which is free of charge. The command-line compiler, VBC.EXE, is installed as part of the
freeware .NET Framework SDK. Mono also includes a command-line VB.NET compiler.
VISUAL BASIC is a high level programming language which evolved from the earlier DOS
version called BASIC. BASIC means Beginners' All-purpose Symbolic Instruction Code. It is
a very easy programming language to learn. The code look a lot like English Language.
Different software companies produced different versions of BASIC, such as Microsoft
QBASIC, QUICKBASIC, GWBASIC, IBM BASICA and so on. Now, there are many versions of
VB exist in the market, the most popular one and still widely used by many VB
programmers is none other than Visual Basic 6. We also have VB.net, VB2005, VB2008.
VISUAL BASIC is a VISUAL and events driven Programming Language. These are the main
divergence from the old BASIC. In BASIC, programming is done in a text-only
environment and the program is executed sequentially. In VB, programming is done in a
graphical environment. In the old BASIC, you have to write program code for each
graphical object you wish to display it on screen, including its position and its color.
However, In VB , you just need to drag and drop any graphical object anywhere on the
form, and you can change its color any time using the properties windows.
On the other hand, because the user may click on certain object randomly, so each
object has to be programmed independently to be able to response to those actions
(events). Therefore, a VB Program is made up of many subprograms, each has its own
program code, and each can be executed independently and at the same time each can
be linked together in one way or another.
Example: simple program. First of all, you have to launch Microsoft Visual Basic 6.
Normally, a default form with the name Form1 will be available for you to start your new
project. Now, double click on Form1, the source code window for Form1 as shown the
top of the source code window consists of a list of objects and their associated events or
procedures. the object displayed is Form and the associated procedure is Load.
Statements can terminate with keywords such as "End If", instead of using "{}"s to
group statements.
Statements can also be terminated with a new line, instead of semicolons.
Round brackets are used with arrays, both to declare them and to get a value at a
given index in one of them.
The following is a very simple VB.NET program, a version of the classic "Hello world"
example created as a console application:
Module Module1
Sub Main()
Console.WriteLine ("Hello, world!")
End Sub
End Module
Because computer systems commonly require interaction between newer and older
applications, .NET Framework provides means to access functionality implemented in
newer and older programs that execute outside .NET environment. Access to COM
components is provided in the System.Runtime.Interop Services and System. Enterprise
Services namespaces of the framework; access to other functionality is achieved using
the P/Invoke feature.
The Common Language Runtime (CLR) serves as the execution engine of .NET
Framework. All .NET programs execute under the supervision of the CLR, guaranteeing
certain properties and behaviors in the areas of memory management, security, and
exception handling.
Language independence:-
.NET Framework introduces a Common Type System, or CTS. The CTS specification
defines all possible data types and programming constructs supported by the CLR and
how they may or may not interact with each other conforming to the Common
Language Infrastructure (CLI) specification. Because of this feature, .NET Framework
supports the exchange of types and object instances between libraries and applications
written using any conforming .NET language.
The Framework Class Library (FCL) is a library of functionality available to all languages
using .NET Framework. The FCL provides classes that encapsulate a number of common
functions, including file reading and writing, graphic rendering, database interaction,
XML document manipulation, and so on. It consists of classes, interfaces of reusable
types that integrates with CLR (Common Language Runtime).
Simplified deployment:-
.NET Framework includes design features and tools which help manage the installation
of computer software to ensure it does not interfere with previously installed software,
and it conforms to security requirements.
Security:-
The design addresses some of the vulnerabilities, such as buffer overflows, which have
been exploited by malicious software. Additionally, .NET provides a common security
model for all applications.
Portability:-
While Microsoft has never implemented the full framework on any system except
Microsoft Windows, it has engineered the framework to be platform-agnostic and cross-
platform implementations are available for other operating systems . Microsoft
submitted the specifications for the Common Language Infrastructure (which includes
the core class libraries, Common Type System, and the Common Intermediate
Language).
Memory management:-
.NET Framework CLR frees the developer from the burden of managing memory
(allocating and freeing up when done); it handles memory management itself by
detecting when memory can be safely freed. Instantiations of .NET types (objects)
are allocated from the managed heap; a pool of memory managed by the CLR. As
long as there exists a reference to an object, which might be either a direct
reference to an object or via a graph of objects, the object is considered to be in
use. When there is no reference to an object, and it cannot be reached or used, it
becomes garbage, eligible for collection. .
S.NO RGPV QUESTIONS Year Marks
Q.3 Briefly describe the VB.NET and also explain the June2010 10
features of VB.NET.
Unit-01/Lecture-03
Software development and Visual Basic .NET and versions
Software development:-
Software engineering is not easy to define; indeed, many argue that it is not a form of
engineering at all and that its designers are not really engineers. But software developers are
engineers and include in their ranks many professionals with formal training and experience.
According to Webster's dictionary, engineering is the application of mathematical and scientific
principles to practical ends, as the design, construction, and operation of efficient structures,
equipment, and systems.
The software industry emerged in the mid−20 th century with the advent of the modern
computer and has progressed through three distinct "ages" since then:
As software systems grew, programmers needed to manage and maintain them more
efficiently. The structure−oriented age introduced a paradigm in which the functions were
organized in structures a module containing procedures and data. In other words, the unit or
level of abstraction became the module rather than the individual procedure. Structural
programming lends itself to encapsulation, data−centric programming, collections of like
routines, and object−like programming.
By the end of the 1960s it became apparent that the ever−growing complexity of software
systems would necessitate a new model, one that was more humanly
Manageable and comprehensible. Now almost half a century after the first object−oriented
software language, Simula, was created, the OO age has finally taken hold in response to this
complexity. OO lets us model and design software systems around familiar concepts (objects)
behind which complexity is hidden through abstraction, much like the abstraction found in
nature. The focus of programming is mostly on attributes and data rather than computations or
calculations. Encapsulation
and other features have been refined, and continue to be refined, to better serve the OO
model.
Structured Programming:-
Program flow follows a simple hierarchical model that employs looping constructs such as "for,"
"repeat," and "while." Use of the "Go To" statement is discouraged.
Bug−Reduced Code:-
The boundaries of buggy code are within the confines of a module, which is usually the
responsibility of one programmer. It is much easier to detect a bug in a module through
isolation than in a file containing a single mega−procedure. Once the bugs are dispatched from
the modules, the pest−free code can then be reused in other parts of the application.
The strongest Roman emperors realized that the solution to conquering their enemies was to
divide the armies of resisters and then conquer the smaller units. Modern analytical problem−
solving techniques teach the same approach, as do many successful algorithm masters. The
best way to solve a problem is to restate it in as many ways as you possibly can; this helps
identify the "real" problem, which you then break down into smaller components.
Reuse:-
Contrary to what many OO purists claim, reuse became the battle cry of software professionals
long before the rise of object−orientation. The idea even predates the industrial revolution,
which heralded the effort to make better products through faster and cheaper means.
Object−Based Programming:-
If you expected to find encapsulation on the list, you might be surprised. Let's consider some of
the points made earlier. Encapsulation is often cited as one of the three most important tenets
of an OO language (inheritance and polymorphism are the other two). But while it is vital to OO,
encapsulation is really a trait of all modern programming methodology, adopted without
question by OOP from both object−based programming and structured programming practice.
Encapsulation was certainly supported in the earlier versions of Visual Basic. Therefore,
inheritance and polymorphism are the two critical enabling features of all true OO languages.
Visual Basic now supports both.
Versions:- [RGPV/Dec2011]
Succeeding the classic Visual Basic version 6.0, the first version of Visual Basic .NET debuted in
2002. As of 2014, seven versions of Visual Basic .NET are released.
The first version, Visual Basic .NET, relies on .NET Framework 1.0. The most important feature is
managed code, which contrasts with the classic Visual Basic.
Visual Basic .NET 2003 was released with .NET Framework 1.1. New features included support
for the .NET Compact Framework and a better VB upgrade wizard. Improvements were also
made to the performance and reliability of .NET IDE (particularly the background compiler) and
runtime. In addition, Visual Basic .NET 2003 was available in the Visual Studio.NET Academic
Edition, distributed to a certain number of scholars from each country without cost.
2005 (VB 8.0)
After Visual Basic .NET 2003, Microsoft dropped ".NET" from the name of the product, calling
the next version Visual Basic 2005.
For this release, Microsoft added many features intended to reinforce Visual Basic .NET's focus
as a rapid application development platform and further differentiate it from C#., including:
o Easy access to certain areas of the .NET Framework that otherwise require
significant code to access Dynamically generated classes (e.g. My.Forms)
A "using" keyword, simplifying the use of objects that require the Dispose pattern to
free resources
Just My Code feature, which hides (steps over) boilerplate code written by the Visual
Studio .NET IDE and system library code during debugging
To bridge the gaps between itself and other .NET languages, this version added:
Generics
Partial classes, a method of defining some parts of a class in one file and then adding
more definitions later; particularly useful for integrating user code with auto-generated
code
Support for unsigned integer data types commonly used in other languages
Visual Basic 2005 introduced the IsNot operator that makes 'If X IsNot Y' equivalent to 'If Not X
Is Y'. It gained notoriety when it was found to be the subject of a Microsoft patent application.
Visual Basic 9.0 was released along with .NET Framework 3.5 on 19 November 2007.
For this release, Microsoft added many features, including:
Lambda expressions
XML Literals
Type Inference
Extension methods
In April 2010, Microsoft released Visual Basic 2010. Microsoft had planned to use Dynamic
Language Runtime (DLR) for that release but shifted to a co-evolution strategy between Visual
Basic and sister language C# to bring both languages into closer parity with one another. Visual
Basic's innate ability to interact dynamically with CLR and COM objects has been enhanced to
work with dynamic languages built on the DLR such as IronPython and IronRuby. The Visual
Basic compiler was improved to infer line continuation in a set of common contexts, in many
cases removing the need for the "_" line continuation character. Also, existing support of inline
Functions was complemented with support for inline Subs as well as multi-line versions of both
Sub and Function lambdas.
Visual Basic .NET 2012 was released along .NET Framework 4.5. Major features introduced in
this version include:
Call hierarchy
Caller information
This topic gives the requirements for Studio Enterprise Edition Windows Components.
Hardware Requirements
Processor: Must be at least the minimum specified for the operating system you are
using and for Visual Studio.
Memory: Must be at least the minimum specified for the operating system you are
using.
Disk space:
Studio Enterprise Edition has additional hardware requirements the same as for
Microsoft Visual Studio. See the Visual Studio documentation for details.
Software Requirements
o Windows Vista
o Windows XP Professional
Microsoft Visual Studio 2008 Service Pack 1 or Microsoft Visual Studio Shell 2008. Note
that Microsoft Visual Studio Express Edition is not supported.
Microsoft Windows SDK is required if you are using Visual Studio Shell 2008. See the
Microsoft Download site and search for Windows SDK.
Microsoft .NET Framework 3.5. This is included with the above versions of Visual Studio.
The Java Development Kit (JDK) is required for compiling Java. The JDK is downloadable
from the Sun Web site. After installing the JDK, you must put the tools.jar file for the JDK
on your classpath, using a command similar to:
A Web browser, such as Microsoft Internet Explorer 6.0 or Netscape Navigator 6.1., is
required for Enterprise Server Administration in Server Enterprise Edition.
To use Enterprise Server Administration, scripting or JavaScript support must be enabled
in your browser. This is on by default in Internet Explorer in most Windows operating
systems, apart from Windows 2003. Also, active content must be allowed and not
blocked. To enable both these in Internet Explorer:
2. On the Security tab, click Custom Level. In the Scripting section, under Active
Scripting, click Enable.
3. On the Advanced tab, scroll down the list to the Security section, and ensure the
item Allow active content to run in files on My Computer is checked.
Enterprise Server Help requires the Sun Java Run-time Environment on some Windows
systems to enable the Search facility to work. See Third Party Software
Q.1 Write down Microsoft .NET versions released up to 2010 with Dec2011 10
version name, version number and release date.
.NET Framework (pronounced dot net) is a software framework developed by Microsoft that runs
primarily on Microsoft Windows. It includes a large library and provides language interoperability
(each language can use code written in other languages) across several programming languages.
Programs written for .NET Framework execute in a software environment (as contrasted to
hardware environment), known as the Common Language Runtime (CLR), an application virtual
machine that provides services such as security, memory management, and exception handling.
The class library and the CLR together constitute .NET Framework.
.NET Framework's Framework Class Library provides user interface, data access, database
connectivity, cryptography, web application development, numeric algorithms, and network
communications. Programmers produce software by combining their own source code with .NET
Framework and other libraries. .NET Framework is intended to be used by most new applications
created for the Windows platform. Microsoft also produces an integrated development
environment largely for .NET software called Visual Studio.
Microsoft .NET Framework 4 is Microsoft's comprehensive and consistent programming model for
building applications that have secure communication and the ability to model a range of business
processes. It provides improvements in Common Language Runtime (CLR) and Base Class Library
(BCL), new memory mapped file and numeric types, innovations in the Visual Basic and C#
languages, and support for Windows 7 multi-touch, ribbon controls, taskbar extensibility features,
and Surface 2.0 SDK. WCF Data Services is a component of the .NET Framework that enables you
to create REST-based services and applications that use the Open Data Protocol (OData) to expose
and consume data over the Web.
The .NET Framework is a technology that supports building and running the next generation of
applications and XML Web services. The .NET Framework is designed to fulfill the following
objectives:
To make the developer experience consistent across widely varying types of applications,
such as Windows-based applications and Web-based applications.
To build all communication on industry standards to ensure that code based on the .NET
Framework can integrate with any other code.
The developer writes source code in any .NET language i.e. it may VB.NET or C# or VC+++.NET, etc.
The source code is compiled to Intermediate code known as IL code by the respective compilers
for example for C# it is csc.exe compiler, for VB.NET it is vbc.exe compiler, etc. This half compiled
code is then given to JIT(just in time compiler) by CLR which converts IL code to machine specific
instructions which then gets executed. In this way a .NET code gets compiled. For better
understanding have a look to following diagram :
MSIL Code :
The word IL Code stands for Intermediate Language Code. It is a CPU independent partially
compiled code. When we develop our .NET application, we don’t know in what kind of
environment our code will run i.e. on which operating system it will be finally hosted, what will
be the CPU configuration, etc. So for this purpose we have IL code which is compiled according
to machine configuration. IL code is given by Language compiler which is different for different
languages for example csc.exe compiler for C#, vbc.exe compiler for VB.NET, etc.
The common language runtime manages memory, thread execution, code execution, code
safety verification, compilation, and other system services. These features are intrinsic to the
managed code that runs on the common language runtime.
With regards to security, managed components are awarded varying degrees of trust,
depending on a number of factors that include their origin (such as the Internet, enterprise
network, or local computer). This means that a managed component might or might not be
able to perform file-access operations, registry-access operations, or other sensitive functions,
even if it is being used in the same active application.
The runtime enforces code access security. For example, users can trust that an executable
embedded in a Web page can play an animation on screen or sing a song, but cannot access
their personal data, file system, or network. The security features of the runtime thus enable
legitimate Internet-deployed software to be exceptionally feature rich.
CLR stands for Common Language Runtime. It is the heart of our .NET Framework. CLR
performs following tasks :
1. Garbage Collection :
When we run our .NET application, many objects are created. Garbage collection is a
background process which deletes the objects which are not in use by the application and
frees memory.
CLR checks the whether the code has access rights and it is safe and authenticated to be
used.
3. IL to Native Translation :
The main task of CLR is to provide IL code to JIT to ensure that code is fully compiled as per
machine specification.
Performance improvements.
The ability to easily use components developed in other languages.
Support for explicit free threading that allows creation of multithreaded, scalable
applications.
Use of delegates instead of function pointers for increased type safety and security.
For more information about delegates, see Common Type System.
CTS stands for Common Types System. In .NET we have various languages like C#, VB.NET,
etc. There may be many situations where we want code written in one language to be used
in another. In order to ensure that we have a smooth communication between different
languages, we have CTS. CTS ensures that data types defined in two different languages
get compiled to a common data type so that code written in one language can be used by
another.
CLS stands for Common Language Specifications. It is a subset of CTS. CLS is a set of rules or
guidelines which if followed ensures that code written in one .NET language can be used by
another .NET language. For example one rule is that we cannot have member functions
with same name with case difference only i.e we should not have add() and Add(). This
may work in C# because it is case-sensitive but if try to use that C# code in VB.NET, it is not
possible because VB.NET is not case-sensitive.
It describes the minimal and complete set of features to produce code that can be hosted by CLR.
It ensures that products of compilers will work properly in .NET environment.
Sample Rules:
4. Microsoft has defined CLS which are nothing but guidelines that language to follow so
JIT stands for Just In Timer Compiler. It is the internal compiler of .NET which takes IL code
from CLR and executes it to machine specific instructions.
Q.1 What are the features of .NET? Explain the CTS. June2009 10
Q.2 Describe .NET framework with their components (CTS, CLS, Dec 2011 10
and CLR).
Q.5 Explain the following terms: MSIL, CLR, CTS, Object code. Dec.2013 7
Unit-01/Lecture-05
Comparison between VB.Net and VB 6.0 and Similarity between java and
.NET[RGPV/june2009]
The current VB6 code base will not run under VB.NET due to changes in VB.NET's syntax and language,
its use of the new common runtime, and its switch to WinForms from the VB6 form model. Visual
Basic.NET includes an upgrade tool to assist in converting VB6 projects to .NET. The tool adds an
upgrade report to your project listing any problems and inserts comments into your code and To Do
items into the new Task List indicating where additional changes need to be made.
Variable Declaration:-
Always declare variables on separate lines. I always thought this to be good practice anyway.
This statement, however, declares lngOne as a Variant (which is not supported in .NET) and
lngTwo as a Long.
Data Types:-
Since VB.NET uses a common runtime among Visual Studio languages, data types in VB
needed to be brought into line with those of other languages. Here are some of the data type
changes.
VB.NET no longer supports the Variant and Currency data types. VB documentation has always
warned to minimize your use of variants. In .Net they are not supported. Use the object data
type instead.
The currency data type stores values as 64-bit integers, scaled by 10,000 to give a fixed-point
number with 15 digits to the left of the decimal point and 4 digits to the right. In VB.NET you
can replace currency variables with the new 64-bit Long variable or the 64-bit decimal data type.
Deprecated Commands:-
VB.NET no longer supports the VarPtr, ObjPtr and StrPtr functions which retrieved the
underlying memory address of variables. It also no longer supports the LSet command which
was used to convert one user defined type to another.
Some defunct keywords are: GoSub, Let, Is Missing, DefBool, DefByte, DefLng, DefCur,
DefSng, DefDbl, DefDec, DefDate, DefStr, DefObj and DefVar as well as On x Goto.
becomes:
objObject = objAnotherObject
Debug.Print
to:
Debug.Write
Debug.WriteLine
Array:-
Gives you 6 items from index 0 to index 5. In VB.NET, this same declaration will yield 5
elements from index 0 through index 4. Be on the look out for "out of bounds" type errors. Also,
all arrays in .NET must now be zero-based.
Default Properties:-
VB6 allows you to reference the default property of a control or object without specifying the
name of the property. VB.NET disallows this.
txtMyText = "Hello"
rst!("name") = "Dave"
rst!name = "Dave"
txtMyText.text = "Hello"
rst!("name").value = "Dave"
rst!name.value = "Dave"
Controls on a form are no longer public in VB.NET. Thus, form2 cannot reference
form1.text1.text. What you now need to do is add public Let and Get property procedures to the
form for each control property you want to reference from another form. By the way, Let is no
longer supported, read on for more info.
You can also declare the control you want to reference as Public Shared but that is not the
recommended approach.
The VB Integrated Development Environment (IDE) is now fully integrated with the Visual
Studio.NET IDE. Thus VB.NET has a new language-neutral extensibility model. VB.NET add-ins
are now VS.NET add-ins. While this lets you create a VB.NET add-in that changes a Visual C#
form, your existing add-ins need to change to reflect the new extensibility model.
Parameters:-
Parameters can be passed to a procedure in one of two ways. Either by reference (ByRef) or by
value (ByVal). When you use the by reference method, changes made to parameters' values in a
sub procedure are known when control returns back to the calling procedure.
ByRef is the default method of parameter passing in VB6 and prior versions when the
parameter's data type is an intrinsic one such as Integer, Long, Boolean, String, etc.
Then second method is pass by value (ByVal). This is the default for all non-intrinsic data types.
When passed by value, the calling procedure knows nothing about changes made to the
parameter's value in a sub procedure.
VB.NET passes all parameters ByVal. Thus, don't rely on the default behavior and always
explicitly specify ByVal or ByRef in your parameter lists.
Similarities
Both offer different tools & ways to achieve the same goal.
Very difficult to compare and qualify the comparison because each has its
own advantages & disadvantages.
MS says: “C# combines the power of VC++ with the ease of usage of VB”
Significant features include garbage collection, hierarchical namespaces) are present in both.
Java runs on any platform with a Java VM. C# only runs in Windows for the foreseeable future.
Unit-01/Lecture-06
Architecture of .Net, Three Tier Architecture
Architecture of .Net:- [RGPV/June2011]
Common Language Runtime (CLR): The heart of the .Net Framework. It is also called
the .Net runtime. It resides above the operating system and handles all .Net applications. It
handles garbage collection, Code Access Security (CAS) etc.
1. Microsoft Intermediate Language (MSIL) Code: When we compile our .Net code then it
is not directly converted to native/binary code; it is first converted into intermediate
code known as MSIL code which is then interpreted by the CLR. MSIL is independent of
hardware and the operating system. Cross language relationships are possible since
MSIL is the same for all .Net languages. MSIL is further converted into native code.
2. Just in Time Compilers (JIT): It compiles IL code into native executable code (exe or dlls).
Once code is converted to IL then it can be called again by JIT instead of recompiling
that code.
3. Framework class library: The .Net Framework provides a huge class library called FCL
for common tasks. It contains thousands of classes to access Windows APIs and
common functions like string manipulations, Data structures, stream, IO, thread,
security etc.
5. Common Type System (CTS): CTS defines some basic data types that IL can understand.
Each .Net compliant language should map its data types to these standard data types.
This makes it possible for two .Net compliant languages to communicate by
passing/receiving parameters to and from each other. For example CTS defines Int32
for C# int and VB integer data types.
This article explains how to create and implement a 3-tier architecture for our project in
ASP.Net.
What is a Layer?
A layer is a reusable portion of code that performs a specific function. In the .NET environment,
a layer is usually set up as a project that represents this specific function. This specific layer is
in charge of working with other layers to perform some specific goal.Let’s briefly look at the
latter situation first.
Data Layer:-
A DAL contains methods that help the Business Layer to connect the data and perform required
actions, whether to return data or to manipulate data (insert, update, delete and so on).
Business Layer:-
A BAL contains business logic, validations or calculations related to the data.Though a web site
could talk to the data access layer directly, it usually goes through another layer called the
Business Layer. The Business Layer is vital in that it validates the input conditions before calling
a method from the data layer. This ensures the data input is correct before proceeding, and can
often ensure that the outputs are correct as well. This validation of input is called business
rules, meaning the rules that the Business Layer uses to make “judgments” about the data.
Presentation Layer:-
The Presentation Layer contains pages like .aspx or Windows Forms forms where data is
presented to the user or input is taken from the user. The ASP.NET web site or Windows Forms
application (the UI for the project) is called the Presentation Layer. The Presentation Layer is
the most important layer simply because it’s the one that everyone sees and uses. Even with a
well structured business and data layer, if the Presentation Layer is designed poorly, this gives
the users a poor view of the system.
The main characteristic of a Host Architecture is that the application and databases reside on
the same host computer and the user interacts with the host using an unfriendly dumb
terminal. This architecture does not support distributed computing (the host applications are
unable to connect to a database of a strategically allied partner). Some managers find that
developing a host application takes too long and it is expensive. These disadvantages
consequently led to a Client-Server architecture.
A Client-Server architecture is a 2-Tier architecture because the client does not distinguish
between Presentation Layer and Business Layer. The increasing demands on GUI controls
caused difficulty in managing the mixture of source code from a GUI and the Business Logic
(Spaghetti Code). Further, the Client Server Architecture does not support enough the Change
Management. Let us suppose that the government increases the Entertainment tax rate from
4% to 8 %, then in the Client-Server case, we need to send an update to each client and they
must update synchronously on a specific time otherwise we may store invalid or incorrect
information. The Client-Server Architecture is also a burden to network traffic and resources.
Let us assume that about five hundred clients are working on a data server. Then we will have
five hundred ODBC connections and several ruffian record sets that must be transported from
the server to the clients (because the Business Layer remains in the client side). The fact that
Client-Server does not have any caching facilities like in ASP.NET causes additional traffic in the
network. Normally, a server has better hardware than the client, therefore it is able to compute
algorithms faster than a client, so this fact is also an additional argument in favor of the 3-Tier
Architecture. This categorization of the application makes the function more reusable easily
and it becomes too easy to find the functions that have been written previously. If a
programmer wants to make further updates in the application then he can easily understand
the previous written code and can update it easily.
S.NO RGPV QUESTIONS Year Marks
Assemblies are the building blocks of .NET Framework applications; they form the fundamental
unit of deployment, version control, reuse, activation scoping, and security permissions. An
assembly is a collection of types and resources that are built to work together and form a logical
unit of functionality. An assembly provides the common language runtime with the information
it needs to be aware of type implementations. To the runtime, a type does not exist outside the
context of an assembly.
It contains code that the common language runtime executes. Microsoft intermediate
language (MSIL) code in a portable executable (PE) file will not be executed if it does not
have an associated assembly manifest. Note that each assembly can have only one entry
point (that is, DllMain, WinMain, or Main).
It forms a security boundary. An assembly is the unit at which permissions are requested
and granted. For more information about security boundaries as they apply to
assemblies, see Assembly Security Considerations.
It forms a type boundary. Every type's identity includes the name of the assembly in
which it resides. A type called MyType that is loaded in the scope of one assembly is not
the same as a type called MyType that is loaded in the scope of another assembly.
It forms a version boundary. The assembly is the smallest versionable unit in the
common language runtime; all types and resources in the same assembly are versioned
as a unit. The assembly's manifest describes the version dependencies you specify for
any dependent assemblies. For more information about versioning, see Assembly
Versioning.
It forms a deployment unit. When an application starts, only the assemblies that the
application initially calls must be present. Other assemblies, such as localization
resources or assemblies containing utility classes, can be retrieved on demand. This
allows applications to be kept simple and thin when first downloaded. For more
information about deploying assemblies, see Deploying Applications.
It is the unit at which side-by-side execution is supported. For more information about
running multiple versions of an assembly, see Assemblies and Side-by-Side Execution.
Assemblies can be static or dynamic. Static assemblies can include .NET Framework types
(interfaces and classes), as well as resources for the assembly (bitmaps, JPEG files, resource
files, and so on). Static assemblies are stored on disk in portable executable (PE) files. You can
also use the .NET Framework to create dynamic assemblies, which are run directly from
memory and are not saved to disk before execution. You can save dynamic assemblies to disk
after they have executed.
There are several ways to create assemblies. You can use development tools, such as Visual
Studio, that you have used in the past to create .dll or .exe files. You can use tools provided in
the Windows Software Development Kit (SDK) to create assemblies with modules created in
other development environments. You can also use common language runtime APIs, such as
Reflection.Emit, to create dynamic assemblies.
End users and developers are familiar with versioning and deployment issues that arise from
today's component-based systems. Some end users have experienced the frustration of
installing a new application on their computer, only to find that an existing application has
suddenly stopped working. Many developers have spent countless hours trying to keep all
necessary registry entries consistent in order to activate a COM class.
Many deployment problems have been solved by the use of assemblies in the .NET Framework.
Because they are self-describing components that have no dependencies on registry entries,
assemblies enable zero-impact application installation. They also simplify uninstalling and
replicating applications.
1. Private Assemblies:-
The assembly is intended only for one application. The files of that assembly must be placed in
the same folder as the application or in a sub folder. No other application will be able to make a
call to this assembly. The advantage of having a private assembly is that, it makes naming the
assembly very easy, since the developer need not worry about name clashes with other
assemblies. As long as the assembly has a unique name within the concerned application, there
won't be any problem.
2. Shared Assemblies:-
If the assembly is to be made into a Shared Assembly, then the naming conventions are very
strict since it has to be unique across the entire system. The naming conventions should also
take care of newer versions of the component being shipped. These are accomplished by giving
the assembly a Shared Name. Then the assembly is placed in the global assembly cache, which
is a folder in the file system reserved for shared assemblies.
A namespace is a logical naming scheme for types in which a simple type name, such as My
Type, is preceded with a dot-separated hierarchical name. Such a naming scheme is completely
under control of the developer. For example, types MyCompany.FileAccess.A and
MyCompany.FileAccess.B might be logically expected to have functionally related to file access.
The .NET Framework uses a hierarchical naming scheme for grouping types into logical
categories of related functionality, such as the ASP.NET application framework, or remoting
functionality. Design tools can make use of namespaces to make it easier for developers to
browse and reference types in their code. The concept of a namespace is not related to that of
an assembly. A single assembly may contain types whose hierarchical names have different
namespace roots, and a logical namespace root may span multiple assemblies. In the .NET
Framework, a namespace is a logical design-time naming convenience, whereas an assembly
establishes the name scope for types at run time.
Executable code:-
Software in a form that can be run in the computer. It typically refers to machine language,
which is the set of native instructions the computer carries out in hardware. Executable files in
the DOS/Windows world use .EXE and .COM file extensions, while executable files in Unix and
Mac do not require specific extensions. They are identified by their file structure.
The Portable Executable (PE) format is a file format for executables, object code, DLLs, FON
Font files,[1][2] and others used in 32-bit and 64-bit versions of Windows operating systems. The
PE format is a data structure that encapsulates the information necessary for the Windows OS
loader to manage the wrapped executable code. This includes dynamic library references for
linking, API export and import tables, resource management data and thread-local storage (TLS)
data. On NT operating systems, the PE format is used for EXE, DLL, SYS (device driver), and
other file types. The Extensible Firmware Interface (EFI) specification states that PE is the
standard executable format in EFI environments.
PE is a modified version of the Unix COFF (Common Object File Format). PE/COFF is an
alternative term in Windows development.
A PE file consists of a number of headers and sections that tell the dynamic linker how to map
the file into memory. An executable image consists of several different regions, each of which
requires different memory protection; so the start of each section must be aligned to a page
boundary. For instance, typically the .text section (which holds program code) is mapped as
execute/readonly, and the .data section (holding global variables) is mapped as no-
execute/readwrite. However, to avoid wasting space, the different sections are not page
aligned on disk. Part of the job of the dynamic linker is to map each section to memory
individually and assign the correct permissions to the resulting regions, according to the
instructions found in the headers.
Reflection:-
The classes in the System. Reflection namespace, together with System. Type, enable you to
obtain information about loaded assemblies and the types defined within them, such as classes,
interfaces, and value types. You can also use reflection to create type instances at run time, and
to invoke and access them. For topics about specific aspects of reflection, see Related Topics at
the end of this overview.
The common language runtime loader manages application domains, which constitute defined
boundaries around objects that have the same application scope. Assemblies contain modules,
modules contain types, and types contain members. Reflection provides objects that
encapsulate assemblies, modules, and types. You can use reflection to dynamically create an
instance of a type, bind the type to an existing object, or get the type from an existing object.
You can then invoke the type's methods or access its fields and properties. Typical uses of
reflection include the following:
Use Assembly to define and load assemblies, load modules that are listed in the
assembly manifest, and locate a type from this assembly and create an instance of it.
Use Module to discover information such as the assembly that contains the module and
the classes in the module. You can also get all global methods or other specific,
nonglobal methods defined on the module.
Use ConstructorInfo to discover information such as the name, parameters, access
modifiers (such as public or private), and implementation details (such as abstract or
virtual) of a constructor. Use the GetConstructors or GetConstructor method of a Type
to invoke a specific constructor.
Use FieldInfo to discover information such as the name, access modifiers (such as public
or private) and implementation details (such as static) of a field, and to get or set field
values.
Use EventInfo to discover information such as the name, event-handler data type,
custom attributes, declaring type, and reflected type of an event, and to add or remove
event handlers.
Use PropertyInfo to discover information such as the name, data type, declaring type,
reflected type, and read-only or writable status of a property, and to get or set property
values.
Use ParameterInfo to discover information such as a parameter's name, data type,
whether a parameter is an input or output parameter, and the position of the
parameter in a method signature.
The classes of the System.Reflection.Emit namespace provide a specialized form of reflection
that enables you to build types at run time.
Reflection can also be used to create applications called type browsers, which enable users to
select types and then view the information about those types.
S.NO RGPV QUESTION YEAR MARKS
UNIT 1/LECTURE-08
Manifest,Metadata,Manage code and Manage data
Manifest:-
An assembly manifest contains all the metadata needed to specify the assembly's version
requirements and security identity, and all metadata needed to define the scope of the
assembly and resolve references to resources and classes. The assembly manifest can be
stored in either a PE (Portable Executable) file (an .exe or .dll) with Microsoft intermediate
language (MSIL) code or in a standalone PE (Portable Executable) file that contains only
assembly manifest information. The following table shows the information contained in the
assembly manifest. The first four items the assembly name, version number, culture, and
strong name information make up the assembly's identity.
Culture: Information on the culture or language the assembly supports. This information
should be used only to designate an assembly as a satellite assembly containing culture- or
language-specific information. (An assembly with culture information is automatically
assumed to be a satellite assembly.) Strong name information: The public key from the
publisher if the assembly has been given a strong name. List of all files in the assembly:
A hash of each file contained in the assembly and a file name. Note that all files that make up
the assembly must be in the same directory as the file containing the assembly manifest.
Type reference information: Information used by the runtime to map a type reference to the
file that contains its declaration and implementation. This is used for types that are
exportedfrom the assembly.
Information on referenced assemblies: A list of other assemblies that are statically referenced
by the assembly. Each reference includes the dependent assembly's name, assembly
metadata (version, culture, operating system, and so on), and public key, if the assembly is
strong named.
Every assembly, whether static or dynamic, contains a collection of data that describes how
the elements in the assembly relate to each other. The assembly manifest contains this
assembly metadata. An assembly manifest contains all the metadata needed to specify the
assembly's version requirements and security identity, and all metadata needed to define the
scope of the assembly and resolve references to resources and classes. The assembly
manifest can be stored in either a PE file (an .exe or .dll) with Microsoft intermediate
language (MSIL) code or in a standalone PE file that contains only assembly manifest
information.
Metadata:-
In .NET, this data is contained in the header portion of a COFF-compliant PE and follows certain
guidelines;
it contains information such as the assembly’s name, version, language (spoken, not
computera.k.a., culture), what external types are referenced, what internal types are exposed,
methods, properties, classes, and much more.
The CLR uses metadata for a number of specific purposes. Security is managed through a public
key in the PE’s header.
Information about classes, modules, and so forth allows the CLR to know in advance what
structures are necessary. The class loader component of the CLR uses metadata to locate
specific classes within assemblies, either locally or across networks.
Just-in-time (JIT) compilers use the metadata to turn IL into executable code.
Other programs take advantage of metadata as well.
A common example is placing a Microsoft Word document on a Windows 2000 desktop. If the
document file has completed comments, author, title, or other Properties metadata, the text is
displayed as a tool tip when a user hovers the mouse over the document on the desktop. You
can use the Ildasm.exe utility to view the metadata in a PE. Literally, this tool is an IL
disassembler.
Metadata in .Net is binary information which describes the characteristics of a resource . This
information include Description of the Assembly , Data Types and members with their
declarations and implementations, references to other types and members , Security
permissions etc. A module's metadata contains everything that needed to interact with
another module.
During the compile time Metadata created with Microsoft Intermediate Language (MSIL) and
stored in a file called a Manifest. Both Metadata and Microsoft Intermediate Language (MSIL)
together wrapped in a Portable Executable (PE) file. During the runtime of a program Just In
Time (JIT) compiler of the Common Language Runtime (CLR) uses the Metadata and converts
Microsoft Intermediate Language (MSIL) into native code. When code is executed, the
runtime loads metadata into memory and references it to discover information about your
code's classes, members, inheritance, and so on. Moreover Metadata eliminating the need for
Interface Definition Language (IDL) files, header files, or any external method of component
reference.
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). Closely
related to managed code is managed data--data that is allocated and de- allocated by the
Common Language Runtime's garbage collector. C#, Visual Basic, and JScript .NET data is
managed by default.
Managed Code in Microsoft .Net Framework, is the code that has executed by the Common
Language Runtime (CLR) environment. On the other hand Unmanaged Code is directly
executed by the computer's CPU. Data types, error-handling mechanisms, creation and
destruction rules, and design guidelines vary between managed and unmanaged object
models.
The benefits of Managed Code include programmers convenience and enhanced security .
Managed code is designed to be more reliable and robust than unmanaged code , examples
are Garbage Collection , Type Safety etc. The Managed Code running in a Common
Language Runtime (CLR) cannot be accessed outside the runtime environment as well as
cannot call directly from outside the runtime environment. This makes the programs more
isolated and at the same time computers are more secure . Unmanaged Code can bypass
the .NET Framework and make direct calls to the Operating System. Calling unmanaged
code presents a major security risk.
Introduction
When I was first faced with the .NET Framework security and cryptography fist, I noticed that
most of the quick-start articles sufferes from lots of low-level details and explanations of the
nuts and bolts of .NET Framework Security.
But for the first time, I needed a brief, easy to understand and remember tutorial, instead. So,
actually this is not an article. This is rather a bird's-eye overview of the .NET Framework security
model, with visual illustrations.
Security concepts
You can implement the security model in your applications in a declarative and/or an
imperative way. In most cases, you should prefer declarative security, and implement the
security model only when some application security issues can be known only at runtime.
[assembly :
FileDialogPermissionAttribute( SecurityAction.Reque
stMinimum, Unrestricted=true)]
fileDlgPermission.Demand();
if (myDlgForm.ShowDialog() == DialogResult.OK)
MessageBox.Show(myDlgForm.FileName);
Permissions
Code groups
CLR examines all code groups in the hierarchy. When the code group is marked as Exclusive,
then the CLR stops checking for group membership. Next, the CLR determines the permission
sets for each code group. If the code is a member of the code group that is marked as Exclusive,
only the permission set of that code group is taken into account, otherwise the CLR calculates
the permission as a Union of all permission sets of all code groups that the running code is a
member of.