.NET & ASP.NET Developer Guide
.NET & ASP.NET Developer Guide
MS interview.
1. In C# he asked what are the Value types and Reference types
2. In depth explanation of stack and Heap with respect to .NET and other languages like C++
3. What r the advantages comparatively, Value types are derived from which namespace and
reference types as well.
4. Why u have chosen C#, what r the reasons behind in choosing this in my last project.
5. How this is more advantageous then other languages as well when ur targeting
6. What r the data types in C# and explain in detail
7. How many types of access modifiers r there in C# and explain internal
8. Diff b/w ASP and ASP.NET (Only this question came from list)
9. Explain any 3 ASP.NET features u know in ASP.NET which u have used in project
1
.NET Faq Naresh Kumar Nelluri
22. How do you design a database? - basics of DB Design, SPs, triggers?
23. What are the normal forms and which is the best?
24. If a database is in 3NF, how many minimum number of tables should it have?
25. What is referential integrity & how is it achieved?
26. What is a Primary Key? Can it have >1 field?
27. What are constraints?
28. Why should you create index? Types on indexes?
29. What is a trigger and stored procedure?
30. What are inserted and deleted tables?
31. What is a view?where will you use views?
32. What is fillfactor?
COM
1. What is COMInterop?
2. Question on Tlbimp,Tlbexp and other tools?
3. What is the difference between COM and DCOM?
4. Question on iunknown interface and methods i.r addref,release etc..
5. What is the default interface for any COM component?
6. What are the methods available in IUnknown?
7. What is IDispatch?
8. What is the diffrence between activex exe and activex dll?
9. How will you choose between activex exe and activex dll?
10. OLE
11. ActiveX.exe example.
ASP
1. Ways to Instantiate a Object
2. Modeling languages.
3. ASP built-in objects
4. HTML and DHTML
SQL
1. What is clustered index and a non-clustered index?
2. What is an indexed view and why do you need it?
3. What is an execution plan?
4. How will you return results as xml from SQL server?
5. How do you design a database? - basics of DB Design, SPs, triggers?
6. What are the normal forms and which is the best?
7. If a database is in 3NF, how many minimum number of tables should it have?
8. What is referential integrity & how is it achieved?
9. What is a Primary Key? Can it have >1 field?
10. What are constraints?
11. Why should you create index? Types on indexes?
12. What is a trigger and stored procedure?
13. Types of triggers?
2
.NET Faq Naresh Kumar Nelluri
14. What are inserted and deleted tables?
15. What is a view? where will you use views?
16. What is fillfactor?
17. You have a table containing information about empid, empname, emailid, emailname and
emailtext. How will you normalize the table.
18. You have a table containing empid, empname, managerid. Write an SQL to display the emp
name along with his manager's name.
19. Desing a db for a school database?
20. What is SQL Trace?
21. What is a join and what are different types of joins?
22. Difference between union and join
23. Difference between Group by and Having clause
24. Implementation of Stored procedures
25. SQL performance tuning
XML
1. What is xml? Diffrences between xml and html?
2. What xsl? Where will you use this technology..give an example.
3. What are the XML parsers you are aware of?
4. What is the difference between DOM and SAX?
OO Programming
1. Pillars of OO Progg
2. What is a Constructor?
3. What is a Destructor?
4. What is inheritance and why is it needed?
5. What is Polymorphism?
6. Say you have identified a set of objects – how will identify a base class?
7. What is an abstract class?
8. What is late binding and early binding?
9. Modeling languages.
ASP
1. What are the built-in objects in ASP?
2. What are the data type in ASP?
3. Are vbscript, vb strongly typed languages?
4. How can you pass values between two pages in asp?
5. How do you make ASP applications secure.
6. Suppose you have an application for credit card validation. What steps will you take to
restrict unauthorized users from using the application.
7. Write the code snippet for fetching data from a table and populating in a list box control of
an asp page.
8. HTML and DHTML
9. Say you are designing a product page – the products list is constant? How will you design
this page? (will you go to db each time to retrieve the list of products for each user?)
10. Similarly how will you store user orders ?
11. How will you manage user session in a web-farm scenario?
12. Performance tuning ASP applications
3
.NET Faq Naresh Kumar Nelluri
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnserv/html/
server03272000.asp
VB & COM
Problem with using Global vars in VB components developed for Web Apps:
http://www.microsoft.com/msj/defaultframe.asp?page=/msj/0598/activex0598.htm&nav=/msj/
0598/newnav.htm
General Threading:
http://www.devarticles.com/art/1/182/2
Glossary of COM/DCOM:
http://www.innovatia.com/software/papers/com.htm
.NET
1. What is the difference between object type and value type?
2. What are the different types of objects available in ADO.Net.
3. How ADO.Net differs from ADO.
4
.NET Faq Naresh Kumar Nelluri
4. What are delegates in C#. How they are used?
5. What is a WebService? Give an example.
6. How is a WebService qualified or defined
7. What is format of WSDL?
8. Question on Reflection?
9. What is Attribute Programming? What are attributes? Where are they used?
10. How state is maintained in ASP.Net.
11. How objects will be managed in .net?
12. How can you pass values between two pages in asp?how will you do the same in ASP.net?
13. What are the main differences between asp and asp.net?
14. What is user control?
15. How do you a replicate a set of controls across a number of ASP Pages.
16. If you have to replicate a set of controls(UI) across a number of web pages, what will you
do?
17. What are different types of controls available in ASP.Net
18. What are the validation controls available in ASP.net?
19. How will you upload a file to IIS in Asp and how will you do the same in ASP.net?
20. What are the Database related classes available in .Net?
21. What is the diff. bet DataReader & DataSet?
22. How do you connect to database in ASp.net and in ASP?
23. What is the difference between recordset and dataset?
24. What are the new object introduced in ado.net that are nor there in ADO?
25. How do you handle errors in VB.net or c#?
26. What is the difference between new and override keywords in c# in the context of
inheritance?
27. Does .NET support multiple inheritance?
28. Security in ASP.NET
5
.NET Faq Naresh Kumar Nelluri
18. Class A
{
Int I =10;
Void new()
{
I = 20 ;
}
}
6
.NET Faq Naresh Kumar Nelluri
62. What is Remoting?
63. What is WEB SERVICE?
64. How WEB SERVICE is secure over network?
65. How good u r in XML? What is NODE, ELEMENT and ATTRIBUTE?
66. Tell me any one parser to read XML? Did u use it before?
67. Why do u prefer XML serialization in .NET?
68. Tell me ADO.NET architecture?
69. How can I update the Datasets date to the database?
70. What is Dataview ? How it is useful?
71. Why SQLClient and OLEDB classes are given in Data namespace? Which one is optimistic?
72. What are Instance Types available in VB 6.0?
73. How GC collects Objects?
74. Does GC collects Value Types? If not, what happen to them after scope is over?
75. When GC moves memory addresses while collecting unused objects, what happen to the
addresses of unmanaged objects and their addresses?
76. What is meant by Windows authentication?
77. My database server and Application server are different. When I connect to database server
from Application, I use connection string. So, it passes through network I think definining
like “server=xx;databse=pubs;uid=pqr;pwd=abc” is insecure. Is there any methodology to
make safe while pass through network.
78. What is Distributed database?
79. What is Linked Server?
80. Is there any relation to the Linked server with the Distributed database?
81. What is database tuning?
82. What is Lock?
83. What is Trace?
84. Tell me three normal forms.
85. What is Composite key?
86. Explain joins
87. What is Equi join?
88. What is Self join?
89. What is an extended stored procedure?
90. What is a trigger?
91. How many types of triggers we have in SQL server 2000?
92. What is INSTEAD of trigger type?
93. What is cursor?
94. Tell me few keywords while declaring a cursor?
95. When we go for dynamic cursor?
96. In a stored proc, string variable is consisting SQL statement. How do you run it? Is there
any other alternative to run it?
97. Name few functions used in SQL server?
98. What is difference between PatIndex and CharIndex?
99. My table doesn’t have key. So many duplicate rows exists in the table. I want to eliminate
all the duplicate rows and keep only one unique row. Can u accomplish this task in a single
query? If not, how do you do it?
100. What are default databases present with SQL server?
101. What are the must present databases to work with SQL server?
102. What is UNICODE?
103. What is difference between varchar and Nvarchar?
104. What is difference between WHERE and HAVING?
105. Why do we use GROUP BY
106. How clustered index works in table?
107. What is COMPUTE , CUBE , ROLLUP?
108. How do you maintain transaction in Stored Procedure?
109. If error comes in the middle of stored proc, does remaining part execute?
110. How do you find whether error occurred or not?
7
.NET Faq Naresh Kumar Nelluri
111. My SP has three DML statements in an order. Insert, Delete and Update. I am not
maintaining transaction. Some how I got error while running a Delete statement. Does
Update statement execute? Does earlier(Insert) statement committed?
112. How do you write code for the above case using transactions?
113. What is execution plan?
114. What do you observe in Execution Plan to know the performance of the query/statement?
115. What are UNION and INTERSECT?
116. What is alternate Key?
117. Tell me the case where we ignore normalization?
118. What is BCNF and tell me few cords’ rules.
119. What are data types available in SQL Server?
120. How do u normalize given non-normalized table? Tell me steps u follow.
Question on ASP.NET
Programmable Controls
ASP .NET contains a large set of HTML controls. Almost all HTML elements on a page can be
defined as ASP .NET control objects that can be controlled by scripts.
ASP .NET also contains a new set of object oriented input controls, like programmable list
boxes, validation controls.
A new data grid control supports sorting, data paging, and everything you expect from a
dataset control.
All ASP .NET objects on a Web page can expose events that can be processed by ASP .NET
code.
Load, Click and Change events handled by code makes coding much simpler and much
better organized.
ASP .NET components are heavily based on XML. Like the new AD Rotator, that uses XML to
store advertisement information and configuration.
ASP .NET supports forms-based user authentication, including cookie management and
automatic redirecting of unauthorized logins.
(You can still do your custom login page and custom user checking).
ASP .NET allows for user accounts and roles, to give each user (with a given role) access to
different server code and executables.
Higher Scalability
8
.NET Faq Naresh Kumar Nelluri
Much has been done with ASP .NET to provide greater scalability.
Server to server communication has been greatly enhanced, making it possible to scale an
application over several servers. One example of this is the ability to run XML parsers, XSL
transformations and even resource hungry session objects on other servers.
The first request for an ASP .NET page on the server will compile the ASP .NET code and
keep a cached copy in memory. The result of this is greatly increased performance.
Configuration files can be uploaded or changed while the application is running. No need to
restart the server. No more metabase or registry puzzle.
Xcopy deployment. No more server restart to deploy or replace compiled code. ASP .NET
simply redirects all new requests to the new code.
2. How will you upload a file to IIS in Asp and how will you do the same in ASP.net?
In asp we had to read binary data posted by the form and parse the headers etc.
In asp.net we can use the same html input file (html control but run at server) and can save the
file by simply calling controlname.postedFile.saveAs(filename)
HTML server controls HTML elements exposed to the server so you can program them.
HTML server controls expose an object model that maps very closely to the HTML elements
that they render.
Web server controls Controls with more built-in features than HTML server controls. Web
server controls include not only form-type controls such as buttons and text boxes, but also
special-purpose controls such as a calendar. Web server controls are more abstract than
HTML server controls in that their object model does not necessarily reflect HTML syntax.
Validation controls Controls that incorporate logic to allow you to test a user's input. You
attach a validation control to an input control to test what the user enters for that input
control. Validation controls are provided to allow you to check for a required field, to test
against a specific value or pattern of characters, to verify that a value lies within a range,
and so on.
User controls Controls that you create as Web Forms pages. You can embed Web Forms
user controls in other Web Forms pages, which is an easy way to create menus, toolbars,
and other reusable elements.
9
.NET Faq Naresh Kumar Nelluri
RequiredFieldValidator
Ensures that the user does not skip a required field when entering data on a Web Forms page
CompareValidator
Compares a user's entry against a constant value, against the property value of another control, or
against a database value
RangeValidator
Ensures that a user's entry is between specified upper and lower bounds
RegularExpressionValidator
Ensures check that a user's entry matches a pattern defined by a regular expression.
CustomValidator
Ensures that a user's entry matches validation logic you create yourself.
5. If you have to replicate a set of controls(UI) across a number of web pages, what will
you do?
This directive is used explicitly to import namespace onto the page. This will allow all the classes
and interfaces of the namespace to be accessible within the code.
We can use the classes and interface in the code without importing namespaces also but we need
to prefix complete namespace to the class that we are going to use.
For example
You should share assemblies by installing them into the global assembly cache only when you need
to.
10
.NET Faq Naresh Kumar Nelluri
There are several ways to deploy an assembly into the global assembly cache:
Use an installer designed to work with the global assembly cache. This is the preferred
option for installing assemblies into the global assembly cache.
Use a developer tool called the Global Assembly Cache tool (Gacutil.exe) provided by
the .NET Framework SDK.
Use Windows Explorer to drag and drop assemblies into the cache.
Needs to discuss
Using querystrings
Response.redirect(“url?name=abc”)
Using Server.Transfer
Details at
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/
cpconpassingservercontrolvaluesbetweenpages.asp
We create read only property (that returns the value which u want to access across pages) in the
source file
11
.NET Faq Naresh Kumar Nelluri
Server.Transfer("secondpage.aspx")
Declare a variable in server-side script to store an instance of the class defined in the Web
Forms page sending the information.
[Visual Basic]
<script runat="server">
Dim fp As FirstPageClass
</script>
Assigns the IHttpHandler implemented object for the current HTTP request to the variable declared
in the previous step when the Web Forms page does not post back to itself.
The IHttpHandler implemented object contains an instance of the handler that first received the
HTTP request. Because the IHttpHandler implemented object is not the same type of object as
the variable declared in the previous step, it must be converted to the class encapsulating the
information sent from the first Web Forms page before it can be assigned to the variable. Retrieve
the handler object by using the Handler property of the HttpContext object.
[Visual Basic]
<script runat="server">
Sub Page_Load()
If Not IsPostBack Then
fp = CType(Context.Handler, FirstPageClass)
End If
End Sub
</script>
The variable declared in the second step now contains an instance of the class encapsulating the
information from the previous Web Forms page.
<%=fp.FirstName%>
Question on ADO.NET
Two key elements are .net data provider (set of components) and dataset.
Objects in ADO.Net
ADO ADO.NET
In-memory Representations of Data
In-memory representation of data is the In-memory representation of data is the
recordset dataset
Number of Tables
A recordset looks like a single table. If a A dataset is a collection of one or more
recordset is to contain data from multiple tables. The tables within a dataset are
database tables, it must use a JOIN called data tables; specifically, they are
query, which assembles the data from DataTable objects. If a dataset contains
the various database tables into a single data from multiple database tables, it will
result table. typically contain multiple DataTable
objects. That is, each DataTable object
typically corresponds to a single
database table or view. In this way, a
dataset can mimic the structure of the
underlying database. A dataset usually
also contains relationships. Because the
dataset can hold multiple, separate
tables and maintain information about
relationships between them, it can hold
much richer data structures than a
recordset, including self-relating tables
and tables with many-to-many
relationships.
Data Navigation
In ADO you scan sequentially through In ADO.NET, rows are represented as
the rows of the recordset using the ADO collections, so you can loop through a
MoveNext method table as you would through any
collection, or access particular rows via
ordinal or primary key index.
DataRelation objects maintain
information about master and detail
records and provide a method that allows
you to get records related to the one you
are working with.
13
.NET Faq Naresh Kumar Nelluri
To transmit an ADO disconnected Transmitting an ADO.NET dataset
recordset from one component to between applications is much easier than
another, you use COM marshalling. transmitting an ADO disconnected
recordset.
The transmission of XML files offers the following advantages over COM
marshalling
Richer data types
COM marshalling provides a limited set of data types — those defined by the COM
standard. Because the transmission of datasets in ADO.NET is based on an XML
format, there is no restriction on data types. Thus, the components sharing the
dataset can use whatever rich set of data types they would ordinarily use.
Performance
Transmitting a large ADO recordset or a large ADO.NET dataset can consume
network resources; as the amount of data grows, the stress placed on the network
also rises. Both ADO and ADO.NET let you minimize which data is transmitted. But
ADO.NET offers another performance advantage, in that ADO.NET does not require
data-type conversions. ADO, which requires COM marshalling to transmit records
sets among components, does require that ADO data types be converted to COM
data types.
Penetrating Firewalls
A firewall can interfere with two components trying to transmit disconnected ADO
recordsets. Remember, firewalls are typically configured to allow HTML text to pass,
but to prevent system-level requests (such as COM marshalling) from passing.
Because components exchange ADO.NET datasets using XML, firewalls
can allow datasets to pass.
In asp.net
In ASP
<%
dim cnString
14
.NET Faq Naresh Kumar Nelluri
dim cn
set cn = server.createobject(“adodb.connection”)
cn.open cnString
%>
4. What are the new object introduced in ado.net that are nor there in ADO
Datareader need all the time to be connected to the datasource but dataset is disconnected one.
Database Transactions
finally you can call the following statements according to your conditions
15
.NET Faq Naresh Kumar Nelluri
objTran.Commit()
or
objTran.Rollback()
8. Which class you have commonly used from the System.Data namespace
Basic concepts
Authentication is a process of discovering the individual identity of users, and making them prove
that they are who they say they are.
Authorization is the process of determining if a particular user is entitled to access the resource
they have requested.
Impersonation is the process whereby the resource is accessed under a different identity usually
the context of a remote user.
Data or functional security is the process of securing the system through physical means, OS
updates, and the use of robust software.
Authentication in IIS
Following checks are done by IIS before actually serving a request.
16
.NET Faq Naresh Kumar Nelluri
account is valid and has appropriate permission for that resource. Base64 encoding is not
very secure.
Access control list(ACL) defines which user has got what rights (Full control, read , write). Right
click on the folder and set the security options.
Authorization in IIS
You can set Script Source Access, Log Visits, Read, Index this resource, Write, directory
browsing.
This applies to all the users who have access to this application.
ASP.net impersonation
Windows
Passport
Forms
17
.NET Faq Naresh Kumar Nelluri
</system.web>
</configuaration>
In the forms based authentication, we can use credentials or use xml file that has
username/password or database in order to authenticate.
Windows based
<configuaration>
<system.web>
<authentication mode=”Windows” />
<identity impersonate=”true” />
<authorization>
<allow roles=”some roles” users=”some users” />
<deny roles=”some roles” users=”some users” />
</authorization>
</system.web>
</configuaration>
ASP.NET
1. What is the difference between object type and value type?
When an object is allocated from the managed heap, the new operator returns the memory
address of the object. You usually store this address in a variable. This is called a reference type
variable because the variable does not actually contain the object's bits; instead, the variable
refers to the object's bits
There are some performance issues to consider when working with reference types. First, the
memory must be allocated from the managed heap, which could force a garbage collection to
occur. Second, reference types are always accessed via their pointers. So every time your code
references any member of an object on the heap, code must be generated and executed to
dereference the pointer in order to perform the desired action. This adversely affects both size and
speed.
Error! Unknown switch argument.In addition to reference types, the virtual object system
supports lightweight types called value types. Value type objects cannot be allocated on the
garbage-collected heap, and the variable representing the object does not contain a pointer to an
object; the variable contains the object itself. Since the variable contains the object, a pointer does
not have to be dereferenced in order to manipulate the object. This, of course, improves
performance
The main advantage of value types is that they are not allocated in the managed heap. Of course,
value types have several limitations compared with reference types. Here are some of the ways in
which value types and reference types differ.
Error! Unknown switch argument.Value type objects have two representations: an unboxed
form and a boxed form. Reference types are always in a boxed form.
Boxing is an implicit conversion of a value type to the type object or to any interface type
implemented by this value type. Boxing a value of a value allocates an object instance and copies
the value into the new object.
Unboxing is an explicit conversion from the type object to a value type or from an interface type
to a value type that implements the interface. An unboxing operation consists of:
Checking the object instance to make sure it is a boxed value of the given value type.
18
.NET Faq Naresh Kumar Nelluri
Copying the value from the instance into the value-type variable.
DataTableCollection
DataTable
DataRowCollection
DataColumnCollection
ConstraintCollection
DataRelationCollection
19
.NET Faq Naresh Kumar Nelluri
SOAP stands for Simple Object Access Protocol. It is a communication protocol for sending
information between application over internet via HTTP.
Application State Application state is controlled through the application object. Application
allows us to maintain data for a given ASP.NET application. Setting should be done to access
the data for all the resources like web services, ASP.NET page and so on.
Static Variables Only one copy of the variable is created no matter how many instances of the
classes are created and these are available through out the application in more efficient way
than the Application.
5. How can you pass values between two pages in asp? How will you do the same in ASP.net?
In ASP values can be passed between two pages using request object.
20
.NET Faq Naresh Kumar Nelluri
the information, first create a property with a get accessor, in the class, for each value you
want to share. The get accessor should return the value you want to pass, such as the value of
a text box. To send the information, transfer control of the application to a different Web Forms
page by using the Transfer method of the Server object.
On the receiving Web Forms page, reference the class declared in the sending page by adding
an @Reference directive, at the top of the page, with the Page attribute set to the sending
page. You can then retrieve an instance of the handler that first received the HTTP request from
the Handler property of the Context object.
21
.NET Faq Naresh Kumar Nelluri
9. If you have to replicate a set of controls(UI) across a number of web pages, what will
you do?
Using custom controls.—NEED TO DISCUSS
12. How will you upload a file to IIS in Asp and how will you do the same in ASP.net?
In ASP using File control , Response.BinaryRead, Response.AddContentType
In ASP.NET usinfg server side file input control and filecontrol.PostedFile object
22
.NET Faq Naresh Kumar Nelluri
There is one significant difference between disconnected processing in ADO and ADO.NET. In
ADO you communicate with the database by making calls to an OLE DB provider. In ADO.NET you
communicate with the database through a data adapter (an OleDbDataAdapter, SqlDataAdapter,
OdbcDataAdapter, or OracleDataAdapter object), which makes calls to an OLE DB provider or the
APIs provided by the underlying data source. The important difference is that in ADO.NET the data
adapter allows you to control how the changes to the dataset are transmitted to the database — by
optimizing for performance, performing data validation checks, or adding any other extra
processing.
16. What is the difference between recordset and dataset?
A recordset looks like a single table. If a recordset is to contain data from multiple database
tables, it must use a JOIN query, which assembles the data from the various database tables into a
single result table.
In contrast, a dataset is a collection of one or more tables. The tables within a dataset are
called data tables; specifically, they are DataTable objects. If a dataset contains data from multiple
database tables, it will typically contain multiple DataTable objects. That is, each DataTable
object typically corresponds to a single database table or view. In this way, a dataset can mimic
the structure of the underlying database.
18.Security in ASP.NET
ANS: The import directive specifies another IDL, ODL, or header file containing definitions you wish
to reference from your main IDL file.
20. Which class you have commonly used from the System.Data namespace.
DataSet, DataColumn, DataColumnCollection, DataTable, DataType, DataRow, DataRelation,
DataView
22. When should we consider the Session states and application states. where do we
declare them?
23
.NET Faq Naresh Kumar Nelluri
.NET
11. What are delegates in VB.NET/C#. How they are used?
12. What are the Value types and Reference types?
13. In depth explanation of stack and Heap with respect to .NET?
14. What r the advantages comparatively, Value types are derived from which namespace and
reference types as well.
15. What r the data types in vb.net and explain in detail
16. How many types of access modifiers r there in vb.net and explain internal
17. What is Attribute Programming? What are attributes? Where are they used?
18. What is Reflection?
19. What is a Constructor?
20. What is a Destructor?
21. How objects will be managed in .net?
24
.NET Faq Naresh Kumar Nelluri
22. How do you handle errors in VB.net or c#?
23. What is Polymorphism?
24. Say you have identified a set of objects – how will identify a base class?
25. What is an abstract class?
26. What is the difference between new and override keywords in c# in the context of
inheritance?
27. Does .NET support multiple inheritance?
a. No.
ADO.NET
Objects that own resources other than memory (in particular “handles”, such as Windows handles,
file handles and SQL handles) need to be told explicitly to release those resources when the object
is no longer required. This includes all Windows controls, since they all own Windows handles! You
might ask, why not put the code to release those resources in the object’s destructor? There are
two reasons for this:
The automatic garbage collector, which is responsible for initiating the destructor (by
identifying and deleting dead objects) is concerned with memory issues and not resource
issues. Hence if running on a PC with a few gigabytes of free RAM, it may wait an hour or two
before even getting out of bed!
There is no guarantee that the destructor will ever get called, even once memory is
released.
The last point is very important – due to the complexities of automatic garbage collection, you
can’t rely on destructors, and this is an inherent limitation in the CLR.
While destructors do not work properly, memory management does. You can be sure that the
memory belonging to an orphaned object will always be released, even though its destructor may
never be called.
The other effect of adding it to the Controls collection is that the .NET framework will
deterministically call a method called Dispose on all of its members the instant they’re no longer
needed. And in this Dispose method, the control can release its Windows handle, as well as
dropping the textbox off the screen.
All classes descending from MarshalByRefComponent (including all Windows Forms controls) have a
Dispose method. This method must be called when an object is no longer needed in order to
release resources other than memory. There are two ways this happens:
- manually (by calling Dispose explicitly)
- automatically: by adding the object to a .NET container, such as a Form, Panel, TabPage or
UserControl. The container will ensure that when it’s Disposed, so are all of its members. Of
course, the container itself must be Disposed (or in turn, be part of another container).
In the case of Windows Forms controls, we nearly always add them to a container – and hence rely
on automatic disposal.
25
.NET Faq Naresh Kumar Nelluri
Class objects have an extra storage and execution overhead in that they require a pointer, which
must be de-referenced at runtime. This overhead, while quite small, is not desirable with a type so
fundamental as Size or Point
26
.NET Faq Naresh Kumar Nelluri
9. You have a table containing empid, empname, managerid. Write an SQL to display the emp
name along with his manager's name.
10. How state is maintained in ASP.Net.
Boxing is converting value type to reference type and unboxing is converting reference type to
value type
It is interesting to note that the runtime type of box is returned as the boxed value type;
int i = 123;
object box = i; (box is int) returns true
Boxing allocates memory for the value being boxed on heap, copies the value into this memory
and stores its reference in an object type. Consider the following code.
int i = 12 ;
Console.WriteLine ( “The value is {0} ”, i ) ;
The WriteLine( ) method is written to accept objects. When we pass a variable of value type, int
in this case, it gets boxed into an object. Using this object a method ToString( ) is called, which
returns the string equivalent of the value stored in a variable. WriteLine( ) then displays this
string.
The primitive data types in C# are mapped to underlying structures defined by the .NET base
class library. This is done to ensure that code written in C# can be used in other .NET compliant
languages.
Implicit type conversion is allowed so long as there is no loss of data. If we want to convert a
data type into another for which implicit conversion is not possible, we can do so by type
casting.
Reference types actually hold the value of a memory address occupied by the object they
reference. Consider the following piece of code, in which two variables are given a reference to
the same object (for the sake of the example, this object is taken to contain the numeric
property 'myValue').
object x = new object();
x.myValue = 10;
object y = x;
y.myValue = 20; // after this statement both x.myValue and y.myValue equal 20
27
.NET Faq Naresh Kumar Nelluri
This code illustrates how changing a property of an object using a particular reference to it is
reflected in all other references to it. Note, however, that although strings are reference types,
they work rather more like value types. When one string is set to the value of another, eg
string s1 = "hello";
string s2 = s1;
Then s2 does at this point reference the same string object as s1. However, when the value of
s1 is changed, for instance with
s1 = "goodbye";
what happens is that a new string object is created for s1 to point to. Hence, following this
piece of code, s1 equals "goodbye", whereas s2 still equals "hello".
The reason for this behaviour is that string objects are 'immutable'. That is, the properties of
these objects can't themselves change. So in order to change what a string variable references,
a new string object must be created.
You can find out whether an Object variable is acting as a reference type or a value type by
passing it to the IsReference method on the Information class in the Microsoft.VisualBasic
namespace. Microsoft.VisualBasic.Information.IsReference returns True if the content of
the Object variable represents a reference type.
2. In depth explanation of stack and Heap with respect to .NET and other languages like C++
3. What r the advantages comparatively, Value types are derived from which namespace and
reference types as well.
4. Why u have chosen C#, what r the reasons behind in choosing this in my last project.
C# allows unmanaged code
C# has structured error handling
VB .Net has project level setting to check for integer over flow (can be turned on or off)
C# can run in checked or unchecked context.. in checked arithmetic overflow raises exception
else… the data gets truncated.
C# allows use of XML Documentation (can be translated to HTML using XSLT/ create web site
using comments/ convert to CHM)
C# has neater code (clarity of code)
5. How this is more advantageous then other languages as well when ur targeting
6. What r the data types in C# and explain in detail
7. How many types of access modifiers r there in C# and explain internal
8. Diff b/w ASP and ASP.NET (Only this question came from list)
9. Explain any 3 ASP.NET features u know in ASP.NET which u have used in project
9. What is Attribute Programming? What are attributes? Where are they used?
1. What are the Database related classes available in .Net?
28
.NET Faq Naresh Kumar Nelluri
2. 11.What is the diff. bet DataReader & DataSet?
3. 12.how do you connect to database in ASp.net and in ASP?
4. 13.what is the difference between recordset and dataset?
5. 14.what are the new object introduced in ado.net that are nor there in ADO?
29
.NET Faq Naresh Kumar Nelluri
Located on oleauto.h header file for 32 bit system and Dispatch.h on 16- bit and Machintosh
system.
41. 50.what is the diffrence between activex exe and activex dll?
42. 51.how will you choose between activex exe and activex dll?
43. 52.OLE
44. 53.ActiveX.exe example.
Late binding uses CreateObject to create and instance of the application object, which you can
then control. For example, to create a new instance of Excel using late binding:
On the other hand, to manipulate an existing instance of Excel (if Excel is already open) you would
use GetObject (regardless whether you're using early or late binding):
To use early binding, you first need to set a reference in your project to the application you want
to manipulate. In the VB Editor of any Office application, or in VB itself, you do this by selecting
Tools + References, and selecting the application you want from the list (e.g. “Microsoft Excel 8.0
Object Library”).
30
.NET Faq Naresh Kumar Nelluri
Dim oXL As Excel.Application
Set oXL = New Excel.Application
In either case, incidentally, you can first try to get an existing instance of Excel, and if that returns
an error, you can create a new instance in your error handler.
1. Your code will run considerably faster, because it can all be compiled up
front. With late binding, the code relating to an application you
declared as an object has to, in effect, be compiled as it runs.
2. Because your code can all be compiled up front, debugging is far easier
– select Debug + Compile, and the compiler will be able to spot syntax
errors which would have been missed had you used late binding.
3. You have full access in your project to intellisense (type a keyword and
a dot to get a popup list of properties and methods supported by that
keyword, select one to insert it; type a keyword and press F1 to launch
the Help topic on that keyword).
4. You have full access to the application's object model via the Object
Browser and VBA Help.
With objWord
.Visible = True
.Activate
.WindowState = wdWindowStateMaximize
.Documents.Open ("c:\temp\temp.doc")
End With
.WindowState =
you'll get a pop-up list of the supported constants, and can simply pick
“wdWindowStateMaximize” from the list.
.WindowState = 1
All this makes programming using early binding immeasurably easier than using late binding.
31
.NET Faq Naresh Kumar Nelluri
Advantages of Late Binding
1. The main advantage is that code which uses late binding is more certain
to be version-independent
But as they famously say, YMMV. Problems have been found in certain
circumstances. For instance, if you run a Word 97 project containing a
reference to the Excel 8.0 object library on a machine with Office 2000
installed, it will run OK, but you may get the occasional “cannot open
macro storage” error unless you save the project in Word 2000. If you
do save it in Word 2000, the reference will change to the Excel 9.0
object library. So if you use early binding and support a mixed
environment, it may be safest to create separate Word 97 and Word
2000 versions of your addins, despite the maintenance overhead.
2. The more references your project contains, the larger the file size and
the longer it takes to compile.
Summary
Personally, as someone who finds programming difficult at the best of times, I would never dream
of using late binding – why make life harder for yourself than it has to be? But some programming
geniuses prefer to use late binding, because of the peace of mind it gives them regarding version
independence – or maybe some of them just enjoy the challenge! <g> But you pays your money
and makes your choice ...
To those unfortunate souls using programming environments in which you have to use late
binding, all I can say is: Look on the bright side – you could have ended up as an Assembly
language programmer ...
You can author new controls by combining existing controls using class composition. A composite
control renders a user interface that reuses the functionality of existing controls. A composite
control can synthesize properties from the properties of its child controls and handle events raised
by its child controls. It can also expose custom properties and events.
There are two different ways of implementing OLE Automation: VTBL (virtual method table,
pronounced V-Table) binding, and the IDispatch (pronounced EYE-Dispatch) interface. Using VTBL
binding is similar to programming the speed dialer on your phone. You look up the number once
and program it into the phone. Once you verify that it's valid, a single button dials the number. All
the work of looking up the phone number is handled long before you use the phone number. Using
the IDispatch interface is similar to looking up the phone number in a phone book before each call,
and then dialing the phone. Both will get the intended results, but the speed dialer is much more
32
.NET Faq Naresh Kumar Nelluri
efficient when you need to make the call. However, looking up the number each time verifies its
correctness.
A VTBL is a data structure containing the addresses (pointers) for the methods and properties of
each object in an Automation server. Using the VTBL is generally known as early binding in VBA.
Frequently, early binding requires type information provided in the form of a type library. This type
information allows VBA to perform compile-time syntax and type checking. At run time, this type of
binding is faster, as the entry points for the Automation server are already known and the data
types and syntax have already been verified.
Using the IDispatch interface is a way to call member functions within an object without knowing
the exact location of their entries in the VTBL. An IDispatch implementation is frequently referred
to as late binding. With IDispatch, VBA has no preexisting information about the server it will be
calling. It assumes during its compile phase that the code is correct. It then attempts at run time
to execute the code and trap for run-time errors. This is much less elegant and represents a step
backward from the familiar syntax and type checking we have come to expect from VBA. An
IDispatch call also requires both the client and the server to marshal their arguments into a
consistent form that is understood by both. In most cases, this means that arguments are copied
into and out of variants. This not only slows down IDispatch, but it also limits the data types that
can be passed using this technique. In all future discussions VTBL binding will be referred to as
early binding and IDispatch as late binding.
What does this mean to you as a developer using VBA? If possible you should attempt to early bind
when using Automation objects from VBA. Early binding not only increases performance, but you
get syntax and type checking at compile-time. If you can't early bind you must use late binding,
which is slower and doesn't allow you to catch simple errors (such as type mismatches) until run
time.
Early binding should be used whenever possible. However, there are programming situations in
which late binding is preferred. If you are implementing polymorphic code (one call can represent
multiple different objects), then late binding is required. For example, you can create three classes
— widgets, gidgets, and gadgets — all with a Create method. By defining your variable as an
object, you can call the Create method for any of the three classes based on run-time conditions.
When testing this type of late-bound strategy, it's generally best to test a single object, early bind
to get the syntax and type checking, and then switch to late binding after you've tested each
object individually.
Binding in VBA
What does early binding versus late binding look like in VBA? The main difference is in how you
declare your variables. The following code snippet declares an object variable that refers to an
instance of Microsoft Word. This example represents late binding, since we have used the generic
Object data type. VBA doesn't know what type of object it is and will use late binding at run time to
handle it. This is like running to the phone book before dialing the phone.
Dim wrd as Object
In the following code snippet, we declare the same object variable and specifically type it as
Word.Application. This can be done only after we have referenced the Microsoft Word type library
using Tools/References. Since VBA knows about the type of this object, it attempts to use early
binding when dealing with it.
Dim wrd As Word.Application
33
.NET Faq Naresh Kumar Nelluri
How you declare the object variable is the factor that determines whether an object is early or late
bound. How you create the object has no bearing on the type of binding VBA does, but it does have
some performance implications.
To create an object, you can use either the New keyword or the CreateObject method. The
CreateObject method is typically used when you don't know the Program ID (ProgID) of the object
you are going to create until run time. Excel.Application is an example of a ProgID. Typically, a
ProgID is composed of the application name followed by a period and then the class name (for
example, Application.Class). To arrive at the ProgID for a particular object, use this method and
then look at HKEY_CLASSES_ROOT in the registry to verify that you are correct. If you are correct,
the ProgID should show up in this hive as a key. It's often assumed that if you use CreateObject
you are using late binding, but this is not always the case. The declaration of the object variable is
the overriding factor. CreateObject does have a slight performance disadvantage when compared
to New. CreateObject assumes there is no reference to the object it is trying to instantiate and
loads all the type information from the registry. This process is slower than using the type
information available in a type library.
The New keyword has two syntaxes. The following example declares and instantiates the object in
separate lines:
Dim wrd As Word.Application
Set wrd = New Word.Application
This is the recommended syntax. The following example shows how New can be used to declare
and instantiate an object at the same time:
Dim wrd As New Word.Application
This ensures that wrd always contains a valid instance of Word.Application. You don't have to worry
about checking to see if wrd has been initialized yet. But there is a minor penalty for this, since the
VBA compiler adds some overhead to be sure the object was loaded. This is transparent to you, but
your compiled code will be slightly larger compared with the previous syntax.
CreateObject can also be used, and it retrieves the type information for Word.Application from the
referenced type library. The results of the following are identical with but slightly slower than using
the similar construct with the New keyword:
Dim wrd as Word.Application
Set wrd = CreateObject("Word.Application")
New is the recommended method for instantiating objects if you have access to the object's type
library.
Early binding: associating with every variable its abstract data type -- enables type checking
Late binding: attributes’ data types are not known until run time. Polymorphism allows to select the
implementation at run-time.
The main advantage of late binding is that programs look simpler, the disadvantage is that many
type errors are not caught until run-time (if at all).
OLE Automation objects are instantiated in two different manners: in-process and cross-process.
An in-process Automation object is loaded as a DLL into the process space (the memory of the
application) of the controller. This has a distinct performance advantage, since the controller and
object are in the same process space and direct function calls may be made between them.
However, there are some drawbacks. When loading servers in-process, each controller must load
its own copy of the object. There is no sharing of objects between processes. When an object is in-
34
.NET Faq Naresh Kumar Nelluri
process, a bug in the object can bring down both the controller and the object. Despite the pitfalls,
in-process object communication is fastest and is typically the method you want to use.
Cross-process objects load in separate process spaces and use remote procedure calls (RPC) to
communicate. There is a certain amount of overhead involved in cross-process RPC, and as a result
this method is typically slower than the in-process implementation. It does, however, have the
advantage of partitioning the processes, and it allows a single object to be shared by multiple
controllers.
The Capability Maturity Model for Software describes the principles and practices underlying
software process maturity and is intended to help software organizations improve the maturity of
their software processes in terms of an evolutionary path from ad hoc, chaotic processes to
mature, disciplined software processes. The CMM is organized into five maturity levels:
1) Initial. The software process is characterized as ad hoc, and occasionally even chaotic. Few
processes are defined, and success depends on individual effort and heroics.
2) Repeatable. Basic project management processes are established to track cost, schedule, and
functionality. The necessary process discipline is in place to repeat earlier successes on projects
with similar applications.
3) Defined. The software process for both management and engineering activities is documented,
standardized, and integrated into a standard software process for the organization. All projects use
an approved, tailored version of the organization's standard software process for developing and
maintaining software.
4) Managed. Detailed measures of the software process and product quality are collected. Both
the software process and products are quantitatively understood and controlled.
Except for Level 1, each maturity level is decomposed into several key process areas that indicate
the areas an organization should focus on to improve its software process.
The key process areas at Level 2 focus on the software project's concerns related to establishing
basic project management controls. They are Requirements Management, Software Project
Planning, Software Project Tracking and Oversight, Software Subcontract Management, Software
Quality Assurance, and Software Configuration Management.
The key process areas at Level 3 address both project and organizational issues, as the
organization establishes an infrastructure that institutionalizes effective software engineering and
management processes across all projects. They are Organization Process Focus, Organization
Process Definition, Training Program, Integrated Software Management, Software Product
Engineering, Intergroup Coordination, and Peer Reviews.
The key process areas at Level 4 focus on establishing a quantitative understanding of both the
software process and the software work products being built. They are Quantitative Process
Management and Software Quality Management.
The key process areas at Level 5 cover the issues that both the organization and the projects must
address to implement continual, measurable software process improvement. They are Defect
Prevention, Technology Change Management, and Process Change Management.
ASP
28.How do you make ASP applications secure?
35
.NET Faq Naresh Kumar Nelluri
a. http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnproasp2/html/
implementingaspsecurity.asp
31.How can you pass values between two pages in ASP?how will you do the same in
ASP.net?
a. Query String
b. Post/Hidden members
c. Session Variables
VB
43.What is late binding and early binding?
There are two different ways of implementing OLE Automation: VTBL (virtual method table,
pronounced V-Table) binding, and the IDispatch (pronounced EYE-Dispatch) interface.
36
.NET Faq Naresh Kumar Nelluri
Early Binding: VTBL Binding
A VTBL is a data structure containing the addresses (pointers) for the methods and
properties of each object in an Automation server. Using the VTBL is generally known as
early binding in VBA. Frequently, early binding requires type information provided in the
form of a type library. This type information allows VBA to perform compile-time syntax and
type checking. At run time, this type of binding is faster, as the entry points for the
Automation server are already known and the data types and syntax have already been
verified.
Using the IDispatch interface is a way to call member functions within an object without
knowing the exact location of their entries in the VTBL. An IDispatch implementation is
frequently referred to as late binding. With IDispatch, VBA has no preexisting information
about the server it will be calling. It assumes during its compile phase that the code is
correct. It then attempts at run time to execute the code and trap for run-time errors. This
is much less elegant and represents a step backward from the familiar syntax and type
checking we have come to expect from VBA. An IDispatch call also requires both the client
and the server to marshal their arguments into a consistent form that is understood by
both. In most cases, this means that arguments are copied into and out of variants. This not
only slows down IDispatch, but it also limits the data types that can be passed using this
technique. In all future discussions VTBL binding will be referred to as early binding and
IDispatch as late binding.
Early binding not only increases performance, but you get syntax and type checking at
compile-time. If you can't early bind you must use late binding, which is slower and doesn't
allow you to catch simple errors (such as type mismatches) until run time.
Early binding should be used whenever possible. However, there are programming
situations in which late binding is preferred. If you are implementing polymorphic code (one
call can represent multiple different objects), then late binding is required. For example, you
can create three classes — widgets, gidgets, and gadgets — all with a Create method. By
defining your variable as an object, you can call the Create method for any of the three
classes based on run-time conditions.
When testing this type of late-bound strategy, it's generally best to test a single object,
early bind to get the syntax and type checking, and then switch to late binding after you've
tested each object individually.
44.How do you handle errors in VB?
a. On Error Resume Next
b. On Error GoTo
c. On Error GoTo 0
47.What are the various ways in which you instantiate an object in VB?
To create an object, you can use either the New keyword or the CreateObject method. The
CreateObject method is typically used when you don't know the Program ID (ProgID) of the
object you are going to create until run time. Excel.Application is an example of a ProgID.
Typically, a ProgID is composed of the application name followed by a period and then the
37
.NET Faq Naresh Kumar Nelluri
class name (for example, Application.Class). To arrive at the ProgID for a particular object,
use this method and then look at HKEY_CLASSES_ROOT in the registry to verify that you
are correct. If you are correct, the ProgID should show up in this hive as a key. It's often
assumed that if you use CreateObject you are using late binding, but this is not always the
case. The declaration of the object variable is the overriding factor. CreateObject does have
a slight performance disadvantage when compared to New. CreateObject assumes there is
no reference to the object it is trying to instantiate and loads all the type information from
the registry. This process is slower than using the type information available in a type
library.
The New keyword has two syntaxes. The following example declares and instantiates the
object in separate lines:
Dim wrd As Word.Application
Set wrd = New Word.Application
This is the recommended syntax. The following example shows how New can be used to
declare and instantiate an object at the same time:
Dim wrd As New Word.Application
This ensures that wrd always contains a valid instance of Word.Application. You don't have
to worry about checking to see if wrd has been initialized yet. But there is a minor penalty
for this, since the VBA compiler adds some overhead to be sure the object was loaded. This
is transparent to you, but your compiled code will be slightly larger compared with the
previous syntax.
CreateObject can also be used, and it retrieves the type information for Word.Application
from the referenced type library. The results of the following are identical with but slightly
slower than using the similar construct with the New keyword:
Dim wrd as Word.Application
Set wrd = CreateObject("Word.Application")
New is the recommended method for instantiating objects if you have access to the object's
type library.
48.What are the threading models that you can choose in VB? Which one will you
recommend and why?
Apartment Threading model.
Because in this model the COM object is instantiated only on the first call to it.
49.Can you store a VB object in ASP session variable? Is it recommended? Why not?
Code that places objects in session or even application scope on the basis that it is more
efficient to only create the object once and that this has the advantage of persisting not
only data but also ‘business logic’ as well. Whilst it is true that the creation of an object can
be time consuming and the idea of persisted ‘business logic’ is tempting, placing the VB
object in session scope has a peculiar side effect – it can seriously impair the performance
of the application.
To understand this problem we have to lift the lid and examine how ASP actually works. The
core of the ASP runtime executes in an MTA process which enables it to do many things at
once, however requests for ASP pages are placed into a queue which then distributes the
requests to a number of STA ‘worker’ threads each of which can only deal with one request
at a time. ASP uses up to 25 STA ‘worker’ threads at any one time (per processor). The
38
.NET Faq Naresh Kumar Nelluri
problem with the VB components is that they exhibit ‘thread affinity’. Once a object has
been created in session scope by an ASP script that was processed by STA worker number
6, that session is pinned to worker number 6 for it’s life cycle. This means that when the
client places a subsequent request it can only be processed by worker thread number 6,
even if all the rest of the workers are idle the request will stay in the queue until worker
thread 6 becomes free. You can see how detrimental this side effect can be with session
scope objects but placing VB objects
application scope is even worse as it will pin all requests for your application to one single
worker thread effectively only using one 25th of your servers capability.
The ActiveX Components you create contain a default interface (for example, CName_D
where CName is the ClassName for the ActiveX Component) that contains all of the
methods and properties you have created. If your Class raises events, you also have an
additional interface called IConnectionPointContainer. When you build an ActiveX Control or
Server, these Interfaces are given a unique identifier. If you modify your control or server,
these interfaces may change. Any applications using an older version of your component
may fail at this point. To ensure that your new and old interfaces will work with all
applications, you need to set the appropriate Compatibility setting.
You can set the Project's Compatibility in the Project\Properties dialog box, under the
Component tab.
With this setting, no compatibility is enforced. Visual Basic creates new Interface IDs and
Class IDs every time you build or compile your project. Each version built can only be used
with applications created to work with that specific build of the component.
Project Compatibility
With this setting, you can make your project compatible to a specific component project.
While new type library information is generated, the type library identifier is maintained so
that test projects can still refer to the component project. This setting is for maintaining
compatibility during testing. Therefore, once the component is released, it behaves the
same as the No Compatibility setting.
Binary Compatibility
When you compile your project, Visual Basic only creates new Class and Interface IDs when
necessary. It preserves the class and interface IDs from the previous version(s) so that
programs compiled using an earlier version will continue to work. If you are making a
change that will result in an incompatible version, Visual Basic will warn you. If you want to
maintain compatibility with older, released versions of an ActiveX component, this is the
setting you need to use.
39
.NET Faq Naresh Kumar Nelluri
51.What is the necessity for Resume Next?
a. To continue executing the code even a runtime error occurs.
COM
12.What is the difference between COM and DCOM?
a. DCOM is used to work with components located in different machines.
b. COM is a Specification
c. DCOM is a Model/Implementation
15.What is IDispatch?
a. Ref Attachment IDispatch
An in-process component, such as a .dll or .ocx file, runs in the same process as the client.
It provides the fastest way of accessing objects, because property and method calls don’t
have to be marshaled across process boundaries. However, an in-process component must
use the client’s thread of execution.
In-process components execute in the process space of the calling application; out-of-
process components execute in their own distinct process space. When an application
(any .exe file) starts, Windows creates a process space in which the application runs. This
process space gets its own memory address space that's inaccessible to other processes.
When an application instantiates an object from an in-process component (DLL, OLE custom
control—OCX), code executes in the calling application. This calling application is called the
client. The in-process component can share the memory address space of the client
application.
17.How will you choose between activex exe and activex dll?
18.ActiveX.exe example.
a. DLLHHost.exe
XML
5. What is xml? Diffrences between xml and html?
XML is a markup language for documents containing structured information.
Structured information contains both content (words, pictures, etc.) and some indication of
what role that content plays (for example, content in a section heading has a different
meaning from content in a footnote, which means something different than content in a
figure caption or content in a database table, etc.). Almost all documents have some
structure.
40
.NET Faq Naresh Kumar Nelluri
A markup language is a mechanism to identify structures in a document. The XML
specification defines a standard way to add markup to documents.
XML is to data as what HTML is to text. One thing to note is that XML is NOT a replacement
for HTML.
XML HTML
Is used for storing and exchanging data Is used for formatting data for display
Is used to describe data Is used to display data
Users define their own tags Users have to utilize the pre-defined tags
White space is preserved White space is not preserved
While there are differences between XML and HTML, in syntax they are very similar,
although XML demands that the user pay attention to the little details. Next I will explain
some of the new rules that XML uses that make its use slightly different from that of HTML.
6. What xsl? Where will you use this technology..give an example?
XSL is a language for expressing style sheets. An XSL style sheet is, like with CSS, a file
that describes how to display an XML document of a given type. XSL shares the functionality
and is compatible with CSS2 (although it uses a different syntax). It also adds:
A transformation language for XML documents: XSLT. Originally intended to perform
complex styling operations, like the generation of tables of contents and indexes, it is
now used as a general purpose XML processing language. XSLT is thus widely used for
purposes other than XSL, like generating HTML web pages from XML data.
Advanced styling features, expressed by an XML document type which defines a set
of elements called Formatting Objects, and attributes (in part borrowed from CSS2
properties and adding more complex ones.
http://www.w3.org/Style/XSL/WhatIsXSL.html
ASP
41
.NET Faq Naresh Kumar Nelluri
Request
Response
Server
Session
Top of Form
The Application object shares, stores, and retrieves information in
response to requests from users to the application.
COLLECTION PROPERTIES
Contents Object
A collection of all of the items which have been created and added to the
Application object during client sessions through script commands, such
as the Server.CreateObject, rather than by using the HTML <OBJECT>
tag.
StaticObjects Object
A collection of all of the items which have been created and added to the
Application object during client sessions by using the HTML <OBJECT>
tag, rather than using script commands.
METHODS
Lock Method
The Lock method prevents all other users from making changes in the
Application object.
Unlock Method
The Unlock method allows any user to have access to any of the
Application object properties in order to make changes.
EVENTS
OnEnd Event
The OnEnd event occurs when the Application quits. This should not
occur unless all user sessions are over. The signal of this event will run a
handler script in the Global.asa file, if the script exist.
OnStart Event
The OnStart event occurs before the start of any new session by a user
(i.e., before the Application object is first referenced). The signal of this
event will run a handler script in the Global.asa file, if the script exist.
ASPError
The ASPError object is used to obtain detailed information on an error condition. This information,
provided by the nine read-only properties of ASPError, can only be accessed by using the
Server.GetLastError method.
42
.NET Faq Naresh Kumar Nelluri
PROPERTIES
ASPCode Property
The ASPCode property returns the error code generated by IIS.
ASPDescription Property
The ASPDescription property returns a string that provides more detailed description of the error
as compared to the short description returned by the Description property. (Not available for all
errors.)
Category Property
The Category property returns a string indicating if the error was generated by IIS, an object, or a
scripting language.
Column Property
The Column property returns a long integer defining the column position inside the ASP file where
the error occurred.
Description Property
The Description property returns a string that is a short description of the error. If you desire a
longer description, use the ASPDescription property.
File Property
The File property returns the name of the ASP (Active Server Page) file in which the error
occurred.
Line Property
The Line property returns an long integer defining the line number inside the ASP file where the
error occurred.
Number Property
The Number property returns a long integer defining the standard COM error code returned by a
COM component.
Source Property
The Source property returns a string with the actual line from the source code where the error
occurred (if available).
ObjectContext object
The ObjectContext object is used to control Active Server Pages transactions which are managed
by the Microsoft Transaction Server (MTS). You may either complete (commit) or abort a
transaction.
The @Transaction directive must be on the first line of the .asp file in order to use this object (see
code examples). The @Transaction directive causes a transaction to run to completetion unless
an abort occurs.
METHODS
SetAbort Method
The SetAbort method declares that a transaction has not been completed and resources should
not be updated.
SetComplete Method
The SetComplete method declares that the transaction has been completed and resources can be
updated.
43
.NET Faq Naresh Kumar Nelluri
EVENTS
OnTransactionAbort Event
The OnTransactionAbort event occurs when a transaction has been aborted for some kind of
processing error. The signal of this event will run a handler script in the same file, if it exist.
OnTransactionCommit Event
The OnTransactionCommit event occurs when a transaction has been successfully completed.
The signal of this event will run a handler script in the same file, if it exist.
Request object
The Request object provides access to all of the information that is passed in a request from
the browser to the server. This information is stored among five types of Request collections.
A collection is similar to a data structure or array. Individual items in the collection are
accessed via a unique key assigned to that item.
All variables can be accessed directly by calling Request(variable) without the collection
name. In this case, the Web server searches the collections in the following order:
QueryString, Form, Cookies, ClientCertificate, then ServerVariables.
PROPERTY
TotalBytes Property
The TotalBytes property specifies the total number of bytes sent in the body of the HTTP
request.
COLLECTION PROPERTIES
METHOD
44
.NET Faq Naresh Kumar Nelluri
Response object
The Response object sends information back to the user (browser).
PROPERTIES
CacheControl Property
The CacheControl property determines whether a proxy server can cache the Active Server Page.
Charset Property
The Charset property appends the name of the character set being used to the content-type
header contained in the response object.
ContentType Property
The ContentType property specifies the HTTP content type/subtype for the response header.
Expires Property
The Expires property specifies the length of time in minutes until a cached page on the browser
expires.
ExpiresAbsolute Property
The ExpiresAbsolute property specifies a date and time when a cached page on the browser will
expire.
PICS Property
The PICS property specifies the value of a PICS rating label for a document or a site.
Status Property
The Status property specifies the value of the status line returned by the server.
COLLECTION PROPERTIES
METHODS
Clear Method
45
.NET Faq Naresh Kumar Nelluri
The Clear method clears (erases) any buffered HTML output.
End Method
The End method causes the web server to stop processing the script and to return the current
results without processing the rest of the file.
Flush Method
The Flush method sends the contents of the buffer.
Server object
The Server object provides access to the utility functions of the server.
PROPERTY
ScriptTimeout Property
The ScriptTimeout property is the amount of runtime in seconds for a script before it terminates.
METHODS
Session Object
Session object is assigned to the user and it is used to store, share, and retrieve information
concerning the user session. By default, the Session object is destroyed after a session has
46
.NET Faq Naresh Kumar Nelluri
been idle for twenty minutes.
PROPERTIES
CodePage Property
The CodePage property specifies the server codepage that will be used to display dynamic
content.
LCID Property
The LCID property specifies the location identifier that will be used to display dynamic content.
SessionID Property
The SessionID property returns the unique identifier for a user session.
Timeout Property
The Timeout property is the length of time in minutes before an idle session is terminated.
COLLECTION PROPERTIES
METHODS
Abandon Method
The Abandon method terminates a user session, destroys all data and objects in the current
Session object, and releases its resources.
EVENTS
OnEnd Event
The OnEnd event occurs when the Session quits. The signal of this event will run a handler
script in the Global.asa file, if the script exists.
OnStart Event
The OnStart event occurs before the start of any new Session by a user. The signal of this
event will run a handler script in the Global.asa file, if the script exists.
47
.NET Faq Naresh Kumar Nelluri
VBScript has only one data type and it's called a Variant. A Variant is a special kind of
data type that can contain different kinds of information, depending on how it's used.
Because Variant is the only data type in VBScript, it's also the data type returned by all
functions in VBScript.
At its simplest, a Variant can contain either numeric or string information. A Variant behaves as a
number when you're using it in a numeric context and as a string when you use it in a string
context. That is, if you're working with data that looks like numbers, VBScript assumes that it is
numbers and does the thing that is most appropriate for numbers. Of course, you can always make
numbers behave as strings, by enclosing them in quotation marks. Similarly, if you're working with
data that can only be string data, VBScript treats it as string data.
Beyond the simple numeric or string classifications, a Variant can make further distinctions about
the specific nature of numeric information. For example, you can have numeric information that
represents a date or a time. When used with other date or time data, the result is always
expressed as a date or a time. Of course, you can also have a rich variety of numeric information
ranging in size from Boolean values to huge floating-point numbers. These different categories of
information that can be contained in a Variant are called subtypes. Most of the time, you can just
put the kind of data you want in a Variant and it behaves in a way that is most appropriate for the
data it contains.
The following table shows the various subtypes of data that a Variant can contain.
Subtype Description
Empty Variant is uninitialized. Value is either 0 for numeric variables
or a zero-length string ("") for string variables.
Null Variant intentionally contains no valid data.
Boolean Contains either True or False.
Byte Contains integer in the range 0 to 255.
Integer Contains integer in the range -32,768 to 32,767.
Currency -922,337,203,685,477.5808 to 922,337,203,685,477.5807.
Long Contains integer in the range -2,147,483,648 to
2,147,483,647.
Single Contains a single-precision, floating-point number in the
range -3.402823E38 to -1.401298E-45 for negative values;
1.401298E-45 to 3.402823E38 for positive values.
Double Contains a double-precision, floating-point number in the
range -1.79769313486232E308 to -4.94065645841247E-324
for negative values; 4.94065645841247E-324 to
1.79769313486232E308 for positive values.
Date Contains a number that represents a date between January 1,
(Time) 100 to December 31, 9999.
String Contains a variable-length string that can be up to
approximately 2 billion characters in length.
Object Contains an object.
Error Contains an error number.
If you want to convert from one subtype to another, there is a rich set of conversion functions you
can use. In addition, the VarType function returns information about how your data is stored
within a Variant.
1. A language is strongly typed if type annotations are associated with variable names, rather
than with values. If types are attached to values, it is weakly typed.
48
.NET Faq Naresh Kumar Nelluri
2. A language is strongly typed if it contains compile-time checks for type constraint violations.
If checking is deferred to run time, it is weakly typed.
3. A language is strongly typed if there are compile-time or run-time checks for type constraint
violations. If no checking is done, it is weakly typed.
4. A language is strongly typed if conversions between different types are forbidden. If such
conversions are allowed, it is weakly typed.
6. A language is strongly typed if there is no language-level way to disable or evade the type
system. If there are casts or other type-evasive mechanisms, it is weakly typed.
7. A language is strongly typed if it has a complex, fine-grained type system with compound
types. If it has only a few types, or only scalar types, it is weakly typed.
8. A language is strongly typed if the type of its data objects is fixed and does not vary over
the lifetime of the object. If the type of a datum can change, the language is weakly typed.
VbScript is not strongly typed but VB is .
* Suppose you have an application for credit card validation. What steps will you take to
restrict unauthorized users from using the application
SSL
* Write the code snippet for fetching data from a table and populating in a list box
control of an asp page.
Open ADO connection and go thru the table and keep in a variable and assign to the listbox
* Say you are designing a product page – the products list is constant? How will you
design this page? (will you go to db each time to retrieve the list of products for each
user?)
Session
49
.NET Faq Naresh Kumar Nelluri
Are you storing Visual Basic objects in Session or Application scope?
Visual Basic® and other Single-Threaded Apartment (STA) objects should be used only at page
scope. Storing STAs in a Session variable locks the object down to the thread that created the
object, defeating the purpose of a thread pool. Storing an STA in Application scope serializes
access for all users.
The Scripting.Dictionary is Apartment threaded and should be used only at page scope, or your
application will suffer serious serialization issues . This limitation usually raises the question of what
dictionaries can be used at Session or Application scope. Options are somewhat limited, but include
the Commerce Dictionary and the LookupTable Object.
Script is interpreted line by line, so eliminating redundant script or creating more efficient script
can improve performance. If you have hundreds of lines of ASP script in a single page, perhaps you
can better partition your user, business, and data services.
There are no hard and fast rules for include-file sizes, but knowing how includes work can help you
gauge whether you are using them efficiently. When ASP processes includes, it reads the entire file
into memory. Because ASP will cache the entire expanded code (your page + the include), not just
the functions you call, you may end up with large, inefficient namespaces that ASP must search
when calling methods or looking up variables. Note that this process occurs for each page that uses
the include. A good guide is to create fine-grained includes, so that you can be more selective
about which pages will include them
Global variables increase the namespace used by ASP to retrieve values from memory. Variables
declared within subroutines or functions are faster.
Keep blocks of ASP server-side script together, rather than switching back and forth between
server-side and client-side code. This switching usually happens when concatenating HTML with
simple values from ASP, as when you are writing out an HTML table:
Buffering is on by default in Windows 2000, but may be off if you've upgraded from Internet
Information Server (IIS) 4.0.
When buffering is on, ASP will wait until processing is complete before sending down the response,
reducing network roundtrips and server-processing delays. When buffering is off, ASP waits for TCP
acknowledgements from clients, which can really hurt performance, particularly over slow
connections.
Note that while buffering may improve throughput, it may reduce perceived performance. If
perceived performance is an issue, you can turn off buffering with Response.Buffer = False or
you can call Response.Flush.
50
.NET Faq Naresh Kumar Nelluri
Are you using Session state?
ASP Sessions are a convenient facility, but they limit scalability. Sessions limit the scalability of a
single box because they consume resources for each user. While Session size is largely determined
by what you stuff into the Session variable, the real cost is resource contention. Sessions also limit
your application's ability to scale out across multiple machines, because each Session is Web-
server specific.
If the application doesn't rely on Sessions, disable Session state for the Web or virtual directory
through the ISM (Internet Services Manager). Disabling Session state allows ASP to skip an
extensive amount of source code, reducing overhead
Caching is one of the most difficult aspects of Web application development, because it threatens
the scalability of your application. Determining what to cache is based on data volatility and scope.
Data that is static or used application-wide can be a good candidate for caching. Data that changes
frequently or is user-specific would not be a good candidate.
Determining where in your application you should cache your data is based on your application
goals, and you need to know the trade-offs. For example, caching an ActiveX® Data Objects (ADO)
Recordset offers flexibility, because you can still grab an array or save the recordset as XML.
However, if your application will be rendering the same HTML repeatedly, such as to display a list
box of countries, you might cache the HTML string in Application scope, rather than just the data
It is generally more expensive to redimension arrays than it is to grab more than you need up
front. Redimensioning arrays requires Visual Basic Scripting Edition (VBScript) to allocate space for
the new array -- and, if you've used the Preserve modifier to preserve the contents of the array, to
copy the data from the old array into the new. This means that not only are you spending extra
processor cycles to redimension the array, but also that the process initially requires twice as much
memory for the copy. However, if you allocate more space than you need initially (you need only
five elements initially, but allocate space for 128), then adding more data to the array requires
VBScript to insert only the new values into the existing array.
Multiple languages on a given page mean multiple script engines for that page. Script engines use
Thread Local Storage (TLS), so multiple threads cannot use an instance of a script engine
concurrently. Therefore, five simultaneous requests to the same page will cause ASP to instantiate
five script engines. More engines means more overhead, so you may be able to gain some
performance by limiting your number of languages used on a given page.
51
.NET Faq Naresh Kumar Nelluri
Are you using Server.MapPath unnecessarily?
When you request Server.MapPath, you are generating an additional request for the server to
process. To improve performance, replace Server.MapPath with a fully qualified path when
deploying your Web site.
Use regular expressions in validation routines, in formatting functions, and instead of looping
through strings
VBScript 5.0 provides the With statement. The With statement allows you to execute a series of
statements on a specific object without requalifying the name of the object
Stripping out empty Session events reduces the amount of source code that ASP must traverse,
and improves performance
Component Performance
Storing references to objects in ASP's Session or Application scope will cause many performance
and scalability issues if those objects aren't designed to be shared across threads or activities. Only
agile components -- or, in Windows 2000, components marked Neutral -- can be referenced in
Session or Application variables with direct access by client threads
If you need to cache data that is read frequently and seldom updated in the middle-tier, use SQL
Server rather than a roll-your-own solution. SQL Server provides high-performance middle-tier
caching
Use fixed-length strings in Visual Basic for string concatenation. Don't just keep adding to a string,
or you'll reallocate it multiple times -- and reallocation is expensive.
Transactions provide a service -- and that service can add a performance hit. Evaluate whether
methods actually need transactions. For example, if you're grabbing a recordset to hand off to a
browser client for reading data, you don't need a transaction. By factoring out operations that read
data into separate components from operations that perform updates, you have more flexibility in
marking your components for transactions.
Calling SetComplete and SetAbort in each method of your Microsoft Transaction Server (MTS)
components will release resources earlier, and will ensure that a component does not live outside
the scope of its transaction. In Windows 2000, COM+ provides the setting 'Automatically deactivate
this object when this method returns,' which performs the equivalent code. You can enable this
setting on a per-method basis in the Component Services console.
52
.NET Faq Naresh Kumar Nelluri
Are you crossing processes effectively?
Minimizing marshaling overhead and reducing network calls are keys to improving performance of
distributed applications. Use early binding in your components to minimize expensive network
round trips by eliminating the extra call to GetIdsOfNames that late binding incurs. You can
further reduce network trips by bundling your parameters into arguments for method calls, instead
of setting a bunch of properties individually. Rather than pass parameters ByRef, pass ByVal
where you can to minimize marshaling overhead.
Indexes provide immediate impact on your application's performance. Poor indexes will slow your
application to a crawl, while good indexes will help optimize your application's performance.
Using stored procedures prevents your database from having to recompile your SQL statements
repeatedly. Use stored procedures or parameterized SQL strings.
Check your SELECT statements to ensure that you're returning only the required columns and only
the necessary rows. If you have queries that can potentially return a lot of records, consider paging
through your recordsets.
This defeats the purpose of connection pooling and creates resource contention. Create connection
at page scope or within the functions that need them, and set the connections to nothing to free
the connection back to the pool.
Recordsets need to be closed if they are going to be reused (but reusing recordsets is
discouraged). Closing Connection variables as soon as you can releases them back to the pool, so
that they can be pooled for reuse. It is always good practice to explicitly close your object
variables.
Create new Recordset and Command variables rather than reusing existing ones. This won't
necessarily improve your application's performance but it will make your application more reliable
and easier to maintain.
Disconnecting recordsets frees the Connection object back to the pool, allowing the Connection to
be closed and reused sooner.
Are you using the right cursor and lock-type for the job?
Use "Firehose" (forward-only, read-only) cursors when you need to make a single pass through the
data. Firehose cursors, the default in ADO, provide the fastest performance and have the least
amount of overhead.
53
.NET Faq Naresh Kumar Nelluri
In general, DSN-less connections are faster than System DSNs (data source names), which are
faster than File DSNs.
IIS Settings
Check the ISM. If ASP debugging is enabled, the application is locked down to a single thread of
execution
Secure Sockets Layer (SSL) is expensive in terms of bandwidth and CPU usage. If you're using
SSL, it's because of security needs. Your best bet is to restrict SSL usage to where you need it, and
keep the pages simple.
VB & COM
Late binding uses CreateObject to create and instance of the application object, which you can
then control. For example, to create a new instance of Excel using late binding:
On the other hand, to manipulate an existing instance of Excel (if Excel is already open) you would
use GetObject (regardless whether you're using early or late binding):
To use early binding, you first need to set a reference in your project to the application you want
to manipulate. In the VB Editor of any Office application, or in VB itself, you do this by selecting
Tools + References, and selecting the application you want from the list (e.g. “Microsoft Excel 8.0
Object Library”).
54
.NET Faq Naresh Kumar Nelluri
To create a new instance of Excel using early binding:
In either case, incidentally, you can first try to get an existing instance of Excel, and if that returns
an error, you can create a new instance in your error handler.
* What are the various ways in which you instantiate an object in VB?
CreateObject, GetObject, New,
* What are the threading models that you can choose in VB? Which one will you
recommend and why?
* Can you store a VB object in ASP session variable? Is it recommended? Why not?
Storing references to objects in ASP's Session or Application scope will cause many performance
and scalability issues if those objects aren't designed to be shared across threads or activities. Only
agile components -- or, in Windows 2000, components marked Neutral -- can be referenced in
Session or Application variables with direct access by client threads
When an ActiveX component is compiled, there are three possible project compatibility settings:
No Compatibility
Project Compatibility
Binary Compatibility
No Compatibility
With this setting, new class ID’s, new interface ID’s and a new type library ID will be generated by
VB each time the ActiveX component project is compiled. This will cause any compiled client
components to fail (with error 429!) and report a missing reference to the 'VB ActiveX Test
Component' when a client project is loaded in the VB IDE.
TIP: Use this setting to compile the initial release of a component to other developers.
Project Compatibility
With this setting, VB will generate new interface ID’s for classes whose interfaces have changed,
but will not change the class ID’s or the type library ID. This will still cause any compiled client
components to fail (with error 429!) but will not report a missing reference to the 'VB ActiveX Test
Component' when a client project is loaded in the VB IDE. Recompilation of client components will
restore them to working order again.
TIP: Use this setting during the initial development and testing of a component within the IDE
and before the component is released to other developers.
55
.NET Faq Naresh Kumar Nelluri
Binary Compatibility
VB makes it possible to extend an existing class or interface by adding new methods and properties
etc. and yet still retain binary compatibility. It can do this, because it silently creates a new
interface ID for the extended interface and adds registration code to register the original interface
ID but with a new Forward key containing the value of this new interface ID. COM will then
substitute calls having the old ID with the new ID and hence applications built against the old
interface will continue to work (assuming the inner workings of the component remain backward
compatible!).
With this setting, VB will not change any of the existing class, interface or type library ID’s,
however in order that it can do so, VB requires the project to specify an existing compiled version
that it can compare against to ensure that existing interfaces have not been broken.
TIP: Use this setting following the release of a component to other developers.
Breaking Compatibility
When the need to break compatibility arises, be sure to tackle it head on and make a clean break.
To do so, create a new version of the project with compatibility set to 'No Compatibility'. Next,
change the project 'Name' attribute and compile to a different component name. Taking this
approach ensures that existing applications can continue to work with the old component while new
versions can use the new component.
The first time an ActiveX component is built for release then the 'No Compatibility' setting should
be selected thereby causing new class, interface and type library ID’s to be generated. (Only use
'Project Compatibility' during the initial development of a component within the IDE and before
releasing the component to other developers.)
A copy of the released component should then be placed into a sub-folder (preferably named
'Compat') beneath the project folder and the compatibility setting changed to 'Binary Compatible'
with the compatible image being set to the component in the 'Compat' sub-folder.
The following rules ensure binary compatibility is maintained:
The name of the project cannot change.
The names of any public classes cannot change.
The names of any public methods or properties cannot change.
The number of parameters to any public method cannot change.
The data types of the parameters cannot change.
The calling convention (ByRef, ByVal) of the parameters cannot change.
The names of public enums cannot change.
The order/values of elements in public enums cannot change.
The names of public user-defined types cannot change.
The names and data types of elements in public user-defined types cannot change.
If a public class implements user-defined interfaces then the 'Implements' statement
cannot change.
Whenever the component is amended, always update the component's version information to allow
different versions to be correctly distinguished. You should also update the compatible image in the
'Compat' folder with the latest compiled component binary once the component has been
successfully tested and released to other developers. It is a good habit to do this even when
interfaces remain unchanged.
56
.NET Faq Naresh Kumar Nelluri
Enables the error-handling routine that starts at line specified in the required line argument.
The line argument is any line label or line number. If a run-time error occurs, control branches to
line, making the error handler active. The specified line must be in the same procedure as the On
Error statement; otherwise, a compile-time error occurs.
On Error Resume Next
Specifies that when a run-time error occurs, control goes to the statement immediately
following the statement where the error occurred where execution continues. Use this form rather
than On Error GoTo when accessing objects
* ActiveX.exe example.
Winword.exe, Dllhost.exe
* what is COMInterop?
While late binding to components is still supported, early binding is a better choice for performance
reasons. A utility named the Type Library Importer (TlbImp), included with the .NET Framework
SDK in the file Tlbimp.exe, converts standard COM components in DLL files to equivalent .NET
Framework assemblies by building managed wrappers around the components. The converted
components can be early-bound to managed code for greatly increased performance
Once the COM component is converted to a .NET assembly, you can import it into an ASP.NET page
by placing a directive at the top of the page. For example, the following directive imports the
namespace MyNewNamespace, which was created by the Tlbimp utility:
<%@Import Namespace="MyNewNamespace"%>
57
.NET Faq Naresh Kumar Nelluri
The assembly file generated by Tlbimp.exe must be placed in the ASP.NET application's \bin
directory. The original COM component file must be registered for the directory in which it resides.
When using single-threaded (STA) COM components, such as components developed using Visual
Basic, from an ASP.NET page, you must include the compatibility attribute aspcompat=true in an
<%@ Page > tag on the ASP.NET page. For example:
<%@Page aspcompat=true Language = VB%>
The aspcompat attribute forces the page to execute in STA mode. The runtime throws an
exception if the compatibility tag is omitted and an STA component is referenced on the page. If
you convert the STA component to an assembly using TlbImp, the runtime does not detect that the
component uses the STA model and does not throw an exception, but your application can suffer
from poor performance and possible deadlocks. STA components cannot be used from .NET
Framework code modules (compiled .NET assemblies); they can be used only from ASP.NET pages.
COM is the general term (Component Object Model). It is a general term that represents all
objects that follow this modle.
DCOM is just Distributed COM . It is really just a COM object that may be located on another
machine on a network or even over the internet. The idea is, you dont need the COM object on
your machine to run...you can have it run from another location and still use it.
COM+ really refers to another package that encapsulates COM. COM + provides means of
providing security to your COM objects (only certain people can access them) and allowing them to
participate in transactions with other programs/COM Objects.
The IUnknown interface lets clients get pointers to other interfaces on a given object through the QueryInterface method,
and manage the existence of the object through the IUnknown::AddRef and IUnknown::Release methods. All other
COM interfaces are inherited, directly or indirectly, from IUnknown. Therefore, the three methods in IUnknown are the
first entries in the VTable for every interface.
QueryInterface Returns pointers to supported
interfaces.
AddRef Increments reference count.
Release Decrements reference count.
* What is IDispatch?
Interface that exposes objects, methods and properties to programming tools and applications that support automation
IDispatch Methods Description
GetTypeInfoCount Retrieves the number of type
information interfaces that an
object provides (either 0 or 1).
GetTypeInfo Gets the type information for an
object.
GetIDsOfNames Maps a single member and an
optional set of argument names to
58
.NET Faq Naresh Kumar Nelluri
a corresponding set of integer
DISPIDs.
Invoke Provides access to properties and
methods exposed by an object.
Problem with using Global vars in VB components developed for Web Apps:
http://www.microsoft.com/msj/defaultframe.asp?page=/msj/0598/activex0598.htm&nav=/msj/
0598/newnav.htm
General Threading:
http://www.devarticles.com/art/1/182/2
Glossary of COM/DCOM:
http://www.innovatia.com/software/papers/com.htm
Changes in VB.Net
ASP.NET does not support Visual Basic Scripting Edition (VBScript), but it does support Visual Basic
.NET, which is very similar to VBScript. However, most existing ASP pages that contain VBScript
will still have to be rewritten to some extent to run under ASP.NET.
Specific Visual Basic changes that might affect existing ASP pages containing VBScript include
changes to Visual Basic syntax and changes in the threading model.
The following list describes specific changes in Visual Basic .NET that may require changes to
existing Visual Basic or VBScript applications.
The data type Variant no longer exists. It has been replaced with the type Object. Object
types must be explicitly cast to other primitive data types.
Parentheses are now required around the parameter list in all method calls, even for
methods that do not take parameters. For example:
If Flag = False Then
DisplayMessage()
End If
By default, arguments are passed by value, not by reference as in previous versions of
Visual Basic. If you want to pass arguments by reference, you must use the ByRef keyword
in front of the argument, as in the following example:
Call MyFunction(argbyvalue, ByRef argbyref)
Set and Let are no longer supported. Objects can be assigned by a simple assignment
operation:
59
.NET Faq Naresh Kumar Nelluri
Object1 = Object2
To set a default property of an object, you must now explicitly reference the property. For
example:
Object1.Name = Object2.Name
Most objects no longer have default properties. All nonindexed properties must be explicitly
referenced. In previous versions of Visual Basic, if you wanted to access the default
property of an object, specifying the name of the property was optional. For example, if you
wanted to access the Text property of a TextBox control, you could use the following code:
Dim str As String = TextBox1
Using Visual Basic .NET, the above code must be modified as follows:
Dim str As String = TextBox1.Text
As another example, you must explicitly reference the Value property of the Field object
when retrieving fields from a Recordset (RS in the following example):
Response.Write (RS("au_fname").Value)
Indexed default properties are still supported, however. The Fields property, a default
collection property of the Recordset, does not have to be explicitly referenced because it is
an indexed property and the argument provides sufficient information to the compiler to
evaluate the expression. The preceding line of code is functionally equivalent to the
following line:
Response.Write (RS.Fields("au_fname").Value)
The Integer data type is now 32 bits; the Long data type is 64 bits.
Multipart Boolean expressions are short-circuited. If the first part of a multiple AND
expression evaluates to False, evaluation of the expression terminates and the entire
expression returns False. If the first part of a multiple OR expression evaluates to True,
evaluation terminates and the entire expression returns True.
Data types should always be explicitly cast to other data types. For instance, always cast
numerical values to String if a string is expected:
Response.Write("The count is " & CStr(count))
Variables created within the same Dim statement will be of the same type. For example, in
Visual Basic .NET, the Dim statement Dim i, j, k As Integer creates each of the three objects
(i, j, and k) as an Integer. Previous versions of Visual Basic would create i and j as
Variants and k as an Integer.
Class property syntax has changed and no longer includes Property Let, Property Get,
and Property Set. The new property syntax is similar to that in C#.
[Visual Basic]
Public Property ThisProperty As String
Get
ThisProperty = InternalValue
End Get
Set
InternalValue = value
End Set
End Property
Spaces must always be included around the & operator when concatenating strings.
VBScript allowed you to write a&b&c; in Visual Basic. NET this must be written as a & b & c
to avoid a syntax error.
60
.NET Faq Naresh Kumar Nelluri
All If statements must be constructed on multiple lines. With VBScript, it was possible to
write a single-line If statement such as If x Then y. In Visual Basic .NET, this must be
written as follows:
If x Then
y
End if
Option Explicit is on by default, so all variables must be declared before they can be used.
COM type definitions usually reside in a type library. In contrast, CLS-compliant compilers produce
type metadata in an assembly. The two sources of type information are quite different. This topic
describes techniques for generating metadata from a type library. The resulting assembly is called
an interop assembly.
When available, always use the primary interop assembly published by the author of the COM
component you intend to incorporate in your managed code. Types in the primary interop assembly
have been imported for you and are ready to activate and call from managed code.
Generating Metadata
COM type libraries can be standalone TLB files, such as Loanlib.tlb. Some type libraries are
embedded in the resource section of a DLL or EXE file. Other sources of type-library information
are OLB and OCX files.
After locating the type library containing the implementation of your target COM type, you have the
options described in the following table for generating an interop assembly containing type metadata.
Option Description
Visual Studio .NET Automatically converts COM types in a
type library to metadata in an assembly.
Type Library Importer Provides command-line switches to adjust
metadata in the resulting interop file,
imports types from an existing type
library, and generates an interop
assembly and a namespace.
TypeLibConverter Class Exposes methods that perform
conversion-related actions. Can convert
in-memory type library information to
metadata.
Custom Wrappers As a less-desirable option, you can create
type definitions from scratch. Requires
advanced programming skills.
For details about the COM interop import process, see Type Library to Assembly Conversion
Summary.
Visual Studio .NET generates an interop assembly containing metadata when you add a reference
to a given type library.
61
.NET Faq Naresh Kumar Nelluri
1. Install the COM DLL or EXE file on your computer, unless a Windows Setup.exe performs
the installation for you.
4. Select the type library from the Available References list, or browse for the TLB file.
5. Click OK.
The Type Library Importer (Tlbimp.exe) is a command-line tool that converts the coclasses and
interfaces contained in a COM type library to metadata. This tool creates an interop assembly and
namespace for the type information automatically. After the metadata of a class is available,
managed clients can create instances of the COM type and call its methods, just as if it were a .NET
instance. Tlbimp.exe converts an entire type library to metadata at once and cannot generate type
information for a subset of the types defined in a type library.
Use the following command to produce the Loanlib.dll assembly in the Loanlib namespace.
c:\>tlbimp Loanlib.dll
Adding the /out: switch produces an interop assembly with an altered name, such as LOANLib.dll.
Altering the interop assembly name can help distinguish it from the original COM DLL and prevent
problems that can occur from having duplicate names.
c:\>tlbimp LoanLib.dll /out: LOANLib.dll
TypeLibConverter Class
Custom Wrappers
When a type library is unavailable or incorrect, one option is to create a duplicate definition of the
class or interface in managed source code. You then compile the source code with a compiler that
targets the runtime to produce metadata in an assembly.
To define COM types manually, you must have access to the following items:
A compiler, such as the C# compiler, that can generate the appropriate .NET Framework
class definitions.
Writing a custom wrapper is an advanced technique that you seldom perform. For additional
information on generating a custom wrapper, see the Customizing Standard Wrappers topic.
62
.NET Faq Naresh Kumar Nelluri
Operator overloading enables developers to define new struct types that behave much like the
predefined value types. For instance, a Digit struct can support the same mathematical operations
as the predefined integral types, and can define conversions between Digit and predefined types.
The predefined types employ operator overloading themselves.
The following are the points to be remembered when using operator overloading
1. Only the operators mentioned in the list can be overloaded, other operators like new,
typeof, sizeof etc. cannot be overloaded.
3. At least one of the parameters for the operator overloading method should be the class for
which the operator overloading is defined.
7. Comparison operators should be overloaded only in pairs. (i.e.) if < is overloaded then >
should also overloaded.
What is a Destructor ?
Ans : A destructor is a member that implements the actions required to destruct an instance of a
class. Destructors cannot have parameters, cannot have accessibility modifiers, and cannot be
called explicitly. The destructor for an instance is called automatically during garbage collection.
A static constructor is only called once throughout the application's lifetime. The static constructor
method is called when any of the defining class' members are first accessed. The constructor is
called once only
cannot have parameters,
cannot have accessibility modifiers,
and cannot be called explicitly.
The static constructor for a class is called automatically.
Thus, the Color class can be enhanced by adding the readonly modifier to the static fields:
class Color
{
internal ushort redPart;
internal ushort bluePart;
internal ushort greenPart;
public Color(ushort red, ushort blue, ushort green) {
redPart = red;
bluePart = blue;
greenPart = green;
}
public static readonly Color Red = new Color(0xFF, 0, 0);
public static readonly Color Blue = new Color(0, 0xFF, 0);
public static readonly Color Green = new Color(0, 0, 0xFF);
public static readonly Color White = new Color(0xFF, 0xFF, 0xFF);
}
What is a constant?
Ans : A constant is a class member that represents a constant value:
a value that can be computed at compile-time.
Constants are permitted to depend on other constants within the same program as long as there
are no circular dependencies.
The rules governing constant expressions are defined in constant expression
The example
class Constants
{
public const int A = 1;
public const int B = A + 1;
}
shows a class named Constants that has two public constants.
Even though constants are considered static members, a constant declaration neither requires nor
allows the static modifier. Constants can be accessed through the class, as in
class Test
{
static void Main() {
Console.WriteLine("{0}, {1}", Constants.A, Constants.B);
}
}
which prints out the values of Constants.A and Constants.B.
What is a method?
Ans : A method is a member that implements a computation or action that can be performed by
an object or class. Methods have a list of formal parameters (which may be empty), a return value
(or void), and are either static or non-static.
Static methods are accessed through the class.
Non-static methods, which are also called instance methods, are accessed through instances of the
class.
64
.NET Faq Naresh Kumar Nelluri
Methods can be overloaded, which means that multiple methods may have the same name so long
as they have unique signatures.
The signature of a method consists of the name of the method and the number, modifiers, and
types of its formal parameters.
The signature of a method does not include the return type.
What is a Property ?
Ans : A property is a member that provides access to a characteristic
of an object or a class.
Examples of properties include the length of a string, the size of a font,
the caption of a window, the name of a customer, and so on.
Properties are a natural extension of fields.
Both are named members with associated types, and the syntax for accessing fields and
properties is the same. However, unlike fields, properties do not denote storage locations.
Instead, properties have accessors that specify the statements to be executed when their values
are read or written.
65
.NET Faq Naresh Kumar Nelluri
What is clustering
What is indexing
Types of indexes
Given a problem and asked for database design
ASP:
Types of objects
Types of authentication
C#:
CLR features
CLS and CTS definitions
Assembley and dll differences
Private and shared assemblies differences
what are static constructors
Memory management
Remoting concept
Typrs of proxies in remoting
Type of protocols and channels and difference
Webservices concept
Difference between webservices and remoting
Assembly loading, signing, generating keys
Java:
Oops:
Difference between abstract classes and interfaces (Descriptive answer with example)
Why interfaces are required
What is polymorphism
Different keywords and thier access types
static variables and static methos.
Patterns:
Types of Patterns
Singlton Pattern implementation
Observer Pattern implementation
MVC Pattern implementation
UML:
Usecase and class diagram concepts
66
.NET Faq Naresh Kumar Nelluri
xML\XSL:
What is sort?
sysntax of if,while and for loops in xsl
what is DTD?
what is xpath?
Advantages of oops?
what is inheritance,polymorphism?
advantages of asp.net over asp?
.net features?
what is normalisation?
advantages of normalisation?
what are design patterns?
what are attributes in .net?
ado.net architecture?
1)How to maintain transaction in asp and asp.net
2)how caching is done in asp and asp.net
3)what is the diff between disconnected recordset and dataset
4)what are the diff types of inheritance
5)name few of the abstract class in .net
6)how to maintain state in asp and asp.net
7)what is the best form of validation (server side and client side)
8)GAC what are the advantages and disadvantages
9)what is join like += and *=
10)what is the diff between sql 2000 and sql 7.0 in terms of triggers
11)what is magic table and temp table
12)Can u deploy .net assemblies in MTS
1)What is usercontrols?
2)Can we have dynamic usercontrols and can we pass values from the usercontrols to the aspx
pages?
3)What is the diff between abstract class and interface
4)Can u use javascript in aspx
5)what is the diff between windows dll and com dll
6)Diff between asp and asp.net
7)Diff between having and where clause
8)Can i have mulitple global.asa files
9)Diff between machine.config and web.config
10)what is web.config
11)Types of parameters passed in c# methods
12)byref and byval
13)diff between repeater,datalist and datagrid
14)threading
15)can i have a connected dataset
16)why u need dataadpater
17)diff between servercontrols and htmlcontrols
18)what is response.end,response.clear and response.flush
19)what is diff between asp caching and asp.net caching
20)what is global assembly cache.how to put the components in the GAC and is there any steps
before that
21)CLR,CTS and CLS
22)what are strongnames
23)what all u can pass in byval and byref
24)what is assembly
67
.NET Faq Naresh Kumar Nelluri
25)what is namespace and can we have nested namespace in a dll and where exactly the
namespace is stored
26)what is the version control in .net
27)what is the disadvantage of using static
28)Apart from DOM how can u retreive records in XML
29)how to use com in .net and vice versa
30)oops,operator overloading(What happend when the return type is different and the signature is
the same)
31)What is the difference between operator overloading and overiding
32)What is the namespace used for creating the collection object
33)can u force the garbage collector
34)can u use try without catch
35)how to create disconnected recordset in asp
36)what is the process flow of asp.net page
37)what is the problem of using server.transer
4)What is a join?what is the difference between inner joins and outer joins?
ASP
4)what are the ways on which we can access a COM component in an asp page?
COM/DCOM/COM+/MTS
5)Waht is COM+
XML/Schema/XSL
1)what is xml/schema/xsl?
2)What is the use of XSL?
3)How is a variable declared in XSL?
68
.NET Faq Naresh Kumar Nelluri
.NET
1)what is an assembly?
2)What is the difference betweemn VB and VB.net?
3)What is RCW and CCW?
4)What are the steps to be taken for porting a VB application to a VB.NET application?
69
.NET Faq Naresh Kumar Nelluri
38. Do u know Passport authentication?
39. What are types of securities we can provide through IIS.
40. What is Global.asax file?
41. What are the events present in the Global.asx file.
42. Can I place Global.asax out side the application directory?
43. Can I write Code behind file for the WEb.Config?( Ready with Machine.Config and
Security.Config files also. He may ask them. Because I explained them even he is not
asked.)
44. What is reflection?
45. What is Web service?
46. What is SOAP protocol?
47. What is Serialization?
48. What are types of serializations?
49. Draw a diagram to tell how WEB service works?
50. Are U comfortable with XML?(I said yes. He not asked me any further regarding XML.
Anyway prepare basics.)
51. Draw ADO.NET architecture?
52. What is the other name space we use connect to other databases? (Oledb)
53. Write Connection string for SQLConnection object.(remember --> Dont write Provider in the
conn string)
54. What do you know about remoting?
55. What is the role of Web Service in remoting?
56. U worked for 3 years on MS Tech. How confident u r in MTS? ( I said , I Used it but I dont
have theoritcal knowledge. I used it in ASP applications to register a DLL)
57. Study about Interface, Inheritance, OverLoad and OverRide. He asked different simple
questions on these.
58. What types of sessions we have in ASP.NET? (I don’t know. Look at Cookie sessions,
Cokkieless sessions).
59. Tell me the sequence of events occur in aspx page?
60. What is an Application Domain? ( I Just told defintion. He left this topic)
Questionnaire for Dev Lead Profile - MSBUIT
One important point which I noticed was that, he was asking me whether I was sure
about the answer very often to find that I am not bookish.
Q. Brief about yourself and about the roles and responsibilities for the past 1-2 years.
A. I explained him about my last project and the technologies involved and what was I doing off
late (pre-sales activities like estimation etc., involved in the design of a Biztalk to SAP adapter
project, have formed a team to do research on Tablet-PC to present a paper in Tech forum)
Note: A thread of discussion started here to know the depth of my understanding about the stack
and heap implementation in .NET. This discussion went on for more than 12 minutes. Basically he
wanted to know memory is managed in .NET by the CLR or runtime.
70
.NET Faq Naresh Kumar Nelluri
defined types which need to retain the state across function calls and have a lifetime which is
defined by the usage.
Note: I also explained him about the Garbage collection mechanism here and how GC works:
Application roots, marking for removal, Compaction and Finalization etc.
Q. Given an unsigned 16 bit integer, what is the max value it can hold?
A. 65535
Q. What happens if I store more than max value in the previous scenario?
A. In .Net this scenario can be addressed in two ways: If the same is done in a checked context,
the runtime will throw an OverflowException, whereas if run in unchecked context, the MSB is
truncated and rest of the value is stored in the variable and the execution continues…
Note: He asked whether I was sure about this and I said, yes. But he said “Check this out to-night
and you will be surprised to see the result”. Which in fact I did and didn’t find any surprise. May be
there’s some undocumented feature of .NET here.
Composition is a strong form of containment, where the part’s lifetime is dependent on the whole.
Cited and example.
71
.NET Faq Naresh Kumar Nelluri
Q. What is polymorphism?
A. Compile time polymorphism (Function/operator overloading examples).
Runtime polymorphism (Late binding, Virtual/Overridden functions examples).
Q. Given a base class reference to a derived class can you access the derived class
methods?
A. Object Polymorphism in other words: Cited the same shape Circle example and explained the
behavior.
72
.NET Faq Naresh Kumar Nelluri
Second Round of Interview Questions from Redmond
He upfront informed me that he had a question before the interview starts and asked me whether I
had VB knowledge. Since I didn't have any VB experience, I informed him about the same and
briefed him about my skillset (VC++, C++, C#, COM etc.,). He was in a opinion that there was a
miscommunication regarding job description and there is no point in continuing the interview
1. We got 3 sealed boxes one with Red other with Blue and the other with Green balls. Each
box has a label denoting the color of the balls that it contains. But the labels for all the
boxes r pasted wrongly. Now how many boxes should u open to find the color of balls in all
the 3 boxes?
Ans: 1
73
.NET Faq Naresh Kumar Nelluri
12)can i use action="a.exe" inside the form tag
13)can i use server.createobject(a.exe)
14)can i pass querystring in server.transfer
15)diff between server.transfer and server.execute
16)what is the step to be done before making an instance of excel file using server.createobject
17)what are type datasets
18)what is the difference between manifest and metadata
Database:
ASP:
Types of objects
Types of authentication
C#:
CLR features
CLS and CTS definitions
Assembley and dll differences
Private and shared assemblies differences
what are static constructors
Memory management
Remoting concept
Typrs of proxies in remoting
Type of protocols and channels and difference
Webservices concept
Difference between webservices and remoting
Assembly loading, signing, generating keys
Java:
Oops:
74
.NET Faq Naresh Kumar Nelluri
Why interfaces are required
What is polymorphism
Different keywords and thier access types static variables and static methos.
Patterns:
Types of Patterns
Singlton Pattern implementation
Observer Pattern implementation
MVC Pattern implementation
UML:
Usecase and class diagram concepts
xML\XSL:
What is sort?
sysntax of if,while and for loops in xsl
what is DTD?
what is xpath?
Advantages of oops?
what is inheritance,polymorphism?
advantages of asp.net over asp?
.net features?
what is normalisation?
advantages of normalisation?
what are design patterns?
what are attributes in .net?
ado.net architecture?
dataset
4)what are the diff types of inheritance
5)name few of the abstract class in .net
6)how to maintain state in asp and asp.net
7)what is the best form of validation (server side and
client side)
8)GAC what are the advantages and disadvantages
9)what is join like += and *=
10)what is the diff between sql 2000 and sql 7.0 in terms of
triggers
11)what is magic table and temp table
12)Can u deploy .net assemblies I
1)What is usercontrols?
2)Can we have dynamic usercontrols and can we pass values from the usercontrols to the aspx
pages?
3)What is the diff between abstract class and interface
4)Can u use javascript in aspx
75
.NET Faq Naresh Kumar Nelluri
5)what is the diff between windows dll and com dll
6)Diff between asp and asp.net
7)Diff between having and where clause
8)Can i have mulitple global.asa files
9)Diff between machine.config and web.config
10)what is web.config
11)Types of parameters passed in c# methods
12)byref and byval
13)diff between repeater,datalist and datagrid
14)threading
15)can i have a connected dataset
16)why u need dataadpater
17)diff between servercontrols and htmlcontrols
18)what is response.end,response.clear and response.flush
19)what is diff between asp caching and asp.net caching
20)what is global assembly cache.how to put the components in the GAC and is there any steps
before that
21)CLR,CTS and CLS
22)what are strongnames
23)what all u can pass in byval and byref
24)what is assembly
25)what is namespace and can we have nested namespace in a dll and where exactly the
namespace is stored
26)what is the version control in .net
27)what is the disadvantage of using static
28)Apart from DOM how can u retreive records in XML
29)how to use com in .net and vice versa
30)oops,operator overloading(What happend when the return type is different and the signature is
the same)
31)What is the difference between operator overloading and
overiding
32)What is the namespace used for creating the collection
object
33)can u force the garbage collector
34)can u use try without catch
35)how to create disconnected recordset in asp
36)what is the process flow of asp.net page
37)what is the problem of using server.transer
ASP
76
.NET Faq Naresh Kumar Nelluri
4)what are the ways on which we can access a COM component in an asp page?
COM/DCOM/COM+/MTS
5)Waht is COM+
XML/Schema/XSL
1)what is xml/schema/xsl?
2)What is the use of XSL?
3)How is a variable declared in XSL?
.NET
1)what is an assembly?
2)What is the difference betweemn VB and VB.net?
3)What is RCW and CCW?
4)What are the steps to be taken for porting a VB
application to a VB.NET application?
77