Question 1 - What Is
CLR ?
CLR is Common Language Runtime is the runtime
that converts a 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 include:
·
ASP.Net - An ISAPI
filter that ships with ASP.NET loads 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.
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 Common Type System. So “Integer” data type in VB and “int”
data type in C++ will convert it to System.int32, which is 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.
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.
(IL) Intermediate Language Or (CIL) Common
Intermediate Language Or (MSIL) Microsoft Intermediate Language, is one of the
Core component 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 as 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)
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 references 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 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.
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 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.
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.
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:
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 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)
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.
[ad]
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 an 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.
·
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 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.
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 41 - What is
Custom Serialization?
·
In some cases, the
default serialization techniques provided by .NET may not be sufficient in real
life.
·
This is when we
require implementing custom serialization.
·
It is possible to
implement custom serialization in .NET by implementing the ISerializable
interface.
·
This interface allows
an object to take control of its own serialization and de-serialization
process.
·
It gives us a great
deal of flexibility in the way we can save and restore objects.
Question 42 - What is a Namespace?
·
Containers of objects
which contain classes, unions, structures, interfaces, enumerators, delegates.
·
Main goal is for
creating hierarchical organization of program.
·
Developers does not need
to worry about the naming conflicts of classes, functions, variables etc.
Question 43 - What is GUID?
It is Short form of Globally Unique
Identifier,
A unique 128-bit number that is produced by
the Windows OS or Windows app to identify a particular component, application,
file, database entry, and/or user.
Question 44 - What is a Formatter?
·
A formatter is used to
determine the serialization format for objects.
·
In other words, it is
used to control the serialization of an object to and from a stream.
·
They are the objects
that are used to encode and serialize data into an appropriate format before
they are transmitted over the network.
·
They expose an
interface called the IFormatter interface. IFormatter's significant methods are
Serialize and De-serialize which perform the actual serialization and
de-serialization.
·
There are two
formatter classes provided within .NET, the BinaryFormatter and the
SoapFormatter. Both these classes extend the IFormatter interface.
Question 45 - What is a Binary Formatter?
The Binary formatter provides support for
serialization using binary encoding. The BinaryFormater class is responsible
for binary serialization and is used commonly in .NET's Remoting technology.
This class is not appropriate when the data is supposed to be transmitted
through a firewall.
Question 46 -
What is a SOAP Formatter?
The SOAP formatter provides formatting that
can be used to serialize objects using the SOAP protocol. It is used to create
a Soap envelop and it uses an object graph to generate the result. It is
responsible for serializing objects into SOAP messages or parsing the SOAP
messages and extracting these serialized objects from the SOAP messages. SOAP
formatters in .NET are widely used by the Web Services.
Question 47 - What is Reflection?
·
It is a collection of
classes which allow u to query assembly (class/object) metadata at runtime.
·
Using reflection we
can also create new types and their instances at runtime and invoke methods on
these new instances.
·
At runtime, the
Reflection mechanism uses the PE file to read information about the assembly.
·
We can dynamically
invoke methods using System.Type.Invokemember
·
We can dynamically
create types at runtime using System.Reflection.Emit.TypeBuilder
·
With reflection we can
do the below
§ we can dynamically create an instance of a
type
§ bind the type to an existing object
§ get the type from an existing object
§ invoke its methods or access its fields and
properties
Question 48 - What is Thread and Process?
·
Threads are basically
light weight processes responsible for multitasking within a single
application.
·
The base class used
for threading is System.Threading.
·
Threads are
implemented when situations in which you want to perform more than one task at
a time.
§ A Process is an instance of a running
application.
§ A thread is the Execution stream of the
Process.
§ A process can have multiple Threads.
·
Example: A Microsoft Word is an Application. When you
open a word file, an instance of the Word starts and a process is allocated to
this instance which has one thread.
§ Create Thread – use System.Thread() class and create an instance.
§ Join Thread - use object.Join() to join threads.
§ Suspend Thread - use object.Sleep(<No of seconds>) to
suspend a thread.
§ Kill Thread - use object.Abort() to abort a thread.
Question 49 - What
are the difference between a Dll and an Exe?
DLL
|
EXE
|
Create an object of dll
|
Not in exe
|
In Process Component
|
Out Process Component
|
Multiple Uses
|
Single use
|
Cannot be started as stand alone
|
Can be started as stand alone
|
Question 50 - What are
Globalization and Localization?
To implementing a
multilingual user interface, you design the user interface to open in the
default UI language and offer the option to change to other languages.
Globalization is the first step in the process. A globalized application
supports localized user interfaces and regional data for all users. Truly
global applications should be culture-neutral and language-neutral. A
globalized application can correctly accept, process, and display a worldwide
assortment of scripts, data formats, and languages. Accommodating these
cultural differences in an application is called localization.
No comments:
Post a Comment