Professional Documents
Culture Documents
NET Framework
.NET Framework
Developed
Microsoft
by
Latest
3.5.21022.8 / November 19, 2007
release
OS Windows NT 4.0, Windows 98 and above
Genre System platform
MS-EULA, BCL under Microsoft Reference
License
License[1]
Website http://www.microsoft.com/net
Microsoft .NET Framework is a software component that is a part of Microsoft Windows operating systems. It has
a large library of pre-coded solutions to common programming problems and manages the execution of programs
written specifically for the framework. The .NET Framework is a key Microsoft offering and is intended to be used
by most new applications created for the Windows platform.
The pre-coded solutions that form the framework's Base Class Library cover a large range of programming needs in
areas including user interface, data access, database connectivity, cryptography, web application development,
numeric algorithms, and network communications. The class library is used by programmers who combine it with
their own code to produce applications.
Programs written for the .NET Framework execute in a software environment that manages the program's runtime
requirements. This runtime environment, which is also a part of the .NET Framework, is known as the Common
Language Runtime (CLR). The CLR provides the appearance of an application virtual machine so that programmers
need not consider the capabilities of the specific CPU that will execute the program. The CLR also provides other
important services such as security, memory management, and exception handling. The class library and the CLR
together compose the .NET Framework.
The .NET Framework is included with Windows Server 2003, Windows Server 2008 and Windows Vista, and can
be installed on some older versions of Windows.
Microsoft has not yet made public a roadmap of the development plans for future edition of .NET framework, but
has released general information regarding it. Future revisions will have better support for parallel programs, that
target multi-core or distributed systems.[24] To this end, it will include technologies like PLINQ (Parallel LINQ),[25] a
parallel implementation of the LINQ engine, and Task Parallel Library, which exposes parallel constructs via
method calls.[26]
[edit] .NET vs. Java and Java EE
See also: Comparison of the Java and .NET platforms and Comparison of C# and Java
The CLI and C# have many similarities to Sun's JVM and Java. They are strong competitors. Both are based on a
virtual machine model that hides the details of the computer hardware on which their programs run. Both use their
own intermediate byte-code, Microsoft calling theirs Common Intermediate Language (CIL; formerly MSIL) and
Sun Java bytecode. On .NET the byte-code is always compiled before execution, either Just In Time (JIT) or in
advance of execution using the ngen.exe utility. With Java the byte-code is either interpreted, compiled in advance,
or compiled JIT. Both provide extensive class libraries that address many common programming requirements and
address many security issues that are present in other approaches. The namespaces provided in the .NET Framework
closely resemble the platform packages in the Java EE API Specification in style and invocation.
.NET in its complete form (Microsoft's implementation) is only available on Windows platforms and partially
available on Linux and Macintosh,[27][28][29] whereas Java is fully available on nearly all platforms.[30] From its
beginning .NET has supported multiple programming languages and at its core remains platform agnostic and
standardized so that other vendors can implement it on other platforms (although Microsoft's implementation only
targets Windows, Windows CE, and Xbox platforms). The Java platform was initially built to support only the Java
language on many operating system platforms under the slogan "Write once, run anywhere." Other programming
languages have been implemented on the Java Virtual Machine[31] but are not widely used.[citation needed]
Sun's reference implementation of Java (including the class library, the compiler, the virtual machine, and the
various tools associated with the Java Platform) is becoming open source under the GNU GPL license with
Classpath exception.[32]
The third-party Mono Project, sponsored by Novell, has been developing an open source implementation of the
ECMA standards that define the .NET Framework, as well as most of the other non-ECMA standardized libraries in
Microsoft's .NET. The Mono implementation is meant to run on Linux, Solaris, Mac OS X, BSD, HP-UX, and
Windows platforms. Mono includes the CLR, the class libraries, and compilers for C# and VB.NET. The current
version supports nearly all the APIs in version 1.1 of Microsoft's .NET and almost 96% of the APIs in version 2.0 of
Microsoft's .NET. Support for the additional libraries in .NET 3.0 and 3.5 is in the early stages of development, as is
support for C# 3.0 and Linq.[33]
[edit] Disadvantages
Some concerns and criticisms relating to .NET include:
• Applications running in a managed environment such as the Microsoft framework's CLR or Java's JVM
tend to require more system resources than similar applications that access machine resources more
directly. Some applications, however, have been shown to perform better in .NET than in their native
version.[citation needed] This could be due to the runtime optimizations made possible by such an environment,
the use of relatively well-performing functions in the .NET framework, just-in-time compilation of
managed code, or other aspects of the CLR.[34][35][dead link]
• As JIT languages can be more easily reverse-engineered than native code to algorithms used by an
application there is concern over possible loss of trade secrets and the bypassing of license control
mechanisms. Many obfuscation techniques already developed, however, can help to prevent this; indeed
Microsoft's Visual Studio 2005 includes such a tool produced by PreEmptive Solutions (see dotfuscator).
• In a managed environment such as the Microsoft framework's CLR or Java's JVM the regularly occurring
garbage collection for reclaiming memory suspends execution of the application for an unpredictable lapse
of time (typically no more than a few milliseconds). This makes such environments unsuitable for
applications such as those that must respond to events with sub-second timing (see real-time computing).
• Since the framework is not pre-installed on older versions of Windows an application that requires it must
verify that it is present, and if it is not, guide the user to install it. This requirement may deter some from
using the application.
• Newer versions of the framework (3.5 and up) are not pre-installed on any versions of the Windows
operating system. Some developers have expressed concerns about the large size (around 54 MB for end-
users with .NET 3.0 and 197 MB with .NET 3.5) and reliability of .NET framework runtime installers for
end-users.
Alternative implementations
The Microsoft .NET Framework is the predominant implementation of .NET technologies. Other implementations
for parts of the framework exist. Since the runtime engine is described by an ECMA/ISO specification, other
implementations of it are unencumbered by copyright issues. It is more difficult to develop alternatives to the base
class library (BCL), which is not described by an open standard, and may be subject to copyright restrictions.
Additionally, parts of the BCL have Windows-specific functionality and behavior, so implementation on non-
Windows platforms can be problematic.
Some alternative implementations of parts of the framework are listed here.
• Microsoft's Shared Source Common Language Infrastructure is a shared source implementation of the CLR
component of the .NET Framework. It runs on Microsoft Windows XP, FreeBSD, and Mac OS X 10.2.
• Portable.NET (part of DotGNU) provides an implementation of the Common Language Infrastructure
(CLI), portions of the .NET Base Class Library (BCL), and a C# compiler. It supports a variety of CPUs
and operating systems.
• Mono is an implementation of the CLI and portions of the .NET Base Class Library (BCL), and provides
additional functionality. It is dual-licensed under free software and proprietary software licenses. Mono is
being developed by Novell, Inc. It includes support for ASP.NET, ADO.NET, and evolving support for
Windows Forms libraries. It also includes a C# compiler, and a VB.NET compiler is in pre-beta form.
• CrossNet is an implementation of the CLI and portions of the .NET Base Class Library (BCL). It is free
software. It parses .NET assemblies and generates unmanaged C++ code that can be compiled and linked
within any ANSI C++ application on any platform.
• .NET for Symbian .NET Compact Framework implementation for Symbian (S60)
• What’s wrong with a line like this? DateTime.Parse(myString);
There IS nothing wrong with this declaration.Converts the specified string representation of a date and time
to its DateTime equivalent.But If the string is not a valid DateTime,It throws an exception.
• What are PDBs? Where must they be located for debugging to work?
A program database (PDB) files holds debugging and project state information that allows incremental
linking of debug configuration of your program.There are several different types of symbolic debugging
information. The default type for Microsoft compiler is the so-called PDB file. The compiler setting for
creating this file is /Zi, or /ZI for C/C++(which creates a PDB file with additional information that enables
a feature called ""Edit and Continue"") or a Visual Basic/C#/JScript .NET program with /debug.
A PDB file is a separate file, placed by default in the Debug project subdirectory, that has the same name as
the executable file with the extension .pdb. Note that the Visual C++ compiler by default creates an
additional PDB file called VC60.pdb for VisulaC++6.0 and VC70.PDB file for VisulaC++7.0. The
compiler creates this file during compilation of the source code, when the compiler isn't aware of the final
name of the executable. The linker can merge this temporary PDB file into the main one if you tell it to, but
it won't do it by default. The PDB file can be useful to display the detailed stack trace with source files and
line numbers.
Before the .NET Framework existed, Windows had two levels of trust for downloaded code. This old
model was a binary trust model. You only had two choices: Full Trust, and No Trust. The code could either
do anything you could do, or it wouldn't run at all.
The permission sets in .NET include FullTrust, SkipVerification, Execution, Nothing, LocalIntranet,
Internet and Everything. Full Trust Grants unrestricted permissions to system resources. Fully trusted code
run by a normal, nonprivileged user cannot do administrative tasks, but can access any resources the user
can access, and do anything the user can do.
From a security standpoint, you can think of fully trusted code as being similar to native, unmanaged code,
like a traditional ActiveX control.
GAC assemblies are granted FullTrust. In v1.0 and 1.1, the fact that assemblies in the GAC seem to always
get a FullTrust grant is actually a side effect of the fact that the GAC lives on the local machine. If anyone
were to lock down the security policy by changing the grant set of the local machine to something less than
FullTrust, and if your assembly did not get extra permission from some other code group, it would no
longer have FullTrust even though it lives in the GAC.
The Global Assembly Cache tool allows you to view and manipulate the contents of the global assembly
cache and download cache.The tool comes with various optional params to do that.
""/l"" option Lists the contents of the global assembly cache. If you specify the assemblyName parameter(/l
[assemblyName]), the tool lists only the assemblies matching that name.
Sn -t option displays the token for the public key stored in infile. The contents of infile must be previously
generated using -p.
Sn.exe computes the token using a hash function from the public key. To save space, the common language
runtime stores public key tokens in the manifest as part of a reference to another assembly when it records a
dependency to an assembly that has a strong name. The -tp option displays the public key in addition to the
token.
.NET provides an utility called strong name tool. You can run this toolfrom the VS.NET command prompt
to generate a strong name with an option "-k" and providing the strong key file name. i.e. sn- -k <>
• What is the difference between a Debug and Release build? Is there a significant speed difference? Why
or why not?
The Debug build is the program compiled with full symbolic debug information and no optimization. The
Release build is the program compiled employing optimization and contains no symbolic debug
information. These settings can be changed as per need from Project Configuration properties. The release
runs faster since it does not have any debug symbols and is optimized.
Sealed:
It can be applied on a class and methods. It stops the type from further derivation i.e no one can derive class
from a sealed class,ie A sealed class cannot be inherited.A sealed class cannot be a abstract class.A compile
time error is thrown if you try to specify sealed class as a base class.
When an instance method declaration includes a sealed modifier, that method is said to be a sealed method.
If an instance method declaration includes the sealed modifier, it must also include the override modifier.
Use of the sealed modifier prevents a derived class from further overriding the method For Egs: sealed
override public void Sample() { Console.WriteLine("Sealed Method"); }
Virtual & Override: Virtual & Override keywords provides runtime polymorphism. A base class can make
some of its methods as virtual which allows the derived class a chance to override the base class
implementation by using override keyword.
class Rectangle:Shape
{
public override void Display()
{
Console.WriteLine("Derived");
}
}
• Explain the importance and use of each, Version, Culture and PublicKeyToken for an assembly.
This three alongwith name of the assembly provide a strong name or fully qualified name to the assembly.
When a assebly is referenced with all three.
PublicKeyToken: Each assembly can have a public key embedded in its manifest that identifies the
developer. This ensures that once the assembly ships, no one can modify the code or other resources
contained in the assembly.
Version: The version number of the assembly.It is of the following form major.minor.build.revision.
Public: Allows class, methods, fields to be accessible from anywhere i.e. within and outside an assembly.
Private: When applied to field and method allows to be accessible within a class.
Protected: Similar to private but can be accessed by members of derived class also.
Internal: They are public within the assembly i.e. they can be accessed by anyone within an assembly but
outside assembly they are not visible.
Typeof is operator which applied to a object returns System.Type object. Typeof cannot be overloaded
white GetType has lot of overloads.GetType is a method which also returns System.Type of an object.
GetType is used to get the runtime type of the object.
/*
An XML Namespace is a collection of element types and attribute names. It consists of 2 parts
<>
<>DVS1< /Name >
< addr="http://www.tu-darmstadt.de/ito/addresses">
<>Wilhelminenstr. 7< /addr:Street >
<>Darmstadt< /addr:City >
<>Hessen< /addr:State >
<>Germany< /addr:Country >
<>D-64285< /addr:PostalCode >
< /addr:Address >
< serv="http://www.tu-darmstadt.de/ito/servers">
<>OurWebServer< /serv:Name >
<>123.45.67.8< /serv:Address >
< /serv:Server >
< /Department >
• What is difference between MetaData and Manifest ?
Metadata and Manifest forms an integral part of an assembly( dll / exe ) in .net framework .
Out of which Metadata is a mandatory component , which as the name suggests gives the details about
various components of IL code viz : Methods , properties , fields , class etc.
Essentially Metadata maintains details in form of tables like Methods Metadata tables , Properties Metadata
tables , which maintains the list of given type and other details like access specifier , return type etc.
Now Manifest is a part of metadata only , fully called as “manifest metadata tables” , it contains the details
of the references needed by the assembly of any other external assembly / type , it could be a custom
assembly or standard System namespace .
Now for an assembly that can independently exists and used in the .Net world both the things ( Metadata
with Manifest ) are mandatory , so that it can be fully described assembly and can be ported anywhere
without any system dependency . Essentially .Net framework can read all assembly related information
from assembly itself at runtime .
But for .Net modules , that can’t be used independently , until they are being packaged as a part of an
assembly , they don’t contain Manifest but their complete structure is defined by their respective metadata .
Ultimately .Net modules use Manifest Metadata tables of parent assembly which contain them.
Internal keyword is one of the access specifier available in .Net framework , that makes a type visible in a
given assembly , for e.g : a single dll can contain multiple modules , essentially a multi file assembly , but it
forms a single binary component , so any type with internal keyword will be visible throughout the
assembly and can be used in any of the modules .
a. Check up the total space if there’s any free space on the declared list .
b. If yes add the new item and increase count by 1 .
c. If No Copy the whole thing to a temporary Array of Last Max. Size .
d. Create new Array with size ( Last Array Size + Increase Value )
e. Copy back values from temp and reference this new array as original array .
f. Must doing Method updates too , need to check it up .
• What is Boxing and unboxing? Does it occure automaatically or u need to write code to box and unbox?
Boxing – Process of converting a System.ValueType to Reference Type , Mostly base class System.Object
type and allocating it memory on Heap .Reverse is unboxing , but can only be done with prior boxed
variables.
Boxing is always implicit but Unboxing needs to be explicitly done via casting , thus ensuring the value
type contained inside .
Boxing converts value type to reference type , thus allocating memory on Heap . Unboxing converts
already boxed reference types to value types through explicit casting , thus allocating memory on stack .
• Why only boxed types can be unboxed?
Unboxing is the process of converting a Reference type variable to Value type and thus allocating memory
on the stack . It happens only to those Reference type variables that have been earlier created by Boxing of
a Value Type , therefore internally they contain a value type , which can be obtained through explicit
casting . For any other Reference type , they don’t internally contain a Value type to Unboxed via explicit
casting . This is why only boxed types can be unboxed.