Question 1 – What Is CLR?
CLR
is Common Language Runtime is the runtime that converts an MSIL code into the
host machine language code. It is the execution engine for .NET Framework
applications. It provides a number of services, including:
• Code management
(loading and execution)
• Memory Management
• Thread Management
• Conversion of
IL to native code.
• Access to metadata (enhanced type information)
• Managing
memory for managed objects (Garbage collection)
• Enforcement of code access
security (Security Management)
• Exception handling, including cross-language
exceptions
• Interoperation btw managed code, COM objects, and pre-existing
DLL’s (unmanaged code and data)
• Support for developer services
(profiling, debugging, and so on).
• Type safety.
Question 2 – What is CLR HOST?
A CLR host is an application that is responsible for loading the CLR into a
process, creating application domains within the process, and executing user
code within the application domains.
Examples of hosts that ship with the .NET
Framework includes:
• ASP.Net – An ISAPI filter that ships with ASP.NET load the
CLR and does the initialization necessary to handle web requests.
• Internet
Explorer: – A MIME filter hooks into IE versions 5.01 and higher to execute
managed controls referenced from HTML pages.
Question 3 – What is CTS?
CTS is
Common Type System, which describes how types are declared, used, and managed.
CTS facilitate cross-language integration, type safety, and high-performance
code execution. Example in VB you have “Integer” and in C++ you have “long”
these data types are not compatible so the interfacing between them is very
complicated. In order that these two different languages communicate Microsoft
introduced the Common Type System. So “Integer” data type in VB and “int” data type
in C++ will convert it to System.int32, which is the data type of CTS.
Question 4 –
What is CLS?
CLS Is Common Language Specification, is a specification that
defines the rules to support language integration. This is done in such a way,
that programs written in any language (.NET compliant) can interoperate with one
another. This also can take full advantage of inheritance, polymorphism,
exceptions, and other features. It was always a dream of Microsoft to unite all
different languages in to one umbrella and CLS is one-step towards that.
Question 5 – What is an Intermediate Language?
(IL) Intermediate Language Or
(CIL) Common Intermediate Language Or (MSIL) Microsoft Intermediate Language, is
one of the Core components of the .NET Framework. Any .NET source codes written
in any .net supportive language (C#,VB.net etc), when compiled are converted to
MSIL. This MSIL, when installed or at the Runtime, gets converted to machine
code. The Runtime conversion of MSIL code to the machine code is handled by a
component called the Just In Time (JIT) Compiler.
Question 6 – What is Just
In Time Compiler?
It is a compiler which converts MS IL (Microsoft Intermediate
Language) code to Native Code (i.e. CPU-specific code that runs on the same
computer architecture). Just-In-Time compiler- it converts the language that you
write in .Net into machine language that a computer can understand.
There are 3
types of JITs
• Pre-JIT compiler (Compiles entire code into native code
completely in a single Operation)
• Econo JIT compiler (Compiles only
methods(Code) called at Runtime)
• Normal JIT compiler (Compiles only that part
of code called at Runtime and places in cache)
Question 7 – What is Portable
executable (PE)?
The file format defining the structure that all executable
files (EXE) and Dynamic Link Libraries (DLL) must use to allow them to be loaded
and executed by Windows. Windows PE is divided into 2 main sections.
• The first
section includes the PE/COFF headers that reference the contents within the PE
file.
• The second section is the native image section which contains .data,
.rdata, .rsrc, and .text sections.
Question 8 – What is the Managed Code?
Managed
code runs inside the environment of CLR i.e. .NET runtime. In short, all IL are
managed code. However, if you are using some third party software example VB6 or
VC++ component they are unmanaged code, as .NET runtime (CLR) does not have
control over the source code execution of these languages. A runtime-aware the compiler compiles the IL into native executable code within a managed execution
environment that ensures type safety, array bound and index checking, exception
handling, and garbage collection. Also, many unproductive programming tasks are
automatically taken care of, such as type safety checking, memory management,
and destruction of unneeded objects. You can therefore focus on the business
logic of your applications and write them using fewer lines of code. The result
is shorter development time and more secure and stable applications.
Question 9
– What is UnManaged Code?
As mentioned above the Unmanaged code will be one
where
• The CLR cannot able to understand the code.
• The CLR cannot instruct
the code.
• The second time compilation is unmanaged code. It is understood only
by the machine not by the user.
Question 10 – What is Garbage Collector?
Garbage
collection is a process of releasing the memory used by the objects, which are
no longer referenced. This is done in different ways and different manners in
various platforms and languages. When an program is loaded in the memory there
will be a bunch of memory allocated for that particular program alone and loaded
with memory. This bunch of memory is called Managed Heap(is nothing but a bunch
of memory allocated for the program at run time). This amount of memory will
only be used when an object is to be loaded in to the memory for that particular
program. This memory is separated in to three parts:
• Generation Zero – Smaller
size
• Generation One – Medium size
• Generation Two – Larger size When we try
to create an object by using a NEW keyword the system will,
• Calculate the number
of bytes required for the object or type to be loaded in to the managed heap.
•
The CLR then checks that the bytes required to allocate the object are available
in the reserved region. IF the object fits, it is allocated at the address
pointed to by NextObjPtr.
• These processes will happen at the Generation zero
level.
Question 11 – What is a Strong Name?
A strong name is a .NET assembly
name combined with its version number and other information to uniquely identify
the assembly. This allows multiple versions of the same assembly to peacefully
co-exist in the global assembly cache, where shared assemblies are typically
stored. It consists of five parts as mentioned below
• Simple Name – Usually the
name of the file (without the extension) that contains the assembly
• Public Key
– RSA cryptographic public key that helps verify the assembly’s authenticity
•
Version – Four-part version number, in the form of Major.Minor.Build.Revision
•
Culture – Target audience for the assembly, such as “neutral” (default
audience), “en-us” (English – United States) or “fr” (France) etc.
• Processor
Architecture – Defines the assembly’s format, such as MSIL (intermediate
language) or x86 (binary for Intel x86 processors)
Question 12 – What are the
steps to create Strong Name?
We have a set of steps that should be followed to
create a strong name as shown below.
• Open .net command prompt.
• Go to the
folder containing DLL.
• Type sn -k test.snk, This will create test .snk file in
that folder.
• Open the assemblyinfo.cs file of project.
• Type file path in
this tag [assembly:AssemblyKeyFile@”E:\Code\practice\HP\bin\Debug\HP.snk”)]
•
Build application, finally your strong name created for your DLL.
Question 13 –
What are the Problems faced using Strong Name?
• Requires Exact Match. If you
use strong names, your application or library must load the assembly with the
exact strong name that you specify, including version and culture.
• Cannot Lose
Private Key. If your private key is lost or stolen, the security of your
assembly is compromised. You will be forced to re-issue a new assembly signed
with a new public-private key pair.
Question 14 – What is Program Database?
A
program database files holds debugging and project state information that allows
incremental linking of debug configuration of your program. A PDB file can be up
to 2GB.
Question 15 – What is Delay Signing?
It is signing an assembly with its
strong name public key, which is freely distributable, instead of using the
private key as usual. This allows developers to use and test a strong-named
assembly without access to the private key. Then at a later stage (typically
just before shipping the assembly), a manager or trusted key holder must sign
the assembly with the corresponding private key.
Question 16 – What is an
Assembly?
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.
Question 17 – What are
the Contents of an Assembly
• Type metadata.
• The assembly manifest, which
contains assembly metadata.
• Microsoft intermediate language (MSIL) code that
implements the types.
• A set of resources
Question 18 – What are the Types of Assemblies?
Assemblies are of four types
• Private – The assembly is intended
only for one application
• Shared – If the assembly is to be made into a Shared
Assembly(GAC)
• Static – These are the .NET PE files that you create at compile
time.
• Dynamic – These are PE-formatted, in-memory assemblies that you
dynamically create at runtime
Question 19 – What is a Satellite assembly?
• A
.NET Framework assembly containing resources specific to a given language.
•
Using satellite assemblies, you can place the resources for different languages
in different assemblies. • The correct assembly is loaded into memory only if
the user elects to view in that language.
• Culture is maintained in a text file
which acts like a resource to the assembly.
Question 20 – What are the Steps to
Create Satellite Assembly?
Below are the steps to create a satellite assembly
•
Set the paths for resgen and al.exe:
• Create a .resources file.
• Create the
satellite assembly.
The assembly should have the naming convention for .NET to
be able to search for it.
• Specify the settings for culture.
• Put the
satellite assembly in the appropriate folder.
• Once the satellite assembly is
created, physically copy it to the appropriate directory.
• Repeat the process
for each language in which you are creating an assembly.
Question 21 – What is
an Assembly Loader?
• Checks if the assembly is Strongly signed.
• If yes it
will search in the GAC
• Loader will search the policy file name in the format
of
• Policy.AssemblyMajorVersion.AssemblyMinorVersion.AssemblyName
• Eg.
MyPolicy.1.2.Assembly1
• If such a file exists it will look inside of it if the
version of the assembly that we are trying to load matches the version/versions
range written in the policy file. If it does, it will try to load the assembly
with the version specified there. If no such policy file exists, it will try to
load an assembly from the GAC.
• If it will fail to find it in the GAC, it will
start to search in the system’s search path. In web applications it will also
include the application’s Bin directory in the search path.
Question 22 – What
is Multi-Module Assembly or Assembly Linker?
We like to combine Hello.dll with
GoodBye.dll and put them into a Private Assembly we call GreetAssembly.dll.
DotNet> al /t:library /out:bin\Hellowroldassembly.dll bin\GoodDay.dll
bin\GoodMorning.dll For this purpose we use the Assembly Linker. As /t (target)
we generate here a library referencing the two other DLLs. This is also called a
Multi-Module Assembly. Again, we store all the binaries in a bin folder.
Question 23 – What is an Assembly Manifest?
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.
Question 24
– What is a Metadata?
Metadata is data that describes the state of the assembly
and a detailed description of each type, attribute within the assembly. Metadata
stores the following information:
• Description of the assembly.
• Identity
(name, version, culture, public key).
• The types that are exported.
• Other
assemblies that this assembly depends on.
• Security permissions needed to run.
• Description of types.
• Name, visibility, base class, and interfaces
implemented.
• Members (methods, fields, properties, events, nested types).
•
Attributes.
• Additional descriptive elements that modify types and members.
Question 25 – What is a Base class in .Net?
Base class is the one from which the
object and references are being inherited in .net
• System.object is for .Net
•
System.Web.UI is for asp.net
Question 26 – What is Full Assembly Reference?
A
full assembly reference includes the assembly’s text name, version, culture, and
public key token (if the assembly has a strong name). A full assembly reference
is required if you reference any assembly that is part of the common language
runtime or any assembly located in the global assembly cache.
Question 27 – What
is Partial Assembly Reference?
We can dynamically reference an assembly by
providing only partial information, such as specifying only the assembly name.
When you specify a partial assembly reference, the runtime looks for the
assembly only in the application directory.
Question 28 – What is an Assembly
Qualified Name?
An assembly qualified name isn’t the filename of the assembly;
it’s the internal name of the assembly combined with the assembly version,
culture, and public key, thus making it unique.
Question 29 – What is ILDASM
(Intermediate Language Disassembler)?
It is a tool provided in C# to view and
read the assembly content in manifest view. This tool is supplied along with the
Visual Studio .NET you are using. It is also available along with .NET SDK. To
access this tool, you have to run the ildasm.exe
Question 30 – What is Global
Assembly Cache?
• The GAC stores assemblies specifically designated to be shared
by several applications on the computer.
• Assemblies deployed in the GAC must
have a strong name.
• When an assembly is added to the GAC, integrity checks are
performed on all files that make up the assembly. The cache performs these
integrity checks to ensure that an assembly has not been tampered with, for
example, when a file has changed but the manifest does not reflect the change.
•
Use a developer tool called the Global Assembly Cache tool (Gacutil.exe),
provided by the .NET Framework SDK or Use Windows Explorer to drag assemblies
into the cache.
Question 31 – What is an Attribute?
Attributes are declarative
tags in code that insert additional metadata into an assembly. Attributes are of
Two types:
• Predefined attributes such as Assembly Version, which already exist
and accessed through Runtime Classes;
• Custom attributes, which you write
yourself by extending the System.Attribute class.
• Example – Custom Attribute
for entire assembly 1. using System; 2. [assembly : MyAttributeClass] class X {}
Question 32 – What is Serialization & DeSerialization?
It is a process of taking
an object and converting into a form so that it can be transported across the
network or can be persisted in the storage location. This storage location can
be physical file, database or ASP.NET Cache. The form contains the state of the
object so that by this format, we can construct the same object a later point in
time, which is called De-serialization. When the object is subsequently
de-serialized, an exact clone of the original object is created. Remoting and
Web Services depend heavily on this process.
Question 33 – Where Serialization
is used?
• Used to save session state in ASP.NET.
• Copy objects to the
Clipboard in Windows Forms
Remoting to pass objects by value from one
application domain to another.
Question 34 – What are the types of Serialization
available in .net?
Serialization of 3 types and are as follows.
• Binary
Serialization : Light and compact used in Remoting
• SOAP Serialization :
interoperable use SOAP and used in web Services
• XML Serialization : Custom
Serialization
Question 35 – What is Binary Serialization?
Binary serialization
is a mechanism which writes the data to the output stream such that it can be
used to re-construct the object automatically. The term binary in its name
implies that the necessary information that is required to create an exact
binary copy of the object is saved onto the storage media.
Question 36 – What
are the Advantages & Disadvantages of Binary Serialization?
Advantages: Object
can be de-serialized from the same data you serialized it to. It has enhanced
performance as it is faster and even more powerful in the sense that it provides
support for complex objects, read only properties and even circular references.
Disadvantage: It is not easily portable to another platform.
Question 37 – What
is SOAP Serialization?
The SOAP protocol is ideal for communicating between
applications that use heterogeneous architectures. In order to use SOAP
serialization in .NET we have to add a reference to
System.Runtime.Serialization.Formatters.Soap in the application.
Question 38 –
What are the Advantages of SOAP Serialization?
The basic advantage of SOAP
serialization is portability. The SoapFormatter serializes objects into SOAP
messages or parses SOAP messages and extracts serialized objects from the
message.
Question 39 – What is a XML Serialization?
XML serialization converts
(serializes) the public fields and properties of an object or the parameters and
returns values of methods, into an XML stream that conforms to a specific XML
Schema definition language (XSD) document. XML serialization results in strongly
typed classes with public properties and fields that are converted to a serial
format (in this case, XML) for storage or transport. Because XML is an open
standard, the XML stream can be processed by any application, as needed,
regardless of platform.” Implementing XML Serialization in .Net is quite simple.
No comments:
Post a Comment