Saturday, May 1, 2010

How you will handle session when deploying application in more than a server? Describe session handling in a webfarm, how does it work and what are th

By default, ASP.NET will store the session state in the same process that processes the request. ASP.NET can store session data in an external process which can even reside on another machine. To enable this feature:
* Start the ASP.NET state service, either using the Services snap-in or by executing "net start aspnet_state" on the command line. The state service will by default listen on port 42424.
* Set the mode attribute of the section to "StateServer".
* Configure the stateConnectionString attribute with the values of the machine on which you started aspnet_state.

How does an AppDomain get created?

AppDomains are usually created by hosts like Windows Shell, ASP.NET and IE etc.
When you run a .NET application from the command-line the host is the Shell. The Shell creates a new AppDomain for every application.

AppDomains can also be explicitly created by .NET applications. Here is a C# sample which creates an AppDomain creates an instance of an object inside it, and then
executes one of the object's methods.

using System;
using System.Runtime.Remoting;

public class AppDomainInfo : MarshalByRefObject

{
public string GetAppDomainInfo()

{
return "AppDomain = " + AppDomain.CurrentDomain.FriendlyName;
}
}

public class App
{

public static int Main()
{
AppDomain ad = AppDomain.CreateDomain( "My new domain", null, null );
ObjectHandle objh = ad.CreateInstance( "appdomaintest", "GetAppDomainInfo");
GetAppDomainInfo myInfo = (GetAppDomainInfo)(objh.Unwrap());
string info = myInfo.GetAppDomainInfo();
Console.WriteLine( "AppDomain : " + info );
return 0;
}
}

Wednesday, April 28, 2010

Thursday, April 1, 2010

Difference between OLEDB Provider and SqlClient ?

SQLClient .NET classes are highly optimized for the .net / sqlserver combination and achieve optimal results. The SqlClient data provider is fast. It's faster than the Oracle provider, and faster than accessing database via the OleDb layer. It's faster because it accesses the native library (which automatically gives you better performance), and it was written with lots of help from the SQL Server team.

What are object pooling and connection pooling and difference? Where do we set the Min and Max Pool size for connection pooling?

Object pooling is a COM+ service that enables you to reduce the overhead of creating each object from scratch. When an object is activated, it is pulled from the pool. When the object is deactivated, it is placed back into the pool to await the next request. You can configure object pooling by applying the ObjectPoolingAttribute attribute to a class that derives from the System.EnterpriseServices.ServicedComponent class.
Object pooling lets you control the number of connections you use, as opposed to connection pooling, where you control the maximum number reached.
Following are important differences between object pooling and connection pooling:

* Creation. When using connection pooling, creation is on the same thread, so if there is nothing in the pool, a connection is created on your behalf. With object pooling, the pool might decide to create a new object. However, if you have already reached your maximum, it instead gives you the next available object. This is crucial behavior when it takes a long time to create an object, but you do not use it for very long.
* Enforcement of minimums and maximums. This is not done in connection pooling. The maximum value in object pooling is very important when trying to scale your application. You might need to multiplex thousands of requests to just a few objects. (TPC/C benchmarks rely on this.)

COM+ object pooling is identical to what is used in .NET Framework managed SQL Client connection pooling. For example, creation is on a different thread and minimums and maximums are enforced.

What is portable executable (PE)?

The file format defining the structure that all executable files (EXE) and Dynamic Link Libraries (DLL) must use to allow them to be loaded and executed by Windows. PE is derived from the Microsoft Common Object File Format (COFF). The EXE and DLL files created using the .NET Framework obey the PE/COFF formats and also add additional header and data sections to the files that are only used by the CLR.

Friday, March 12, 2010

What are relation objects in dataset and how & where to use them?

In a DataSet that contains multiple DataTable objects, you can use DataRelation objects to relate one table to another, to navigate through the tables, and to return child or parent rows from a related table. Adding a DataRelation to a DataSet adds, by default, a UniqueConstraint to the parent table and a ForeignKeyConstraint to the child table.

The following code example creates a DataRelation using two DataTable objects in a DataSet. Each DataTable contains a column named CustID, which serves as a link between the two DataTable objects. The example adds a single DataRelation to the Relations collection of the DataSet. The first argument in the example specifies the name of the DataRelation being created. The second argument sets the parent DataColumn and the third argument sets the child DataColumn.
custDataSet.Relations.Add("CustOrders",
custDataSet.Tables["Customers"].Columns["CustID"],
custDataSet.Tables["Orders"].Columns["CustID"]);

OR
private void CreateRelation()
{
DataColumn parentCol;
DataColumn childCol;
parentCol = custDataSet.Tables["Customers"].Columns["CustID"];
childCol = custDataSet.Tables["Orders"].Columns["CustID"];
DataRelation relCustOrder;
relCustOrder = new DataRelation("CustomersOrders", parentCol, childCol);
custDataSet.Relations.Add(relCustOrder);
}