Professional Documents
Culture Documents
.NET Framework is a complete environment that allows developers to develop, run, and deploy the
following applications:
Console applications
Windows Forms applications
Web services
Windows services
.NET Framework also enables a developer to create sharable components to be used in distributed
computing architecture. NET Framework supports the object-oriented programming model for multiple
languages, such as Visual Basic, Visual C#, and Visual C++. .NET Framework supports multiple
programming languages in a manner that allows language interoperability. This implies that each
language can use the code written in some other language.
2. What are the main components of .NET Framework?
.NET Framework provides enormous advantages to software developers in comparison to the
advantages provided by other platforms. Microsoft has united various modern as well as existing
technologies of software development in .NET Framework. These technologies are used by developers
to develop highly efficient applications for modern as well as future business needs. The following are
the key components of .NET Framework:
Application Domains
Runtime Host
Cross-Language Interoperability
Profiling
Side-by-Side Execution
Networking Improvements
Improvements in WPF 4
4. What is an IL?
Intermediate Language is also known as MSIL (Microsoft Intermediate Language) or CIL (Common
Intermediate Language). All .NET source code is compiled to IL. IL is then converted to machine code
at the point where the software is installed, or at run-time by a Just-In-Time (JIT) compiler.
5. What is Manifest?
Assembly metadata is stored in Manifest. Manifest contains all the metadata needed to do the
following things
Version of assembly.
Security identity.
The assembly manifest can be stored in a PE file either (an .exe or) .dll with Microsoft
intermediate language (MSIL code with Microsoft intermediate language (MSIL) code or in a
stand-alone PE file, that contains only assembly manifest information.
6. What are code contracts?
Code contracts help you to express the code assumptions and statements stating the behavior of your
code in a language-neutral way. The contracts are included in the form of pre-conditions, postconditions and object-invariants. The contracts help you to improve-testing by enabling run-time
checking, static contract verification, and documentation generation.
The System.Diagnostics.Contracts namespace contains static classes that are used to express
contracts in your code.
7. Name the classes that are introduced in the System.Numerics namespace.
The following two new classes are introduced in the System.Numerics namespace:
BigInteger - Refers to a non-primitive integral type, which is used to hold a value of any
size. It has no lower and upper limit, making it possible for you to perform arithmetic
calculations with very large numbers, even with the numbers which cannot hold by double or
long.
Complex - Represents complex numbers and enables different arithmetic operations with
complex numbers. A number represented in the form a + bi, where a is the real part,
and b is the imaginary part, is a complex number.
11. Give a brief introduction on side-by-side execution. Can two applications, one using
private assembly and the other using the shared assembly be stated as side-by-side
executables?
Side-by-side execution enables you to run multiple versions of an application or component and CLR
on the same computer at the same time. As versioning is applicable only to shared assemblies and not
to private assemblies, two applications, one using a private assembly and other using a shared
assembly, cannot be stated as side-by-side executables.
12. Which method do you use to enforce garbage collection in .NET?
The System.GC.Collect() method.
13. State the differences between the Dispose() and Finalize().
CLR uses the Dispose and Finalize methods to perform garbage collection of run-time objects of .NET
applications.
The Finalize method is called automatically by the runtime. CLR has a garbage collector (GC),
which periodically checks for objects in heap that are no longer referenced by any object or program.
It calls the Finalize method to free the memory used by such objects. The Dispose method is called
by the programmer.Dispose is another method to release the memory used by an object. The
Dispose method needs to be explicitly called in code to dereference an object from the heap.
The Dispose method can be invoked only by the classes that implement the IDisposable interface.
14. What is code access security (CAS)?
Code access security (CAS) is part of the .NET security model that prevents unauthorized access of
resources and operations, and restricts the code to perform particular tasks.
15. Differentiate between managed and unmanaged code?
Managed code is the code that is executed directly by the CLR instead of the operating system. The
code compiler first compiles the managed code to intermediate language (IL) code, also called as MSIL
code. This code doesn't depend on machine configurations and can be executed on different machines.
Unmanaged code is the code that is executed directly by the operating system outside the CLR
environment. It is directly compiled to native machine code which depends on the machine
configuration.
In the managed code, since the execution of the code is governed by CLR, the runtime provides
different services, such as garbage collection, type checking, exception handling, and security support.
These services help provide uniformity in platform and language-independent behavior of managed
code applications. In the unmanaged code, the allocation of memory, type safety, and security is
required to be taken care of by the developer. If the unmanaged code is not properly handled, it may
result in memory leak. Examples of unmanaged code are ActiveX components and Win32 APIs that
execute beyond the scope of native CLR.
16. What are tuples?
Tuple is a fixed-size collection that can have elements of either same or different data types. Similar to
arrays, a user must have to specify the size of a tuple at the time of declaration. Tuples are allowed to
hold up from 1 to 8 elements and if there are more than 8 elements, then the 8th element can be
defined as another tuple. Tuples can be specified as parameter or return type of a method.
17. How can you turn-on and turn-off CAS?
YOU can use the Code Access Security Tool (Caspol.exe) to turn security on and off.
To turn off security, type the following command at the command prompt:
caspol -security on
In the .NET Framework 4.0, for using Caspol.exe, you first need to set
the <LegacyCasPolicy> element totrue.
18. What is garbage collection? Explain the difference between garbage collections in .NET
4.0 and earlier versions.
Garbage collection prevents memory leaks during execution of programs. Garbage collector is a lowpriority process that manages the allocation and deallocation of memory for your application. It checks
for the unreferenced variables and objects. If GC finds any object that is no longer used by the
application, it frees up the memory from that object.
GC has changed a bit with the introduction of .NET 4.0. In .NET 4.0, the GC.Collect() method
contains the following overloaded methods:
GC.Collect(int)
GC.Collect(int,GCCollectionMode)
Another new feature introduced in .NET is to notify you when the GC.Collect() method is invoked
and completed successfully by using different methods. The .NET 4.0 supports a new background
garbage collection that replaces the concurrent garbage collection used in earlier versions. This
concurrent GC allocates memory while running and uses current segment (which is 16 MB on a
workstation) for that. After that, all threads are suspended. In case of background GC, a separate
ephemeral GC - gen0 and gen1 can be started, while the full GC - gen0, 1, and 2 - is already running.
3.
Security rights are allocated to the assembly, depending on the code group.
4.
22. Is there a way to suppress the finalize process inside the garbage collector forcibly in
.NET?
Use the GC.SuppressFinalize() method to suppress the finalize process inside the garbage
collector forcibly in .NET.
23. How can you instantiate a tuple?
The following are two ways to instantiate a tuple:
Tuple<String,int>t=newTuple<String,int>("Hellow",2);
Using the Create factory method available in the Tuple class. For example,
Tuple<int,int,int>t=Tuple.Create<int,int,int>(2,4,5);
24. Which is the root namespace for fundamental types in .NET Framework?
Generation 2 - Whenever new objects are created and added to the memory, they are added
to generation 0 and the old objects in generation 1 are considered to be in generation 2.
29. Explain covariance and contra-variance in .NET Framework 4.0. Give an example for
each.
In .NET 4.0, the CLR supports covariance and contravariance of types in generic interfaces and
delegates. Covariance enables you to cast a generic type to its base types, that is, you can assign a
instance of typeIEnumerable<Tl> to a variable of type IEnumerable<T2> where, T1 derives
from T2. For example,
IEnumerable<string>str1=newList<string>();
IEnumerable<object>str2=str1;
Contravariance allows you to assign a variable of Action<base> to a variable of
type Action<derived>. For example,
IComparer<object>obj1=GetComparer()
IComparer<string>obj2=obj1;
.NET framework 4.0 uses some language keywords (out and in) to annotate covariance and contravariance. Out is used for covariance, while in is used for contra-variance.
Variance can be applied only to reference types, generic interfaces, and generic delegates. These
cannot be applied to value types and generic types.
30. How do you instantiate a complex number?
The following are the different ways to assign a value to a complex number:
By passing two Double values to its constructor. The first value represents the real, and the second
value represents imaginary part of a complex number.
For example,
Complexc1=newComplex(5,8);/*Itrepresents(5,8)*/
By assigning a Byte, SByte, Intl6, UIntl6, Int32, UInt32, Int64, UInt64, Single,
or Double value to aComplex object. The assigned value represents the real part of the complex
number, and its imaginary part becomes 0. For example,
Complexc2=15.3;/*Itrepresents(15.3,0)*/
By casting a Decimal or BigInteger value to a Complex object.
For example,
Complexc3=(Complex)14.7;/*Itrepresents(14.7,0)*/
Assigning the value returned by an operator to a Complex variable.
For example,
Complexc4=c1+c2;/*Itrepresents(20.3,8)*/
String and StringBuilder classes are used to store string values but the difference in them is that
String is immutable (read only) by nature, because a value once assigned to a String object cannot be
changed after its creation. When the value in the String object is modified, a new object is created, in
memory, with a new value assigned to the String object. On the other hand,
the StringBuilder class is mutable, as it occupies the same space even if you change the value.
The StringBuilder class is more efficient where you have to perform a large amount of string
manipulation.
34. Describe the roles of CLR in .NET Framework.
CLR provides an environment to execute .NET applications on target machines. CLR is also a common
runtime environment for all .NET code irrespective of their programming language, as the compilers of
respective language in .NET Framework convert every source code into a common language known as
MSIL or IL (Intermediate Language).
CLR also provides various services to execute processes, such as memory management service and
security services. CLR performs various tasks to manage the execution process of .NET applications.
The responsibilities of CLR are listed as follows:
Code verification
There are two ways to install .NET assembly in GAC:1. Using Microsoft Installer Package. You can get download of installer
from http://www.microsoft.com.
2. Using Gacutil. Goto "Visual Studio Command Prompt" and type "gacutil i
(assembly_name)", where (assembly_name) is the DLL name of the project.
What is garbage collection?
Garbage collection is a CLR feature which automatically manages memory. Programmers
forget to release the objects while coding.(Remember in VB6 where one of the good practices
is to set object to nothing). CLR automatically releases objects when they are no longer in
use and refernced. CLR runs on non-deterministic to see the unused objects and cleans
them. One side effect of this non-deterministic feature is that we cannot assume an object is
destroyed when it goes out of the scope of a function. Therefore, we should not put code into
a class destructor to release resources.
Can we force garbage collector to run?
System.GC.Collect() forces garbage collector to run. This is not recommended but can be
used if situations arises.
What is reflection?
All .NET assemblies have metadata information stored about the types defined in modules.
This metadata information can be accessed by mechanism called as "Reflection".System.
Reflection can be used to browse through the metadata information.
What are Value types and Reference types?
Value types directly contain their data which are either allocated on the stack or allocated inline in a structure. Reference types store a reference to the value's memory address, and are
allocated on the heap. Reference types can be self-describing types, pointer types, or
interface types. Variables that are value types each have their own copy of the data, and
therefore operations on one variable do not affect other variables. Variables that are
reference types can refer to the same object; therefore, operations on one variable can affect
the same object referred to by another variable. All types derive from the System.Object
base type.
What is concept of Boxing and Unboxing?
Boxing permits any value type to be implicitly converted to type object or to any interface
type implemented by value type. Boxing is a process in which object instances are created
and copy values in to that instance. Unboxing is vice versa of boxing operation where the
value is copied from the instance in to appropriate storage location. Below is sample code of
boxing and unboxing where integer data type is converted in to object and then vice versa.
Dim x As Integer
Dim y As Object
x =10
y = x boxing process
x = y unboxing process
What is the difference between VB.NET and C#?
Well this is the most debatable issue in .NET community and people treat there languages
like religion. Its a subjective matter which language is best. Some like VB.NETs natural style
and some like professional and terse C# syntaxes. Both use the same framework and speed
is also very much equivalents. But still lets list down some major differences between
them :- Advantages VB.NET :1. Has support for optional parameters which makes COM interoperability much easy.
2. With Option Strict off late binding is supported.Legacy VB functionalities can be used by
using Microsoft.VisualBasic namespace.
3. Has the WITH construct which is not in C#.
4. The VB.NET part of Visual Studio .NET compiles your code in the background. While this is
considered an advantage for small projects, people creating very large projects have found
that the IDE slows down considerably as the project gets larger.
Advantages of C#
1. XML documentation is generated from source code but this is now been incorporated in
Whidbey.
2. Operator overloading which is not in current VB.NET.
3. Use of this statement makes unmanaged resource disposal simple.
4. Access to Unsafe code. This allows pointer arithmetic etc, and can improve performance in
some situations. However, it is not to be used lightly, as a lot of the normal safety of C# is
lost (as the name implies).This is the major difference that you can access unmanaged code
queueing them up with the NGEN Service. Use the following command line.
ngen.exe install <assemblyname> /queue:<priority>
Assemblies which are critical to your application's start up time should either be precompiled
synchronously or asynchronously with priority 1. Priority 1 and 2 assemblies are precompiled
aggressively while Priority 3 assemblies are only precompiled during machine idle-time.
Synchronously precompiling your critical assemblies guarantees that the native images will
be available prior to the first time your end user launches the application but increases the
time taken to run your application's set up program. You can uninstall an assembly and its
dependencies (if no other assemblies are dependent on them) from the native image cache
by running the following command. ngen.exe uninstall <assemblyname>. Native images
created using Ngen.exe cannot be deployed; instead they need to be created on the end
user's machine. These commands therefore need to be issued as part of the application's
setup program. Visual Studio .NET can be used to implement this behavior by defining
custom actions in a Microsoft Installer (MSI) package.
What is .NET Framework?
The .NET Framework is such a comprehensive platform that it can be used to develop
websites, webapplications, web services and much more.
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. PE is derived
from the Microsoft Common Object File Format (COFF). The EXE and DLL files created using
the .NET Framework obey the PE/COFF formats and also add additional header and data
sections to the files that are only used by the CLR.
Which is the base class for .net Class library?
System.object.
What is Application Domain?
Application domains provide a unit of isolation for the common language runtime. They are
created and run inside a process. Application domains are usually created by a runtime host,
which is an application responsible for loading the runtime into a process and executing user
code within an application domain. The runtime host creates a process and a default
application domain, and runs managed code inside it. Runtime hosts include ASP.NET,
Microsoft Internet Explorer, and the Windows shell.
What is serialization in .NET?
Serialization can be defined as the process of storing the state of an object to a storage
medium. During this process, the public and private fields of the object and the name of the
class, including the assembly containing the class, are converted to a stream of bytes, which
is then written to a data stream. When the object is subsequently deserialized, an exact
clone of the original object is created.
1. Binary serialization preserves type fidelity, which is useful for preserving the state of an
object between different invocations of an application. For example, you can share an object
between different applications by serializing it to the clipboard. You can serialize an object to
a stream, disk, memory, over the network, and so forth. Remoting uses serialization to pass
objects "by value" from one computer or application domain to another.
2. XML serialization serializes only public properties and fields and does not preserve type
fidelity. This is useful when you want to provide or consume data without restricting the
application that uses the data. Because XML is an open standard, it is an attractive choice for
sharing data across the Web. SOAP is an open standard, which makes it an attractive choice.
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 withthe information it needs to be aware of type implementations. To the runtime, a
type does not exist outside the context of an assembly. Assemblies are a fundamental part of
programming withthe .NET Framework. An assembly performs the following functions:1. 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, orMain).
2. It forms a security boundary. An assembly is the unit at which permissions are requested
and granted.
3. It forms a type boundary. Every types identity includes the name of the assembly in which
it resides. A type called MyType loaded in the scope of one assembly is not the same as a
type called MyType loaded in the scope of another assembly.
4. It forms areference scope boundary. The assemblys manifest contains assembly metadata
that is used for resolving types and satisfying resource requests. It specifies the types and
resources that are exposed outside the assembly. The manifest also enumerates other
assemblies on which it depends.
5. It forms aversion 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
assemblys manifest describes the version dependencies you specify for any dependent
assemblies.
6. 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.
7. It is the unit at which side-by-side execution is supported. 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 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
.NET, that you have used in the past to create .dll or .exe files. You can use tools provided in
the .NET Framework SDK to create assemblies withmodules created in other development
environments. You can also use common language runtime APIs, such as Reflection.Emit, to
create dynamic assemblies.
What are Satellite Assemblies?
Satellite assemblies are often used to deploy language-specific resources for an application.
These language-specific assemblies work in side-by-side execution because the application
has a separate product ID for each language and installs satellite assemblies in a languagespecific subdirectory for each language. When uninstalling, the application removes only the
satellite assemblies associated witha given language and .NET Framework version. No
core .NET Framework files are removed unless the last language for that .NET Framework
version is being removed.
What is Assembly manifest?
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
assemblys 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) withMicrosoft intermediate
language (MSIL) code or in a standalone PE file that contains only assembly manifest
information. It contains Assembly name, Version number, Culture, Strong name information,
List of all files in the assembly, Type reference information, Information on referenced
assemblies.
What are the contents of assembly?
In general, a static assembly can consist of four elements:1. The assembly manifest, which contains assembly metadata.
2. Type metadata.
3. Microsoft intermediate language (MSIL) code that implements the types.
4. A set of resources.
Difference between assembly manifest & metadata assembly manifest?
An integral part of every assembly that renders the assembly self-describing. The assembly
manifest contains the assemblys metadata. The manifest establishes the assembly identity,
specifies the files that make up the assembly implementation, specifies the types and
resources that make up the assembly, itemizes the compile-time dependencies on other
assemblies, and specifies the set of permissions required for the assembly to run properly.
This information is used at run time to resolve references, enforce version binding policy, and
validate the integrity of loaded assemblies. The self-describing nature of assemblies also
helps makes zero-impact install and XCOPY deployment feasible. metadata -Information that
describes every element managed by the common language runtime: an assembly, loadable
file, type, method, and so on. This can include information required for debugging and
garbage collection, as well as security attributes, marshaling data, extended class and
member definitions, version binding, and other information required by the runtime.
What is Global Assembly Cache (GAC) and what is the significance of it?
Each computer where the common language runtime is installed has a machine-wide code
cache called the global assembly cache. The global assembly cache stores assemblies
specifically designated to be shared by several applications on the computer. You should
share assemblies by installing them into the global assembly cache only when you need to.
What is the difference between Readonly and Constant?
Aconstfield can only be initialized at the declaration of the field. Areadonlyfield can be
initialized either at the declaration or in a constructor. Therefore,readonlyfields can have
different values depending on the constructor used. Also, while aconstfield is a compile-time
constant, thereadonlyfield can be used for runtime constants, as in the following example:
public static readonly uint l1 = (uint) DateTime.Now.Ticks;
What is the managed and unmanaged code in .net?
The .NET Framework provides a run-time environment called the Common Language
Runtime, which manages the execution of code and provides services that make the
development process easier. Compilers and tools expose the runtimes functionality and
enable you to write code that benefits from this managed execution environment. Code that
you develop witha language compiler that targets the runtime is calledmanaged code;
itbenefits from features such as cross-language integration, cross-language exception
handling, enhanced security, versioning and deployment support, a simplified model for
component interaction, and debugging and profiling services.
PAGE NO. 1 2
How to implement cloning in .NET ? What is shallow copy and deep copy ?
Cloning is achieved by using ICloneable of the System namespace. It has a "Clone" method
which actually returns the reference of the same copy. Clone method allows a Shallow copy
and not a deep copy. In Shallow copy if you make changes to the cloned object it actually
changes on the main object itself. So how is deep copy achieved, by using "ISerializable"
interface? So what you do is first serialize the object then deserialize back to a complete new
copy. Now any changes to this new copy do not reflect on the original copy of the object, this
is called as Deep copy.
How can I write IL programs directly?
Assembly MyAssembly {}
.class MyApp {
.method static void Main() {
.entrypoint
ldstr "Hello, IL!"
call void System.Console::WriteLine(class System.Object)
ret
}
}.
Which name space is the base class for .net Class library?
language should comply with the Common Language Runtime standard to become a.NET
language. In .NET, code is compiled to Microsoft Intermediate Language (MSIL for short).
This is called as Managed Code. This Managed code is run in .NET environment. So after
compilation to this IL the language is not a barrier. A code can call or use a function written
in another language.
enable you to write code that benefits from this managed execution environment. The code
that runs within the common language runtime is called managed code.
What is MSIL?
When the code is compiled, the compiler translates your code into Microsoft intermediate
language (MSIL). The common language runtime includes a JIT compiler for converting this
MSIL then to native code.
MSIL contains metadata that is the key to cross language interoperability. Since this
metadata is standardized across all .NET languages, a program written in one language can
understand the metadata and execute code, written in a different language. MSIL includes
instructions for loading, storing, initializing, and calling methods on objects, as well as
instructions for arithmetic and logical operations, control flow, direct memory access,
exception handling, and other operations.
What is JIT?
JIT is a compiler that converts MSIL to native code. The native code consists of hardware
specific instructions that can be executed by the CPU.
Rather than converting the entire MSIL (in a portable executable[PE]file) to native code, the
JIT converts the MSIL as it is needed during execution. This converted native code is stored
so that it is accessible for subsequent calls.
What
is
portable
executable
(PE)?
PE is 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. PE is
derived from the Microsoft Common Object File Format (COFF). The EXE and DLL files
created using the .NET Framework obey the PE/COFF formats and also add additional
header and data sections to the files that are only used by the CLR.
What is an application domain?
Application domain is the boundary within which an application runs. A process can contain
multiple application domains. Application domains provide an isolated environment to
applications that is similar to the isolation provided by processes. An application running
inside one application domain cannot directly access the code running inside another
application domain. To access the code running in another application domain, an
application needs to use a proxy.
How
does
an
AppDomain
get
created?
AppDomains are usually created by hosts. Examples of hosts are the Windows Shell,
ASP.NET and IE. When you run a .NET application from the command-line, the host is the
Shell. The Shell creates a new AppDomain for every application. AppDomains can also be
explicitly created by .NET applications.
What is an assembly?
An assembly is a collection of one or more .exe or dlls. An assembly is the fundamental unit
for application development and deployment in the .NET Framework. An assembly contains
a collection of types and resources that are built to work together and form a logical unit of
functionality. An assembly provides the CLR with the information it needs to be aware of
type implementations.
What are the contents of assembly?
A static assembly can consist of four elements:
Assembly manifest - Contains the assembly metadata. An assembly manifest contains the
information about the identity and version of the assembly. It also contains the information
required to resolve references to types and resources.
Type metadata - Binary information that describes a program.
Microsoft intermediate language (MSIL) code.
A set of resources.
What are the different types of assembly?
Assemblies can also be private or shared. A private assembly is installed in the installation
directory of an application and is accessible to that application only. On the other hand, a
shared assembly is shared by multiple applications. A shared assembly has a strong name
and is installed in the GAC.
We also have satellite assemblies that are often used to deploy language-specific resources
for an application.
What is a dynamic assembly?
A dynamic assembly is created dynamically at run time when an application requires the
types within these assemblies.
What is a strong name?
You need to assign a strong name to an assembly to place it in the GAC and make it globally
accessible. A strong name consists of a name that consists of an assembly's identity (text
name, version number, and culture information), a public key and a digital signature
generated over the assembly. The .NET Framework provides a tool called the Strong Name
Tool (Sn.exe), which allows verification and key pair and signature generation.
What is GAC? What are the steps to create an assembly and add it to the GAC?
The global assembly cache (GAC) is a machine-wide code cache that stores assemblies
specifically designated to be shared by several applications on the computer. You should
share assemblies by installing them into the global assembly cache only when you need to.
Steps
- Create a strong name using sn.exe tool eg: sn -k mykey.snk
- in AssemblyInfo.cs, add the strong name eg: [assembly: AssemblyKeyFile("mykey.snk")]
(shfusion.dll tool)
gacutil -i abc.dll
What is the caspol.exe tool used for?
The caspol tool grants and modifies permissions to code groups at the user policy, machine
policy, and enterprise policy levels.
What is a garbage collector?
A garbage collector performs periodic checks on the managed heap to identify objects that
are no longer required by the program and removes them from memory.
What are generations and how are they used by the garbage collector?
Generations are the division of objects on the managed heap used by the garbage collector.
This mechanism allows the garbage collector to perform highly optimized garbage collection.
The unreachable objects are placed in generation 0, the reachable objects are placed in
generation 1, and the objects that survive the collection process are promoted to higher
generations.
What is Ilasm.exe used for?
Ilasm.exe is a tool that generates PE files from MSIL code. You can run the resulting
executable to determine whether the MSIL code performs as expected.
What is Ildasm.exe used for?
Ildasm.exe is a tool that takes a PE file containing the MSIL code as a parameter and
creates a text file that contains managed code.
What is the ResGen.exe tool used for?
ResGen.exe is a tool that is used to convert resource files in the form of .txt or .resx files to
common language runtime binary .resources files that can be compiled into satellite
assemblies.
sensitive. So for language interoperability , C# doesn't allow two variable which differs only in
Case.
Private Assemblies are intended to be used by the program for which its made for. This is because
application will only load private assemblies that are located in the same folder or in a sub folder that
the main executable is loaded.
While using shared assemblies, to avoid Assembly being overwritten by a different version of the
same assembly , shared assemblies are placed in a special directory subtree in the file system,
known as the global assembly cache (GAC). Placing shared assemblies can be done by special .Net
Utilities Only.
3) Normal-JIT - Complies methods that are called at runtime and get stored in cache. Next time
when the same method is called, it will be taken from cache.
25) What are Value types and Reference types ?
There are two types of data types in .Net, Value types and Reference types.Value types are stored
in stack part of the memory. Reference type are stored in managed heap. Let have a look at the
example for better understanding.
Int iCount = 0; \\ Value Type
int NewiCount = iCount; \\ Reference Type
Ngen.exe creates compiled processor-specific machine code called native images, which are files
and installs them into the native image cache on the local computer. The runtime will use native
images from the cache rather than using the JIT compiler to compile the original assembly.