Wednesday, October 31, 2007

What is the difference between private and shared assembly?

Assembly which is used by a single application is called as private assembly.It must be placed in the same folder as the application or in the subfolder.
Shared Assemblies are the assemblies that are accessible globally/shared across the machine to all the applications. For using the shared assemblies you need to register the assembly with a strong name in the global assembly cache(GAC).

What is reference type and value type?

Reference types inherit directly from System.Object and are stored in heap.They are directly controled by Garbage collector.Eg. Class, Delegate, Interface etc
Value type inherit from System.ValueType which inturn inherits from System.Object.They are stored in stack.Eg. Structs, integer,bool etc

What is boxing and unboxing?

Boxing and unboxing enables value type to be treated as object.Boxing allows a value type to stored in heap.Unboxing converts the object to value type.
Eg.
int
i = 123;
object o = (object)i; // boxing
o = 123;
i = (int)o; // unboxing

What is Base Class Library?

Its a library which is available to all the languages using .Net Framework. It encapsulates large number of common functions, such as file reading and writing, database interaction and xml manipulation etc.

How many classes can a single .NET DLL contain?

Infinite classes

What is the base class of .net?

System.Object

What is menifest?

An assembly manifest contains all the metadata needed to specify the assembly's version requirements and security identity, and all metadata needed to define the scope of the assembly and resolve references to resources and classes. The assembly manifest can be stored in either a PE (Portable Executable) file (an .exe or .dll) with Microsoft intermediate language (MSIL) code or in a standalone PE (Portable Executable) file that contains only assembly manifest information.
It contains:
Assembly name: A text string specifying the assembly's name.
Version number: A major and minor version number, and a revision and build number. The common language runtime uses these numbers to enforce version policy.
Culture: Information on the culture or language the assembly supports. This information should be used only to designate an assembly as a satellite assembly containing culture- or language-specific information. (An assembly with culture information is automatically assumed to be a satellite assembly.)
Strong name information: The public key from the publisher if the assembly has been given a strong name.
List of all files in the assembly: A hash of each file contained in the assembly and a file name. Note that all files that make up the assembly must be in the same directory as the file containing the assembly manifest.
Type reference information: Information used by the runtime to map a type reference to the file that contains its declaration and implementation. This is used for types that are exported from the assembly.
Information on referenced assemblies: A list of other assemblies that are statically referenced by the assembly. Each reference includes the dependent assembly's name, assembly metadata (version, culture, operating system, and so on), and public key, if the assembly is strong named.

What is the difference between a namespace and assembly name?

Namespace is a logical boundary for a group of classes. It basically solves the naming problem.
An assembly is the building block of a .NET application. It is a self describing collection of code, resources, and metadata (data about data, example, name, size, version of a file is metadata about that file).
One assembly can contain many namespaces.

What is managed code and managed data?

The .Net Framework provides a run time environment called Common Language Runtime which manages the execution of code and provides services that make the development process easier.Code that you write with a language compiler that targets the runtime is called managed code.It benefits from features like cross language integration,cross language exceptional handling, security and deployment support etc.
Data whoes memory allocation and deallocation is managed by Garbage collector is called as managed data.

What is Common Language Specification (CLS)?

Common Language Specification is a set of rules that all Dotnet Languages must follow to achieve Cross Language interoperability.
Its a subset of Common Type System.

What is "Common Type System" (CTS)?

CTS( common type system) brings all .net languages data types on a common platform. It defines types like System.Int16, System.Int32 etc. A language may map 'int' to System.Int16 while another may map its 'int' data type to System.Int32.

Because all data types from all languages are mapped to common .net datatypes we can integrate code written in different .net languages into one assembly.

What is "Microsoft Intermediate Language" (MSIL)?

All .NET programming language first gets compiled into intermediate language(MSIL) and then CLR compiles IL code into natice code.

MSIL is the CPU-independent instruction set into which .NET Framework programs are compiled. It contains instructions for loading, storing, initializing, and calling methods on objects.
Combined with metadata and the common type system, MSIL allows for true cross- language integration.

What is CLR?

Common Language Runtime (CLR) manages the execution of code and provides different services like Garbage collection and support for Base Class Libraries etc. The main constituents of CLR are:

The common Language Runtime (CLR) a rich set of features for cross-language development and deployment. CLR supports both Object Oriented Languages as well as procedural languages. CLR provides security, garbage collection, cross language exception handling, cross language inheritance and so on.

The Common Type System, support both Object Oriented Programming languages as well as procedural languages. Basically CTS provides rich type system that is intended to support wide range of languages.

CLS (Common Language Specification) defines a subset of Common Type System, which all language compilers targeting CLR must adhere to. CLS is a subset of CTS.

All compilers under .NET will generate Intermediate Language no matter what language is used to develop an application. In fact, CLR will not be aware of the language used to develop an application. All language compilers will generate a uniform, common language called Intermediate Language.Because of which we can have language inteoperability feature in .net.