Vous êtes sur la page 1sur 20

Dot net FAQ

1) What is Assembly?
The assembly is a collection of files that together make up the assembly. It contains
some special metadata known as assembly manifest. The assembly manifest defines
what the versioning requirements of the assembly are, who authorized the assembly,
what the security permissions the assembly requires to run, and what files from part
of the assembly. An assembly is created by default whenever you build a DLL. The
only requirement is that these files need to all reside in the same directory of the
disk. When they are placed into an assembly, the Common Language Runtime treats
all these as a single unit. The assembly can be thought of as a logical DLL.

An assembly is not an application. An application is built from one or more


assemblies. The assemblies that make up an application can be deployed in a
number of different ways. Since an assembly contains its own metadata, it is capable
of telling the operating system all about itself. It does not relay on entries into the
registry to describe itself.
2) Type of assemblies and difference
There are 2 types of assemblies:
1. Private assembly
2. Public assembly/ Shared assembly
Private assemblies: This assembly can be used by only one application.
Public/Shared assembly: This assembly can share with multiple web applications
3) What are the contents of assembly?
In general, a static assembly can consist of four elements:
• The assembly manifest, which contains assembly metadata.
• Type metadata.
• Microsoft intermediate language (MSIL) code that implements the types.
• A set of resources.
Only the assembly manifest is required, but either types or resources are needed to
give the assembly any meaningful functionality.
4) What is GC (Garbage Collection) and how it works
One of the good features of the CLR is Garbage Collection, which runs in the
background collecting unused object references, freeing us from having to ensure we
always destroy them. In reality the time difference between you releasing the object
instance and it being garbage collected is likely to be very small, since the GC is
always running.
[The process of transitively tracing through all pointers to actively used objects in
order to locate all objects that can be referenced, and then arranging to reuse any
heap memory that was not found during this trace. The common language runtime
garbage collector also compacts the memory that is in use to reduce the working
space needed for the heap.]
Heap: A portion of memory reserved for a program to use for the temporary storage
of data structures whose existence or size cannot be determined until the program is
running.
5) Managed code and unmanaged code difference
Managed Code: Code that runs under a "contract of cooperation" with the common
language runtime. Managed code must supply the metadata necessary for the
runtime to provide services such as memory management, cross-language
integration, code access security, and automatic lifetime control of objects. All code
based on Microsoft intermediate language (MSIL) executes as managed code.
Un-Managed Code: Code that is created without regard for the conventions and
requirements of the common language runtime. Unmanaged code executes in the
common language runtime environment with minimal services (for example, no garbage
collection, limited debugging, and so on).
6) What is MSIL, IL, CTS and, CLR
MSIL: (Microsoft intermediate language) A language used as the output of a
number of compilers and as the input to a just-in-time (JIT) compiler. The common
language runtime includes a JIT compiler for converting MSIL to native code
IL: (Intermediate Language A language used as the output of a number of
compilers and as the input to a just-in-time (JIT) compiler. The common language
runtime includes a JIT compiler for converting MSIL to native code.
CTS: (Common Type System) The specification that determines how the common
language runtime defines, uses, and manages types
CLR: (Common Language Runtime) The engine at the core of managed code
execution. The runtime supplies managed code with services such as cross-language
integration, code access security, object lifetime management, and debugging and
profiling support.
7) Reference type and value type
Reference Type: Reference types are allocated on the managed CLR heap, just like
object types.
A data type that is stored as a reference to the value's location. The value of a
reference type is the location of the sequence of bits that represent the type's data.
Reference types can be self-describing types, pointer types, or interface types
Value Type: Value types are allocated on the stack just like primitive types in
VBScript, VB6 and C/C++
Value types are not instantiated using new go out of scope when the function they
are defined within returns.
Value types in the CLR are defined as types that derive from system.valueType
A data type that fully describes a value by specifying the sequence of bits that
constitutes the value's representation. Type information for a value type instance is
not stored with the instance at run time, but it is available in metadata. Value type
instances can be treated as objects using boxing.
8) Boxing and un boxing
Boxing: The conversion of a value type instance to an object, which implies that the
instance will carry full type information at run time and will be allocated in the heap.
The Microsoft intermediate language (MSIL) instruction set's box instruction converts
a value type to an object by making a copy of the value type and embedding it in a
newly allocated object.
Un-Boxing:The conversion of an object instance to a value type.
9) What is JIT and how is works
An acronym for "just-in-time," a phrase that describes an action that is taken only
when it becomes necessary, such as just-in-time compilation or just-in-time object
activation
10) What is portable executable (PE)
The file format used for executable programs and for files to be linked together to
form executable programs
11) What is strong name?
A name that consists of an assembly's identity—its simple text name, version
number, and culture information (if provided)—strengthened by a public key and a
digital signature generated over the assembly. Because the assembly manifest
contains file hashes for all the files that constitute the assembly implementation, it is
sufficient to generate the digital signature over just the one file in the assembly that
contains the assembly manifest. Assemblies with the same strong name are
expected to be identical.
12) What is metadata?
Metadata is binary information describing your program that is stored either in a common
language runtime portable executable (PE) file or in memory. When you compile your code
into a PE file, metadata is inserted into one portion of the file, while your code is converted
to Microsoft intermediate language (MSIL) and inserted into another portion of the file.
Every type and member defined and referenced in a module or assembly is described within
metadata. When code is executed, the runtime loads metadata into memory and references it
to discover information about your code's classes, members, inheritance, and so on.
Metadata describes every type and member defined in your code in a language-neutral
fashion. 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.

Benefits of Metadata
Metadata is the key to a simpler programming model, eliminating the need for Interface
Definition Language (IDL) files, header files, or any external method of component reference.
Metadata allows .NET languages to describe themselves automatically in a language-neutral
manner, unseen by both the developer and the user. Additionally, metadata is extensible
through the use of attributes. Metadata provides the following major benefits:
• Self-describing files.
Common language runtime modules and assemblies are self-describing. A module's
metadata contains everything needed to interact with another module. Metadata
automatically provides the functionality of IDL in COM, allowing you to use one file for
both definition and implementation. Runtime modules and assemblies do not even
require registration with the operating system. As a result, the descriptions used by
the runtime always reflect the actual code in your compiled file, which increases
application reliability.
• Language interoperability and easier component-based design.
Metadata provides all the information required about compiled code for you to inherit
a class from a PE file written in a different language. You can create an instance of
any class written in any managed language (any language that targets the common
language runtime) without worrying about explicit marshaling or using custom
interoperability code.
• Attributes
The .NET Framework allows you to declare specific kinds of metadata, called
attributes, in your compiled file. Attributes can be found throughout the .NET
Framework and are used to control in more detail how your program behaves at run
time. Additionally, you can emit your own custom metadata into .NET Framework files
through user-defined custom attributes
13) What is global assembly cache
A machine-wide code cache that stores assemblies specifically installed to be shared
by many applications on the computer. Applications deployed in the global assembly
cache must have a strong name
14) What is key file? How will u generate key file and how will link to the
assembly?
Specifies the path to the file that contains the strong name key for the generated
assemblies.
Public keyFile As String

Remarks
By default, this field is set to a null reference (Nothing in Visual Basic).
Requirements
Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition,
Windows 2000, Windows XP Home Edition, Windows XP Professional,
Windows .NET Server family
15) Static and dynamic assembly
Static: Loading an assembly in the design time is called static assembly
Dynamic: Loading an assembly in the run time is called dynamic assembly
Method is System.Reflection.Assembly.loadfrom ()
Get Types () and get Methods ()
16) What is side-by-side execution and types?
The ability to run multiple versions of the same assembly simultaneously. This can be
on the same computer or in the same process or application domain. Allowing
assemblies to run side-by-side is essential to support robust versioning in the
common language runtime.
There are two types of side-by-side execution:
• Running on the same computer.
In this type of side-by-side execution, multiple versions of the same application run
on the same computer at the same time without interfering with each other. An
application that supports side-by-side execution on the same computer demands
careful coding. For example, consider an application that uses a file at a specific
location for a cache. The application must either handle multiple versions of the
application accessing the file at the same time or the application must remove the
dependency on the specific location and allow each version to have its own cache.
• Running in the same process.
To successfully run side by side in the same process, multiple versions cannot have
any strict dependencies on process-wide resources. Side-by-side execution in the
same process means that single applications with multiple dependencies can run
multiple versions of the same component, and Web servers and other hosts can run
applications with possibly conflicting dependencies in the same process.
17) How the run time locates the assembly
The runtime uses the following steps to resolve an assembly reference:
1. Determines the correct assembly version by examining applicable
configuration files, including the application configuration file, publisher policy
file, and machine configuration file. If the configuration file is located on a remote
machine, the runtime must locate and download the application configuration file
first.
2. Checks whether the assembly name has been bound to before and, if so, use
the previously loaded assembly.
3. Checks the global assembly cache. If the assembly is found there, the runtime
uses this assembly.
4. Probes for the assembly using the following steps:
a. If configuration and publisher policy do not affect the original
reference and if the bind request was created using the Assembly.Load
From method, the runtime checks for location hints.
b. If a codebase is found in the configuration files, the runtime checks
only this location. If this probe fails, the runtime determines that the
binding request failed and no other probing occurs.
c. Probes for the assembly using the heuristics described in the probing
section. If the assembly is not found after probing, the runtime requests
the Windows Installer to provide the assembly. This acts as an install-on-
demand feature.
Note There is no version checking for assemblies without strong
names, nor does the runtime check in the global assembly cache for
assemblies without strong names.
18) What is application domain?
Application domains provide a secure and versatile unit of processing that the
common language runtime can use to provide isolation between applications. You can
run several application domains in a single process with the same level of isolation
that would exist in separate processes, but without incurring the additional overhead
of making cross-process calls or switching between processes. The ability to run
multiple applications within a single process dramatically increases server scalability.
19) What is difference between constants, read only and, static
Constants: The value can’t be changed
Read-only: The value
Static: Value can be initialized once.
20) What is difference between shared and public?
Both are same
21) What is use of context Util class?
Using this Class, the transaction can be controlled programmatically by using method
of SetAbort and SetComplete
22) What is the new three features of COM+ services, which are not there in
COM (MTS)
1) Load balancing
2) Queue
23) What is method for transaction?
SetAbort and SetComplete
24) How will you call a .net assembly from VB and vice versa?
CCW(COM Callable wrapper) : Calling .net component from Other applications(VB)
using tlbExp.exe
RCW(Remote callable wrapper)Calling VB.Dll from .Net Application
Using tlpImp.exe
25) What is namespace used for loading assemblies at run time and name the
methods?
system. Reflection
26) What are the types of authentication in .net?
We have two types of authentication: 1. SQL authentication and
2. Windows authentication
This has to be declared in web.config file. ( I think they are form based and windows
based)
27) Which is the namespace used to write error message in event Log File?
System.Diagonastics
28) What is role-based security?
Roles are often used in financial or business applications to enforce policy. For
example, an application might impose limits on the size of the transaction being
processed, depending on whether the user making the request is a member of a
specified role. Clerks might have authorization to process transactions that are less
than a specified threshold, supervisors might have a higher limit, and vice-presidents
might have a still higher limit (or no limit at all). Role-based security can also be used
when an application requires multiple approvals to complete an action. Such a case
might be a purchasing system in which any employee can generate a purchase
request, but only a purchasing agent can convert that request into a purchase order
that can be sent to a supplier.
.NET Framework role-based security supports authorization by making information
about the principal, which is constructed from an associated identity, available to the
current thread. The identity (and the principal it helps to define) can be either based
on a Windows account or be a custom identity unrelated to a Windows account. .NET
Framework applications can make authorization decisions based on the principal's
identity or role membership, or both. A role is a named set of principals that have the
same privileges with respect to security (such as a teller or a manager). A principal
can be a member of one or more roles. Therefore, applications can use role
membership to determine whether a principal is authorized to perform a requested
action.
To provide ease of use and consistency with code access security, .NET Framework
role-based security provides PrincipalPermission objects that enable the common
language runtime to perform authorization in a way that is similar to code access
security checks. The PrincipalPermission class represents the identity or role that
the principal must match and is compatible with both declarative and imperative
security checks. You can also access a principal's identity information directly and
perform role and identity checks in your code when needed.
The .NET Framework provides role-based security support that is flexible and
extensible enough to meet the needs of a wide spectrum of applications. You can
choose to interoperate with existing authentication infrastructures, such as COM+ 1.0
Services, or to create a custom authentication system. Role-based security is
particularly well-suited for use in ASP.NET Web applications, which are processed
primarily on the server. However, .NET Framework role-based security can be used on
either the client or the server.
29) What is the difference between ASP and ASP.net
ASP ASP.net
Request(item) this method will return an array of In ASP .NET Request(item) it returns a
strings NameValueCollection
Request.QueryString(item) In ASP, this method . In ASP .NET Request.QueryString(item)
will return an array of strings. a NameValueCollection

Request.Form(item) this method will return an Request.Form(item)


array of strings it returns a NameValueCollection
http://localhost/myweb/valuetest.asp?values=10&val
ues=20 would be accessed as follows: http://localhost/myweb/valuetest.asp?values
<% ues=20 would be accessed as follows: <%
'This will output "10" 'This will output "10"
Response.Write Response.Write
Request.QueryString("values")(1) (Request.QueryString.GetValues("value

'This will output "20" 'This will output "20"


Response.Write Request.QueryString("values")(2) Response.Write
%> (Request.QueryString.GetValues("values")(1
%>
In both the case of ASP and ASP .NET, the fo
code will behave identically:
<%
'This will output "10", "20"
Response.Write (Request.QueryString("val
%>
%>
In ASP, you can declare subroutines and global In ASP .NET, this is no longer allowed. You m
variables in between your code delimiters. instead declare all of your functions and var
<% inside a <script> block.
Dim X <script language = "vb" runat = "server">
Dim str Dim str As String
Sub MySub() Dim x, y As Integer
Response.Write "This is a string."
End Sub %> Function Add(I As Integer, J As Integer) As
Return (I + J)
End Function
</script>
In ASP you must place all directives on the first line In ASP .NET, you are now required to place t
of a page within the same delimiting block. For Language directive with a Page directive, a
example: follows:
<%LANGUAGE="VBSCRIPT" CODEPAGE="932"%> <%@Page Language="VB" CodePage="932
<%@QutputCache Duration="60"
VaryByParam="none" %>
You can have as many lines of directives as
need. Directives may be located anywhere i
.apsx file but standard practice is to place th
the beginning of the file.
In ASP, developers figured out that they could do This type of coding is no longer allowed in A
clever things by using what is termed a "Render This is probably for the better. I am sure you
Function." A Render Function is basically a seen functions that quickly become unreada
subroutine that contains chunks of HTML embedded unmanageable when you start to mix and m
throughout its body. For example: code and HTML like this. The simplest way to
<%Sub RenderMe() this work in ASP .NET is to replace your HTM
%> outputs with calls to Response.Write as fo
<H3> This is HTML text being rendered. </H3> <script language="vb" runat="server">
<%End Sub Sub RenderMe()
RenderMe Response.Write("<H3> This is HTML tex
%> rendered. </H3>")
End Sub
</script>

<%
Call RenderMe()
%>

In ASP, the Option Explicit keywords were available In Visual Basic .NET, this has changed. Opti
but were not enforced as the default Explicit is now the default so all variables n
be declared
On Error Resume Next and On Error Goto error Although the familiar On Error Resume Ne
handling techniques are in Visual Basic On Error Goto error handling techniques a
allowed in Visual Basic .NET, they are not th
way to do things anymore. Visual Basic now
blown structured exception handing using th
Catch, and Finally keywords. If possible, yo
move to this new model for error handling a
allows for a more powerful and consistent
mechanism in dealing with your application
It is Having both (Single thread apartment) The ASP .NET threading model is the Multipl
STA and MTA (Multi-thread apartment) Threaded Apartment (MTA). What this mean
component components that you are using that were cr
the Single Threaded Apartment (STA) will no
perform or function reliably without taking s
extra precautions in ASP .NET. This includes,
not limited to, all COM components that hav
created using Visual Basic 6.0 and earlier ve
You will be glad to hear that you can still use
STA components without having to change a
What you need to do is include the compatib
attribute aspcompat=true in a <%@Page>
the ASP .NET page. For example, <%@Page
aspcompat=true Language=VB%>. Usin
attribute will force your page to execute in S
mode, thus ensuring your component will co
function correctly. If you attempt to use an S
component without specifying this tag, the r
will throw an exception.
In ASP, all Web application configuration information ASP .NET introduces a whole new configurat
is stored in the system registry and the IIS Metabase model based on simple, human readable XM
Each ASP .NET application has its own Web.
file that lives in its main application director

30) What is the difference between VB and VB.net


Visual Basic Visual Basic.net
Active x support ActiveX documents are not supported in Visual Basic.NET, and
like DHTML projects, cannot be automatically upgraded. We
recommend you either leave your ActiveX document
applications in Visual Basic 6.0 or, where possible, replace
ActiveX documents with user controls.
Web class support Web classes no longer exist in Visual Basic.NET. Web class
applications will be upgraded to ASP.NET; however, you will
have to make some modifications after upgrading. Existing Web
class applications can interoperate with Visual Basic.NET
Visual Basic 6.0 offered
several technologies for In Visual Basic.NET, there is a new form package: Windows
creating client/server Forms. Windows Forms has a different object model than Visual
applications: Basic 6.0 Forms, but is largely compatible
• Visual Basic Forms Visual Basic.NET also introduces a new middle-tier component,
• Microsoft Transaction Web Services. Web Services are hosted by ASP.NET, and use
Server (MTS)/COM+ the HTTP transport allowing method requests to pass through
middle-tier objects firewalls. They pass and return data using industry standard
• User controls XML, allowing other languages and other platforms to access
their functionality
Visual Basic 6.0 offered • • Visual Basic.NET does not support DAO and RDO
several types of data data binding to controls, data controls, or RDO User
access: connection
• ActiveX Data Objects
(ADO) • • Visual Basic.NET introduces an enhanced version of
• Remote Data ADO called ADO.NET. An ADO.NET target disconnected
Objects (RDO) data, and provides performance improvements over
• Data Access Objects ADO when used in distributed applications. ADO.NET
(DAO) offers read/write data binding to controls for Windows
Forms and read-only data binding for Web Forms
Previous versions of Visual In Visual Basic.NET, the functionality of the Variant
Basic supported the and Object data types is combined into one new data type:
Variant, data type which Object. The Object data type can be assigned to primitive
could be assigned to any data types, Empty, Nothing, Null, and as a pointer to an
primitive type (except fixed- object
length strings), Empty,
Error, Nothing and Null
Integer represents 16-bit In Visual Basic.NET, the data type for 16-bit whole numbers
whole number and long is now Short, and the data type for 32-bit whole numbers is
represents 32-bit whole now Integer (Long is now 64 bits).
number.
Dim x As Short
Dim x As Integer dim y as Integer
dim y as Long
Label property caption In Visual Basic.NET Windows Forms, the Caption property of
a label control is now called Text

Earlier versions of Visual You should not do this in Visual Basic.NET, because dates
Basic supported using the are not internally stored as doubles. The .NET framework
Double data type to store provides the ToOADate and FromOADate functions to
and manipulate dates convert between doubles and dates
In Visual Basic 6.0, many Visual Basic.NET does not support parameter less default
objects expose default properties, and consequently does not allow this
properties. programming shortcut
For example, Textbox has
a default property of Text,
so instead of writing:
MsgBox Form1.Text1.Text
Visual Basic 6.0 allowed you arrays in Visual Basic.NET must have a lower bound of zero,
to define arrays with lower and ReDim cannot be used unless the variable was
and upper bounds of any previously declared with Dim As Array
whole number. You could
also use ReDim to reassign
a variant as an array. To
enable interoperability with
other languages
DefBool, DefByte, DefInt, • Def<type>
DefLng, DefCur, DefSng, • Computed GoTo/GoSub
DefDbl, DefDec, DefDate, • GoSub/Return
DefStr, DefObj and DefVar • Option Base 0|1
were used in the
• VarPtr, ObjPtr, StrPtr
declarations section of a
module to define a range of • LSet
variables as a certain type This not supported by VB.net.

31) What is the difference between ADO and ADO.net


ADO.Net ADO
The ADO.NET dataset can contain one The ADO recordset is a single table, accessible only
or more tables, and provides both a as a recordset, and does not contain relationships.
table-based relational view and an An ADO recordset can be the result of a multiple
XML-based view. The dataset uses table JOIN query, but it is still only a single result
standard common language runtime table. If you want multiple tables with ADO, you must
types, which simplifies programming. have multiple Recordset objects. The ADO.NET
dataset provides better functionality due to its
integrated relational structure

ADO.NET provides the basis for data If you use COM marshaling to transmit an ADO
interchange between components and record set, the target application must be
across tiers: programmed to use the record set data structure.
1. 1. Datasets can be passed This requires more difficult programming than simply
over the Internet and through reading XML data. Alternatively, you can persist the
firewalls as XML. ADO record set as XML and more easily share the
2. 2. You can view the same data with other applications and services
set of data as relational tables
within your application and as
an XML data structure in some
other application.
3. 3. The dataset provides
convenient two-way
transformation: from dataset
tables to an XML document,
and from an XML document
into dataset tables
Sequential, read-only server ADO by a forward only/read-only Record set object.
cursors are supported in ADO.NET by Sequential, read-only cursors provide the fastest
data readers (such as the means of reading data out of a database
SqlDataReader or OleDbDataReader
objects)
In ADO.NET, rows are represented as In ADO you scan sequentially through the rows of the
collections, so you can loop through a record set using the ADO Move Next method
table as you would through any
collection, or access particular rows
via ordinal or primary key index
In ADO.NET you communicate with the In ADO you communicate with the database by
database through a data adapter (an making calls to an OLE DB provider
OleDbDataAdapter or SqlDataAdapter
object), which makes calls to an OLE
DB provider or the APIs provided by
the underlying data source
To transmit data in ADO.NET, you use To transmit an ADO disconnected record set from
a dataset, which can transmit an XML one component to another, you use COM marshalling
stream.
ADO.NET transmits data in standard Whereas ADO requires that transmitting and
XML format so that COM marshaling or receiving components be COM objects
data-type conversions are not required

32) Explain the .Net Architecture?


.Net architecture has the following:
1. Common Language Runtime (CLR)
2. Class library
CLR is an agent which will manage the code execution, thread management, garbage
collection..
Class library is nothing but a group of types (value types, references)
33) Explain ADO.net Architecture?
There are two central components of ADO.NET that accomplish this:
1. DataSet
2. .NET data provider
Dataset: The ADO.NET DataSet is the core component of the disconnected
architecture of ADO.NET. The DataSet is explicitly designed for data access
independent of any data source. As a result it can be used with multiple and differing
data sources, used with XML data, or used to manage data local to the application.
The DataSet contains a collection of one or more DataTable objects made up of rows
and columns of data, as well as primary key, foreign key, constraint, and relation
information about the data in the DataTable objects
The DataSet object is central to supporting disconnected, distributed data scenarios
with ADO.NET. The DataSet is a memory-resident representation of data that provides
a consistent relational programming model regardless of the data source. It can be
used with multiple and differing data sources, used with XML data, or used to
manage data local to the application. The DataSet represents a complete set of data
including related tables, constraints, and relationships among the tables.
. Net Data Provider: The other core element of the ADO.NET architecture is the
.NET data provider, whose components are explicitly designed for data manipulation
and fast, forward-only, read-only access to data.
A .NET data provider is used for connecting to a database, executing commands, and
retrieving results. Those results are either processed directly, or placed in an
ADO.NET DataSet in order to be exposed to the user in an ad-hoc manner, combined
with data from multiple sources, or remoted between tiers. The .NET data provider is
designed to be lightweight, creating a minimal layer between the data source and
your code, increasing performance without sacrificing functionality.
The following table outlines the four core objects that make up a .NET data provider.
Object Description
Connection Establishes a connection to a specific data
source.
Command Executes a command against a data source.
Exposes Parameters and can execute within
the scope of a Transaction from a Connection.
DataReader Reads a forward-only, read-only stream of
data from a data source.
DataAdapter Populates a DataSet and resolves updates
with the data source.

34) What is the Difference between XmlDocument and XmlDataDocument?


XML Data Document: A language used to create a schema, which identifies the
structure and constraints of a particular XML document. XML-Data carries out the same
basic tasks as DTD, but with more power and flexibility. Unlike DTD, which requires its
own language and syntax, XML-Data uses XML syntax for its language.
XML Document: A document object that is well formed, according to the XML
recommendation, and that might (or might not) be valid. The XML document has a
logical structure (composed of declarations, elements, comments, character references,
and processing instructions) and a physical structure (composed of entities, starting with
the root, or document entity).
35) What is Well-formed/Valid XML?
Well-formed XML: XML that follows the XML tag rules listed in the W3C
Recommendation for XML 1.0, but doesn't have a DTD or schema. A well-
formed XML document contains one or more elements; it has a single
document element, with any other elements properly nested under it; and
each of the parsed entities referenced directly or indirectly within the
document is well formed.
Well-formed XML documents are easy to create because they don't require the
additional work of creating a DTD. Well-formed XML can save download time
because the client does not need to download the DTD, and it can save
processing time because the XML parser doesn't need to process the DTD.
Valid XML: XML that conforms to the rules defined in the XML specification, as well
as the rules defined in the DTD or schema.
The parser must understand the validity constraints of the XML specification
and check the document for possible violations. If the parser finds any errors,
it must report them to the XML application. The parser must also read the
DTD, validate the document against it, and again report any violations to the
XML application.
Because all of this parsing and checking can take time and because validation
might not always be necessary, XML supports the notion of the well-formed
document.
36) What is the Compiler used for XML? [ans: no compiler required as it is plain
ascii text file]
37) Which is faster, early binding or late binding? What are the advantages of
the best?
Early Binding: The Visual Basic compiler performs a process called binding when an
object is assigned to an object variable. An object is early bound when it is assigned
to a variable declared to be of a specific object type. Early bound objects allow the
compiler to allocate memory and perform other optimizations before an application
executes.
For example, the following code fragment declares a variable to be of type
FileStream:
' Add Imports statements to the top of your file.
Imports System.IO
'...
' Create a variable to hold a new object.
Dim FS As FileStream
' Assign a new object to the variable.
FS = New FileStream("C:\tmp.txt", FileMode.Open)
Because FileStream is a specific object type, the instance assigned to FS is early
bound.

Late Binding:
By contrast, an object is late bound when it is assigned to a variable declared to be of
type Object. Objects of this type can hold references to any object, but lack many of
the advantages of early-bound objects. For example, the following code fragment
declares an object variable to hold an object returned by the CreateObject function:
' To use this example, you must have Microsoft Excel installed on your computer.
Option Strict Off ' Option Strict Off allows late binding.
...
Sub TestLateBinding()
Dim xlApp As Object
Dim xlBook As Object
Dim xlSheet As Object
xlApp = CreateObject("Excel.Application")
'Late bind an instance of an Excel workbook.
xlBook = xlApp.Workbooks.Add
'Late bind an instance of an Excel worksheet.
xlSheet = xlBook.Worksheets(1)
xlSheet.Activate()
xlSheet.Application.Visible = True ' Show the application.
' Place some text in the second row of the sheet.
xlSheet.Cells(2, 2) = "This is column B row 2"
End Sub
You should use early-bound objects whenever possible, because they allow the
compiler to make important optimizations that yield more efficient applications.
Early-bound objects are significantly faster than late-bound objects and make your
code easier to read and maintain by stating exactly what kind of objects are being
used. Another advantage to early binding is that it enables useful features such as
automatic code completion and Dynamic Help because the Visual Studio .NET
integrated development environment (IDE) can determine exactly what type of object
you are working with as you edit the code. Early binding reduces the number and
severity of run-time errors because it allows the compiler to report errors when a
program is compiled.
Note Late binding can only be used to access type members that are
declared as Public. Accessing members declared as Friend or Protected
Friend results in a runtime error.

38) What is Single call [in Remoting]


[Singleton types never have more than one instance at any one time. If an instance
exists, all client requests are serviced by that instance.
Single Call types always have one instance per client request. The next method
invocation will be serviced by a different server instance, even if the previous
instance has not yet been recycled by the system.]
39) What is the use of SQL Data adapter?
SQL Data adaptor is used to construct bridge between dataset and data source.This
is used to connect one or more command objects to a Dataset object.
40) What are different transaction options?
Disabled :Indicates that the transaction context will be ignored by ASP.NET. This is
the default transaction state.
NotSupported: Indicates that the page does not run within the scope of
transactions. When a request is processed, its object context is created without a
transaction, regardless of whether there is a transaction active.
Supported: Indicates that the page runs in the context of an existing transaction. If
no transaction exists, the page runs without a transaction.
Required:The page runs in the context of an existing transaction. If no transaction
exists, the page starts one.
RequiresNew:Indicates that the page requires a transaction and a new transaction
is started for each request.
41) What are object pooling and connection pooling and difference?
Object pooling : Object pooling is a COM+ service that enables you to reduce the
overhead of creating each object from scratch. When an object is activated, it is
pulled from the pool. When the object is deactivated, it is placed back into the pool to
await the next request
Object pooling lets you control the number of connections you use, as opposed to
connection pooling, where you control the maximum number reached.
Connection Pooling: Following are important differences between object pooling
and connection pooling:
• Creation. When using connection pooling, creation is on the same thread, so
if there is nothing in the pool, a connection is created on your behalf. With object
pooling, the pool might decide to create a new object. However, if you have
already reached your maximum, it instead gives you the next available object.
This is crucial behavior when it takes a long time to create an object, but you do
not use it for very long.
• Enforcement of minimums and maximums. This is not done in
connection pooling. The maximum value in object pooling is very important when
trying to scale your application. You might need to multiplex thousands of
requests to just a few objects. (TPC/C benchmarks rely on this.)
COM+ object pooling is identical to what is used in .NET Framework managed SQL
Client connection pooling
42) What is delegates and uses?
A delegate is a reference type that refers to a Shared method of a type or to an
instance method of an object. The closest equivalent of a delegate in other languages
is a function pointer, but whereas a function pointer can only reference Shared
functions, a delegate can reference both Shared and instance methods. In the latter
case, the delegate stores not only a reference to the method's entry point, but also a
reference to the object instance with which to invoke the method.
Any attributes specified in the method declaration apply to the delegate itself. The
method declaration may not have modifiers, a Handles clause, an Implements
clause, a method body, or an End construct. The accessibility domain of the return
type and parameter types must be the same as or a superset of the accessibility
domain of the delegate itself.
The members of a delegate are the members inherited from class
System.Delegate. A delegate also contains a set of constructors and methods
defined by the system. As these are specified and implemented by the .NET
Framework, they are not listed here.
There are three steps in defining and using delegates: declaration, instantiation, and
invocation.
Delegates are declared using delegate declaration syntax. The following example
declares a delegate named SimpleDelegate that takes no arguments:
Delegate Sub SimpleDelegate()
The next example creates a SimpleDelegate instance and then immediately calls it:
Module Test

Sub F()
System.Console.WriteLine("Test.F")
End Sub

Sub Main()
Dim d As New SimpleDelegate(F)
d()
End Sub
End Module
There is not much point in instantiating a delegate for a method and then
immediately calling via the delegate, as it would be simpler to call the method
directly. Delegates show their usefulness when their anonymity is used. The next
example shows a MultiCall method that repeatedly calls a SimpleDelegate instance:
Sub MultiCall(d As SimpleDelegate, count As Integer)
Dim i As Integer
For i = 0 To count - 1
d()
Next i
End Sub
It is unimportant to the MultiCall method what the target method for the
SimpleDelegate is, what accessibility this method has, or whether the method is
Shared or nonshared. All that matters is that the signature of the target method is
compatible with SimpleDelegate.
DelegateTypeDeclaration ::=
[ DelegateModifier+ ] Delegate MethodDeclaration
DelegateModifier ::= AccessModifier | Shadows

43) What is method to get XML and schema from Dataset


(ans: getXML () and get Schema ())
44) What is serialization?
Serialization is the process of converting the state of an object into a form that can
be persisted or transported. The complement of serialization is deserialization, which
converts a stream into an object. Together, these processes allow data to be easily
stored and transferred.
The .NET Framework features two serializing technologies:
• 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.
• 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.
45) Serialization technologies of .net
• 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.
• 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.
46) Difference between delegates and Events?
The runtime supports reference types called delegates that serve a purpose similar to
that of function pointers in C++. Unlike function pointers, a delegate instance is
independent of the classes of the methods it encapsulates; all that matters is that
those methods be compatible with the delegate's type. Also, while function pointers
can only reference static functions, a delegate can reference both static and instance
methods. Delegates are mainly used for event handlers and callback functions in the
.NET Framework.
All delegates inherit from System.Delegate, and have an invocation list, which is a
linked list of methods that are executed when the delegate is invoked. The resulting
delegate can reference any method with a matching signature. The return value is
not defined for a delegate that has a return type and contains more than one method
in its invocation list.
You can use the delegate's Combine and Remove methods to add and remove
methods to its invocation list. To call the delegate, use the Invoke method, or the
BeginInvoke and EndInvoke methods to call the delegate asynchronously. The
implementations of the delegate class are provided by the runtime, not by user code.
An event is a message sent by an object to signal the occurrence of an action. The
action could be caused by user interaction, such as a mouse click, or it could be
triggered by some other program logic. The object that raises (triggers) the event is
called the event sender. The object that captures the event and responds to it is
called the event receiver.
In event communication, the event sender class does not know which object or
method will receive (handle) the events it raises. What is needed is an intermediary
(or pointer-like mechanism) between the source and the receiver. The .NET
Framework defines a special type (Delegate) that provides the functionality of a
function pointer.
A delegate is a class that can hold a reference to a method. Unlike other classes, a
delegate class has a signature, and it can hold references only to methods that
match its signature. A delegate is thus equivalent to a type-safe function pointer or a
callback. While delegates have other uses, the discussion here focuses on the event
handling functionality of delegates. The following example shows an event delegate
declaration.
' AlarmEventHandler is the delegate for the Alarm event.
' AlarmEventArgs is the class that holds event data for the alarm event.
' It derives from the base class for event data, EventArgs.
Public Delegate Sub AlarmEventHandler(sender As Object, e As AlarmEventArgs)
The syntax is similar to that of a method declaration; however, the delegate
keyword informs the compiler that AlarmEventHandler is a delegate type.
By convention, event delegates in the .NET Framework have two parameters, the
source that raised the event and the data for the event.
Note A delegate declaration is sufficient to define a delegate class.
The declaration supplies the signature of the delegate, and the
common language runtime provides the implementation.
An instance of the AlarmEventHandler delegate can bind to any method that matches
its signature, such as the AlarmRang method of the WakeMeUp class shown in the
following example.
Public Class WakeMeUp
' AlarmRang has the same signature as AlarmEventHandler.
Public Sub AlarmRang(sender As Object, e As AlarmEventArgs)
...
End Sub
...
End Class
To connect (wire) AlarmRang to an Alarm event:
1. Create an instance of the AlarmEventHandler delegate that takes a reference
to the AlarmRang method of the WakeMeUp instance in its constructor, as shown
in the following example.
' Create an instance of WakeMeUp.
Dim w As New WakeMeUp()
' Instantiate the event delegate.
Dim alhandler As AlarmEventHandler = AddressOf w.AlarmRang
Now, whenever alhandler is called, it in turn calls the AlarmRang method of
the WakeMeUp instance.
14. Register the alhandler delegate with the Alarm event. For details and a
complete sample, see Event Sample.
Custom event delegates are needed only when an event generates event data. Many
events, including some user-interface events such as mouse clicks, do not generate
event data. In such situations, the event delegate provided in the class library for the
no-data event, System.EventHandler, is adequate. Its declaration follows.

' The base class for event data, EventArgs, does not have
' any data and hence can be used as the event data type for events that do not
generate data.

Public Delegate Sub AlarmEventHandler(sender As Object, e As AlarmEventArgs)


Event delegates are multicast, which means that they can hold references to more
than one event handling method. For details, see Delegate. Delegates allow for
flexibility and fine-grain control in event handling. A delegate acts as an event
dispatcher for the class that raises the event by maintaining a list of registered event
handlers for the event.
For details on using delegates to provide event functionality in your component or
control, see Raising an Event.
For an overview of consuming events in your applications, see Consuming Events.
47) Difference between synchronize and asynchronies?
Not Answered
48) Difference between read only and write only properties
Most properties have both Get and Set property procedures to allow you to both
read and modify the value stored inside. However, you can use the ReadOnly or
WriteOnly modifiers to restrict properties from being modified or read. Read-only
properties cannot have Set property procedures; they are useful for items that you
want to expose but not allow to be modified. For example, you could use a read-only
property to provide the processor speed of a computer. Write-only properties cannot
have Get property procedures and are useful for data that you want to store but not
expose to other objects. For example, a write-only property could be used to store a
password.
49) Explain the exception handing in .NET
Visual Basic supports both structured and unstructured exception (error) handling. By
placing specific code in your application, you can handle most of the errors users
may encounter and enable the application to continue running. Structured and
unstructured error handling allow you to plan for potential errors, preventing them
from interfering with the intended purpose of the application.
Consider using exception handling in any method that uses operators that may
generate an exception, or that calls into or accesses other procedures that may
generate an exception.
If an exception occurs in a method that is not equipped to handle it, the exception is
propagated back to the calling method , or the previous method. If the previous
method also has no exception handler, the exception is propagated back to that
method 's caller, and so on. The search for a handler continues up the call stack,
which is the series of procedures called within the application. If it fails to find a
handler for the exception, an error message is displayed and the application is
terminated.
Note A single method can contain either structured or unstructured
exception handling, but not both.
Structured Exception Handling
In structured exception handling, blocks of code are encapsulated, with each block
having one or more associated handlers. Each handler specifies some form of filter
condition on the type of exception it handles. When an exception is raised by code in
a protected block, the set of corresponding handlers is searched in order, and the
first one with a matching filter condition is executed. A single method can have
multiple structured exception handling blocks, and the blocks can also be nested
within each other.
The Try...Catch...Finally statement is used specifically for structured exception
handling.
Unstructured Exception Handling
The On Error statement is used specifically for unstructured exception handling. In
unstructured exception handling, On Error is placed at the beginning of a block of
code. It then has "scope" over that block; it handles any errors occurring within the
block. If the program encounters another On Error statement, that statement
becomes valid and the first statement becomes invalid.
50) Which is the base class for .net Class library? (Ans: stytem.object)
51) How will u create windows services?
If you choose not to use the Windows Service project template, you can write your
own services by setting up the inheritance and other infrastructure elements yourself.
When you create a service programmatically, you must perform several steps that
the template would otherwise handle for you:
• You must set up your service class to inherit from the
System.ServiceProcess.ServiceBase class.
• You must create a Main method for your service project that defines the
services to run and calls the Run method on them.
• You must override the OnStart and OnStop procedures and fill in any code
you want them to run.
To write a service programmatically
1. Create an empty project and create a reference to the necessary namespaces
by following these steps:
a. In Solution Explorer, right-click the References node and click Add
Reference.
b. On the .NET Framework tab, scroll to System.dll and click Select.
c. Scroll to System.ServiceProcess.dll and click Select.
d. Click OK.
2. Add a class and configure it to inherit from
System.ServiceProcess.ServiceBase:
' Visual Basic
Public Class UserService1
Inherits System.ServiceProcess.ServiceBase
End Class

// C#
public class userService1 : System.ServiceProcess.ServiceBase {
}
Add the following code to configure your service class:
' Visual Basic
Public Sub New()
Me.ServiceName = "MyService2"
Me.CanStop = True
Me.CanPauseAndContinue = True
Me.AutoLog = True
End Sub

// C#
public void userService1() {
this.ServiceName = "MyService2";
this.CanStop = true;
this.CanPauseAndContinue = true;
this.AutoLog = true;
}
Create a Sub Main for your class, and use it to define the service your
class will contain:
' Visual Basic
Public Sub Main()
System.ServiceProcess.ServiceBase.Run(New UserService1())
End Sub

// C#
public static void Main() {
System.ServiceProcess.ServiceBase.Run(new UserService1());
}
where userService1 is the name of the class.
Override the OnStart method, and define any processing you want to
occur when your service is started.
' Visual Basic
Protected Overrides Sub OnStart(ByVal args() As String)
' Your processing here
End Sub

// C#
protected override void OnStart(string[] args) {
// Your processing here
}
3. Override any other methods you want to define custom processing for, and
write code to determine the actions the service should take in each case.
4. Add the necessary installers for your service application..
5. Build your project by selecting Build Solution from the Build menu.
Note Do not press F5 to run your project — you cannot run a service
project in this way.
6. Create a setup project and the custom actions to install your service. Install
the service.
52) How many web.config files can we have for an application? [ ans : 1]
53) What are CCW and RCW?
When a COM client calls a .NET object, the common language runtime creates the
managed object and a COM callable wrapper (CCW) for the object. Unable to
reference a .NET object directly, COM clients use the CCW as a proxy for the
managed object.
The runtime creates exactly one CCW for a managed object, regardless of the
number of COM clients requesting its services. As the following illustration shows,
multiple COM clients can hold a reference to the CCW that exposes the INew
interface. The CCW, in turn, holds a single reference to the managed object that
implements the interface and is garbage collected. Both COM and .NET clients can
make requests on the same managed object simultaneously.
COM callable wrappers are invisible to other classes running within the .NET
Framework. Their primary purpose is to marshal calls between managed and
unmanaged code; however, CCWs also manage the object identity and object lifetime
of the managed objects they wrap.
Object Identity The runtime allocates memory for the .NET object from its garbage-
collected heap, which enables the runtime to move the object around in memory as
necessary. In contrast, the runtime allocates memory for the CCW from a non-
collected heap, making it possible for COM clients to reference the wrapper directly.
Object Lifetime Unlike the .NET client it wraps, the CCW is reference-counted in
traditional COM fashion. When the reference count on the CCW reaches zero, the
wrapper releases its reference on the managed object. A managed object with no
remaining references is collected during the next garbage-collection cycle.

54) 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.
55) What is SOAP? : Simple Object Access Protocol
Not Answered
56) What are user controls, custom controls and web 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 applications.
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.
In Windows Forms: A user-authored, client-side control that derives from the
System.Windows.Forms.UserControl class and is developed by combining existing
controls.
57)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.