Sunday, 23 October 2011


1. What is IL?
IL = Intermediate Language. Also known as MSIL (Microsoft Intermediate
Language) or CIL (Common Intermediate Language). All .NET source code
(of any language) is compiled to IL during development. The IL is then
converted to machine code at the point where the software is installed, or
(more commonly) at run-time by a Just-In-Time (JIT) compiler.

2 What is C#?
C# is a new language designed by Microsoft to work with the .NET
framework. In their "Introduction to C#" whitepaper, Microsoft describe C#
as follows:
"C# is a simple, modern, object oriented, and type-safe programming
language derived from C and C++. C# (pronounced “C sharp”) is firmly
planted in the C and C++ family tree of languages, and will immediately be
familiar to C and C++ programmers. C# aims to combine the high
productivity of Visual Basic and the raw power of C++."
Substitute 'Java' for 'C#' in the quote above, and you'll see that the
statement still works pretty well :-). 

3 What does 'managed' mean in the .NET context?
The term 'managed' is the cause of much confusion. It is used in various
places within .NET, meaning slightly different things.
Managed code: The .NET framework provides several core run-time services
to the programs that run within it - for example exception handling and
security. For these services to work, the code must provide a minimum level
of information to the runtime. Such code is called managed code.
Managed data: This is data that is allocated and freed by the .NET runtime's
garbage collector.
Managed classes: This is usually referred to in the context of Managed
Extensions (ME) for C++. When using ME C++, a class can be marked with
the __gc keyword. As the name suggests, this means that the memory for
instances of the class is managed by the garbage collector, but it also means
more than that. The class becomes a fully paid-up member of the .NET
community with the benefits and restrictions that brings. An example of a
benefit is proper interop with classes written in other languages - for
example, a managed C++ class can inherit from a VB class. An example of a
restriction is that a managed class can only inherit from one base class. 

4 What is reflection?
All .NET compilers produce metadata about the types defined in the modules
they produce. This metadata is packaged along with the module (modules in
turn are packaged together in assemblies), and can be accessed by a
mechanism called reflection. The System.Reflection namespace contains
classes that can be used to interrogate the types for a module/assembly.
Using reflection to access .NET metadata is very similar to using
ITypeLib/ITypeInfo to access type library data in COM, and it is used for
similar purposes - e.g. determining data type sizes for marshaling data
across context/process/machine boundaries.
Reflection can also be used to dynamically invoke methods (see
System.Type.InvokeMember), or even create types dynamically at run-time
(see System.Reflection.Emit.TypeBuilder).

Saturday, 22 October 2011


1 What tools can I use to develop .NET applications?
There are a number of tools, described here in ascending order of cost:
·  The .NET Framework SDK is free and includes command-line compilers
for C++, C#, and VB.NET and various other utilities to aid
·  ASP.NET Web Matrix is a free ASP.NET development environment from
Microsoft. As well as a GUI development environment, the download
includes a simple web server that can be used instead of IIS to host
ASP.NET apps. This opens up ASP.NET development to users of
Windows XP Home Edition, which cannot run IIS.
·  Microsoft Visual C# .NET Standard 2003 is a cheap (around $100)
version of Visual Studio limited to one language and also with limited
wizard support. For example, there's no wizard support for class
libraries or custom UI controls. Useful for beginners to learn with, or
for savvy developers who can work around the deficiencies in the
supplied wizards. As well as C#, there are VB.NET and C++ versions.
·  Microsoft Visual Studio.NET Professional 2003. If you have a license for
Visual Studio 6.0, you can get the upgrade. You can also upgrade from
VS.NET 2002 for a token $30. Visual Studio.NET includes support for
all the MS languages (C#, C++, VB.NET) and has extensive wizard
At the top end of the price spectrum are the Visual Studio.NET 2003
Enterprise and Enterprise Architect editions. These offer extra features such
as Visual Sourcesafe (version control), and performance and analysis tools.
Check out the Visual Studio.NET Feature Comparison at

2 What is the CLI? Is it the same as the CLR?
The CLI (Common Language Infrastructure) is the definition of the fundamentals of
the .NET framework - the Common Type System (CTS), metadata, the Virtual
Execution Environment (VES) and its use of intermediate language (IL), and the
support of multiple programming languages via the Common Language Specification
(CLS). The CLI is documented through ECMA - see for more details.
The CLR (Common Language Runtime) is Microsoft's primary implementation of the
CLI. Microsoft also have a shared source implementation known as ROTOR, for
educational purposes, as well as the .NET Compact Framework for mobile devices.
Non-Microsoft CLI implementations include Mono and DotGNU Portable. NET.

3 What is the CTS, and how does it relate to the CLS?
CTS = Common Type System. This is the full range of types that the .NET
runtime understands. Not all .NET languages support all the types in the
CLS = Common Language Specification. This is a subset of the CTS which all
.NET languages are expected to support. The idea is that any program which
uses CLS-compliant types can interoperate with any .NET program written in
any language. This interop is very fine-grained - for example a VB.NET class
can inherit from a C# class.

Friday, 21 October 2011


1 What is .NET?
.NET is a general-purpose software development platform, similar to Java. At
its core is a virtual machine that turns intermediate language (IL) into
machine code. High-level language compilers for C#, VB.NET and C++ are
provided to turn source code into IL. C# is a new programming language,
very similar to Java. An extensive class library is included, featuring all the
functionality one might expect from a contempory development platform -
windows GUI development (Windows Form s), database access (ADO.NET),
web development (ASP.NET), web services, XML etc.

2 When was .NET announced?
Bill Gates delivered a keynote at Forum 2000, held June 22, 2000, outlining
the .NET 'vision'. The July 2000 PDC had a number of sessions on .NET
technology, and delegates were given CDs containing a pre-release version
of the .NET framework/SDK and Visual Studio.NET.

3 What versions of .NET are there?
The final version of the 1.0 SDK and runtime was made publicly available
around 6pm PST on 15-Jan-2002. At the same time, the final version of
Visual Studio.NET was made available to MSDN subscribers.
.NET 1.1 was released in April 2003 - it's mostly bug fixes for 1.0.
.NET 2.0 is expected in 2005.

4 What operating systems does the .NET Framework run on?
The runtime supports Windows Server 2003, Windows XP, Windows 2000,
NT4 SP6a and Windows ME/98. Windows 95 is not supported. Some parts of
the framework do not work on all platforms - for example, ASP.NET is only
supported on XP and Windows 2000/2003. Windows 98/ME cannot be used
for development.
IIS is not supported on Windows XP Home Edition, and so cannot be used to
host ASP.NET. However, the ASP.NET Web Matrix web server does run on XP
The .NET Compact Framework is a version of the .NET Framework for mobile
devices, running Windows CE or Windows Mobile.
The Mono project has a version of the .NET Framework that runs on

Thursday, 20 October 2011

Debugging and Testing Questions Part 5

How do I debug an ASP.NET application that wasn't written with
Visual Studio.NET and that doesn't use code-behind?

Start the DbgClr debugger that comes with the .NET Framework SDK, open
the file containing the code you want to debug, and set your breakpoints.
Start the ASP.NET application. Go back to DbgClr, choose Debug Processes
from the Tools menu, and select aspnet_wp.exe from the list of processes.
(If aspnet_wp.exe doesn't appear in the list,check the "Show system
processes" box.) Click the Attach button to attach to aspnet_wp.exe and
begin debugging.
Be sure to enable debugging in the ASPX file before debugging it with
DbgClr. You can enable tell ASP.NET to build debug executables by placing
<%@ Page Debug="true" %> statement at the top of an ASPX file or a
<COMPILATION debug="true" />statement in a Web.config file.

Can a user browsing my Web site read my Web.config or Global.asax

No. The <HTTPHANDLERS>section of Machine.config, which holds the master
configuration settings for ASP.NET, contains entries that map ASAX files,
CONFIG files, and selected other file types to an HTTP handler named
HttpForbiddenHandler, which fails attempts to retrieve the associated
file. You can modify it by editing Machine.config or including an section in a
local Web.config file.

What's the difference between Page.RegisterClientScriptBlock and

RegisterClientScriptBlock is for returning blocks of client-side script
containing functions. RegisterStartupScript is for returning blocks of clientscript
not packaged in functions-in other words, code that's to execute
when the page is loaded. The latter positions script blocks near the end of
the document so elements on the page that the script interacts are loaded
before the script runs.<%@ Reference Control="MyControl.ascx" %>

Wednesday, 19 October 2011

Debugging and Testing Questions Part 4

Where do you add an event handler?
It's the Attributesproperty, the Add function inside that property.
e.g. btnSubmit.Attributes.Add("onMouseOver","someClientCode();")
What data type does the RangeValidator control support?
Integer,String and Date.

What are the different types of caching?
Caching is a technique widely used in computing to increase performance by
keeping frequently accessed or expensive data in memory. In context of web
application, caching is used to retain the pages or data across HTTP requests
and reuse them without the expense of recreating them.ASP.NET has 3 kinds
of caching strategiesOutput CachingFragment CachingData

 CachingOutput Caching: Caches the dynamic output generated by a
request. Some times it is useful to cache the output of a website even for a
minute, which will result in a better performance. For caching the whole
page the page should have OutputCache directive.<%@ OutputCache
Duration="60" VaryByParam="state" %>

Fragment Caching: Caches the portion of the page generated by the
request. Some times it is not practical to cache the entire page, in such cases
we can cache a portion of page<%@ OutputCache Duration="120"

Data Caching: Caches the objects programmatically. For data caching provides a cache object for eg: cache["States"] = dsStates;

What do you mean by authentication and authorization?
Authentication is the process of validating a user on the credentials
(username and password) and authorization performs after authentication.
After Authentication a user will be verified for performing the various
tasks, It access is limited it is known as authorization.

What are different types of directives in .NET?
@Page: Defines page-specific attributes used by the ASP.NET page parser
and compiler. Can be included only in .aspx files <%@ Page
AspCompat="TRUE" language="C#" %>
@Control:Defines control-specific attributes used by the ASP.NET page
parser and compiler. Can be included only in .ascx files. <%@ Control
Language="VB" EnableViewState="false" %>
@Import: Explicitly imports a namespace into a page or user control. The
Import directive cannot have more than one namespace attribute. To
import multiple namespaces, use multiple @Import directives. <% @
Import Namespace="System.web" %>
@Implements: Indicates that the current page or user control implements
the specified .NET framework interface.<%@ Implements
Interface="System.Web.UI.IPostBackEventHandler" %>
@Register: Associates aliases with namespaces and class names for concise
notation in custom server control syntax.<%@ Register Tagprefix="Acme"
Tagname="AdRotator" Src="AdRotator.ascx" %>
@Assembly: Links an assembly to the current page during compilation,
making all the assembly's classes and interfaces available for use on
the page. <%@ Assembly Name="MyAssembly" %><%@ Assembly
Src="MySource.vb" %>
@OutputCache: Declaratively controls the output caching policies of an
ASP.NET page or a user control contained in a page<%@ OutputCache
Duration="#ofseconds" Location="Any | Client | Downstream | Server |
None" Shared="True | False" VaryByControl="controlname"
VaryByCustom="browser | customstring" VaryByHeader="headers"
VaryByParam="parametername" %>
@Reference: Declaratively indicates that another user control or page

Tuesday, 18 October 2011

Debugging and Testing Questions Part 3

What is view state and use of it?
The current property settings of an ASP.NET page and those of any ASP.NET
server controls contained within the page. ASP.NET can detect when a form
is requested for the first time versus when the form is posted (sent to the
server), which allows you to program accordingly.

What are user controls and custom controls?
Custom controls:
A control authored by a user or a third-party software vendor that does not
belong to the .NET Framework class library. This is a generic term that
includes user controls. A custom server control is used in Web Forms
(ASP.NET pages). A custom client control is used in Windows Forms
User Controls:
In ASP.NET: A user-authored server control that enables an ASP.NET page to
be re-used as a server control. An ASP.NET user control is authored
declaratively and persisted as a text file with an .ascx extension. The
ASP.NET page framework compiles a user control on the fly to a class that
derives from the System.Web.UI.UserControl class.

What are the validation controls?
A set of server controls included with ASP.NET that test user input in HTML
and Web server controls for programmer-defined requirements. Validation
controls perform input checking in server code. If the user is working with a
browser that supports DHTML, the validation controls can also perform
validation using client script.

What's the difference between Response.Write() andResponse.Output.Write()?
The latter one allows you to write formattedoutput.

What methods are fired during the page load? Init()
When the page is instantiated, Load() - when the page is loaded into server
memory,PreRender () - the brief moment before the page is displayed to the
user as HTML, Unload() - when page finishes loading.

Where does the Web page belong in the .NET Framework class hierarchy?

Where do you store the information about the user's locale?
What's the difference between Codebehind="MyCode.aspx.cs" and
CodeBehind is relevant to Visual Studio.NET only.

What's a bubbled event?
When you have a complex control, likeDataGrid, writing an event processing
routine for each object (cell, button,row, etc.) is quite tedious. The controls
can bubble up their eventhandlers, allowing the main DataGrid event handler
to take care of its constituents.
Suppose you want a certain ASP.NET function executed on MouseOver over a
certain button.

Saturday, 15 October 2011

Debugging and Testing Questions Part 2

1. Why are there five tracing levels in System.Diagnostics.Trace Switcher?
The tracing dumps can be quite verbose. For applications that are
constantly running you run the risk of overloading the machine and the
hard drive. Five levels range from None to Verbose, allowing you to
fine-tune the tracing activities.

2. Where is the output of TextWriterTraceListener redirected?
To the Console or a text file depending on the parameter passed to the

3. How do you debug an ASP.NET Web application?
Attach the aspnet_wp.exe process to the DbgClr debugger.

4. What are three test cases you should go through in unit

1. Positive test cases (correct data, correct output).
2. Negative test cases (broken or missing data, proper handling).
3. Exception test cases (exceptions are thrown and caught properly).

5. Can you change the value of a variable while debugging a C#

Yes. If you are debugging via Visual Studio.NET, just go to Immediate