Top 50 . Net Interview Questions You Must Prepare 19.Mar.2024

@Data Reader is read only forward only and much faster than DataAdapter.
@If you use DataReader you have to open and close connection explicitly where as if you use DataAdapter the connection is automatically opened and closed.
@DataReader is connection oriented where as Data Adapter is disconnected

One of the good features of the CLR is Garbage Collection, which runs in the background collecting unused object references, freeing us from having to ensure we always destroy them. In reality the time difference between you releasing the object instance and it being garbage collected is likely to be very small, since the GC is always running.
[The process of tritively tracing through all pointers to actively used objects in order to locate all objects that can be referenced, and then arranging to reuse any heap memory that was not found during this trace. The common language runtime garbage collector also compacts the memory that is in use to reduce the working space needed for the heap.]

Heap:
A portion of memory reserved for a program to use for the temporary storage of data structures whose existence or size cannot be determined until the program is running.

The memory representation of string is an Array of Characters, So on re-assigning the new array of Char is formed & the start address is changed . Thus keeping the Old string in Memory for Garbage Collector to be disposed.

What is break mode? What are the options to step through code? | Debug Vs Trace. | Define trace class. Define Listeners collection of Trace and Debug objects. | Define Trace Switches.

To create an application or game you need to design, code and give some extra feature to your output. To do the above, you need some controls, IDE etc.

Silverlight Tool kit is nothing but is a collection of Silverlight Tools, Components etc. It includes source code describing the all you need to develop an application.

When an exception occurs, the system searches for the nearest catch clause that can handle the exception, as determined by the run-time type of the exception. First, the current method is searched for a lexically enclosing try statement, and the associated catch clauses of the try statement are considered in order. If that fails, the method that called the current method is searched for a lexically enclosing try statement that encloses the point of the call to the current method. This search continues until a catch clause is found that can handle the current exception, by naming an exception class that is of the same class, or a base class, of the run-time type of the exception being thrown. A catch clause that doesn't name an exception class can handle any exception.

Once a matching catch clause is found, the system prepares to trfer control to the first statement of the catch clause. Before execution of the catch clause begins, the system first executes, in order, any finally clauses that were associated with try statements more nested that than the one that caught the exception.

Exceptions that occur during destructor execution are worth special mention. If an exception occurs during destructor execution, and that exception is not caught, then the execution of that destructor is terminated and the destructor of the base class (if any) is called. If there is no base class (as in the case of the object type) or if there is no base class destructor, then the exception is discarded.

Silverlight is built on top of Windows Media enabling developers and designers to collaborate in building media experiences and RIAs. Silverlight is released by the Server and Tools Division at Microsoft as a part of the .NET Framework.

Side-by-side execution is the ability to run multiple versions of an application or component on the same computer. You can have multiple versions of the common language runtime, and multiple versions of applications and components that use a version of the runtime, on the same computer at the same time. Since versioning is only applied to shared assemblies, and not to private assemblies, two application one using private assembly and one using shared assembly cannot be stated as side-by-side executables,

When .NET was introduced it came with several languages.
VB.NET,
C#,
COBOL
and
Perl, etc.
 

Advantages VB.NET :-

* Has support for optional parameters which makes COM interoperability much easy.
* With Option Strict off late binding is supported.Legacy VB functionalities can be used by using Microsoft.VisualBasic namespace.
* Has the WITH construct which is not in C#.
* The VB.NET part of Visual Studio .NET compiles your code in the background.

While this is considered an advantage for small projects, people creating very large projects have found that the IDE slows down considerably as the project gets larger.

Advantages of C#

* XML documentation is generated from source code but this is now been incorporated in Whidbey.
*Operator overloading which is not in current VB.NET but is been introduced in Whidbey.
* The using statement, which makes unmanaged resource disposal simple.
* Access to Unsafe code. This allows pointer arithmetic etc, and can improve performance in some situations. However, it is not to be used lightly, as a lot of the normal safety of C# is lost (as the name implies).This is the major difference that you can access unmanaged code in C# and not in VB.NET

Because of the garbage collection algorithm. The .NET garbage collector works by periodically running through a list of all the objects that are currently being referenced by an application. All the objects that it doesn't find during this search are ready to be destroyed and the memory reclaimed. The implication of this algorithm is that the runtime doesn't get notified immediately when the final reference on an object goes away - it only finds out during the next sweep of the heap.

Futhermore, this type of algorithm works best by performing the garbage collection sweep as rarely as possible. Normally heap exhaustion is the trigger for a collection sweep.

IIS smooth streaming enables for delivering HD streams smoothly on any device. IIS smooth streaming is an extension of IIS7 Media Services 3.@It enables adaptive live streaming through HTTProtocols.

Yes. Page needs to have a script manager for ajax control tool kit controls to work.

The Windows operating system does not provide support for running a CLR application. That support is provided by a CLR host. A CLR host is an application that is responsible for loading the CLR into a process, creating application domains within the process, and executing user code within the application domains. Examples of hosts that ship with the .NET Framework include:

ASP.NET. An ISAPI filter that ships with ASP.NET loads the CLR and does the initialization necessary to handle web requests.

Internet Explorer. A MIME filter hooks into Internet Explorer versions 5.01 and higher to execute managed controls referenced from HTML pages.

Shell Executables. When a managed application is launched from a shell, a small piece of unmanaged code loads the CLR and tritions control of the application to the CLR.

  • You can create an objects of Dll but not of the EXE.
  • Dll is an In-Process Component whereas EXE is an OUt-Process Component.
  • Exe is for single use whereas you can use Dll for multiple use.
  • Exe can be started as standalone where dll cannot be.

  Server.GetLastError();
[C#]
Exception LastError;
String ErrMessage;
LastError = Server.GetLastError();
if (LastError != null)
ErrMessage = LastError.Message;
else
ErrMessage = "No Errors";
Response.Write("Last Error = " + ErrMessage);

 

The mouse events that supports silverlight are

LostMouseCapture - occurs when an UI element lost mouse capture
MouseMove - occurs when the mouse position changes
MouseEnter - occurs when the mouse pointer enters into the bounding area of an object
MouseLeave - occurs when the mouse pointer leaves the bounding area of an object
MouseLeftButtonDown - occurs when the left mouse button is down
MouseLeftButtonU - occurs when the left mouse button is up followed by MouseLeftButtonDown

Choosing a programming language depends on your language experience and the scope of the application you are building. While small applications are often created using only one language, it is not uncommon to develop large applications using multiple languages.For example, if you are extending an application with existing XML Web services, you might use a scripting language with little or no programming effort. For client-server applications, you would probably choose the single language you are most comfortable with for the entire application. For new enterprise applications, where large teams of developers create components and services for deployment across multiple remote sites, the best choice might be to use several languages depending on developer skills and long-term maintenance expectations.The .NET Platform programming languages - including Visual Basic .NET, Visual C#, and Visual C++ with managed extensions, and many other programming languages from various vendors - use .NET Framework services and features through a common set of unified classes. The .NET unified classes provide a consistent method of accessing the platform's functionality. If you learn to use the class library, you will find that all tasks follow the same uniform architecture. You no longer need to learn and master different API architectures to write your applications.

It is the runtime that converts a MSIL code into the host machine language code, which is then executed appropriately. It is the execution engine for .NET Frameworkapplications. It provides a number of services, including:

  • Code management (loading and execution)
  • Application memory isolation
  • Verification of type safety
  • Conversion of IL to native code.
  • Access to metadata (enhanced type information)
  • Managing memory for managed objects
  • Enforcement of code access security
  • Exception handling, including cross-language exceptions
  • Interoperation between managed code, COM objects, and pre-existing DLL's (unmanaged code and data)
  • Automation of object layout
  • Support for developer services (profiling, debugging, and so on}.

  [XmlIgnore]  (use attribute on the property)    Eg:     [XmlIgnore]  public string Name  {  ..  }

Using pagination option in DataGrid control is available in .NET. We have to set the number of records for a page, then it takes care of pagination by itself automatically.

In straight way you create a subimage from an existing image. Here you just clip an image, Clipping is just different from Cropping. In clipping, first you have to dictate which part of the images to draw and later you have to remove all but the desired part of the image. Silverlight does not support cropping.

If you are using the SOAP Toolkit, you need to set some connector properties to use a proxy server:

  Dim soap As SoapClient Set soap=New SoapClient  soap.ConnectorProperty("ProxyServer") = ?proxyservername?  soap.ConnectorProperty("ProxyPort") = ?8080?  soap.ConnectorProperty("UseProxy") = True

While with .NET , you just need to create a System.Net.WebProxy object and use it to set the Proxy property Dim

  webs As localhost.MyService() webs.Proxy=New  System.Net.WebProxy(?http://proxyserver:8080?)

Caspol has a couple of options that might help. First, you can ask caspol to tell you what code group an assembly belongs to, using caspol -rsg. Similarly, you can ask what permissions are being applied to a particular assembly using caspol -rsp

Thread's execution can be paused by calling the Thread.Sleep method. This method takes an integer value that determines how long the thread should sleep. Example Thread.CurrentThread.Sleep(2000). it will paused for 2 second.

A static assembly can consist of four elements:

  • Assembly manifest-Contains the assembly metadata. An assembly manifest contains the information about the identity and version of the assembly. It also contains the information required to resolve references to types and resources.
  • Type metadata-Binary information that describes a program.
  • Microsoft intermediate language(MSIL)code.
  • A set of resources

Event handling is performed in two event cases – Input events and Non-input events.

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.

The first step in running managed code in a process is to get the CLR loaded and initialized using a CLR host. Typically, a host consists of both managed code and unmanaged code. The managed code which executes in the default domain is usually responsible for creating the application domains in which the user code exists. All CLR hosts must contain unmanaged code because execution must begin in unmanaged code. The .NET Frameworks provides a set of unmanaged APIs that the host can use to configure the CLR, load the CLR into a process, load the hosts managed code into the default domain, and trition from the unmanaged code to the managed code. The second step in running managed code in a process is to create application domains in which the user code will execute. The creator of the application domain can specify criteria which control code isolation, security, and loading of assemblies. The third step in running managed code in a process is to execute user code in one or more application domains created in the previous step. All code that is run in the CLR must be part of an assembly. There are three options for loading assemblies. First, precompiled assemblies can be loaded from disk. Second, precompiled assemblies can be loaded from an array of bytes. Third, assemblies can be built dynamically in an application domain using the BCL Reflection Emit APIs.

Note. For an application launched from the command-line, the shell host executes the steps described above on behalf of the user and hides the complexity from the user.

The process of tritively tracing through all pointers to actively used objects in order to locate all objects that can be referenced, and then arranging to reuse any heap memory that was not found during this trace. The common language runtime garbage collector also compacts the memory that is in use to reduce the working space needed for the heap.

It's the Attributesproperty, the Add function inside that property. e.g.btnSubmit.Attributes.Add("onMouseOver","someClientCode();")

The primary steps to properly design custom attribute classes are as follows:
Applying the AttributeUsageAttribute
([AttributeUsage(AttributeTargets.All,
Inherited = false, AllowMultiple = true)])
Declaring the attribute. (class public class MyAttribute : System.Attribute { // .
. . })
Declaring constructors (public MyAttribute(bool myvalue) { this.myvalue =
myvalue; })
Declaring properties
public bool MyProperty
{
get {return this.myvalue;}
set {this.myvalue = value;}
}

The following example demonstrates the basic way of using reflection to get access to custom attributes.
class MainClass
{
public static void Main()
{
System.Reflection.MemberInfo info = typeof(MyClass);
object[] attributes = info.GetCustomAttributes();
for (int i = 0; i < attributes.Length; i ++)
{
System.Console.WriteLine(attributes[i]);
}
}
}

.NET Remoting and ASP.NET Web Services. If we talk about the Framework Class Library, noteworthy classes are in System.Runtime.Remoting and System.Web.Services.

Code security is the approach of using permissions and permission sets for a given code to run. The admin, for example, can disable running executables off the Internet or restrict access to corporate database to only few applications.

Role security most of the time involves the code running with the privileges of the current user. This way the code cannot supposedly do more harm than mess up a single user account.

Neither is better. It depends on the nature of the application; both code-based and role-based security could be implemented to an extent.

DLL contains the IL and other details (metadata) inside.

Common Language Specification (CLS) defines the rules and standards to which languages must adhere to in order to be compatible with other .NET languages. This enables C# developers to inherit from classes defined in VB.NET or other .NET compatible languages

Object.Finalize method in .NET is typically used to clean and release unmanaged resources like OS files, window etc. Even though Garbage collector in .NET has the ability to determine the life time of such objects, however, with no knowledge how to clean them. The Finalize method allows an object to clean up such unmanaged resources when the garbage collector wishes to reclaim the memory. However, Finalize method should be avoided until necessary as it affects the performance because reclaiming the memory used by objects with Finalize methods requires at least two garbage collections.

Application resources utilize the style elements for supporting the forms. The App.xaml file could be used to contain an application resource XML construct. Each style’s target type is set to the control that needs the style.

(Class constructor method is also known as type constructor or type initializer) Instance constructor is executed when a new instance of type is created and the class constructor is executed after the type is loaded and before any one of the type members is accessed. (It will get executed only 1st time, when we call any static methods/fields in the same class.) Class constructors are used for static field initialization. Only one class constructor per type is permitted, and it cannot use the vararg (variable argument) calling convention.

A static constructor is used to initialize a class. It is called automatically to initialize the class before the first instance is created or any static members are referenced.

Following are the different steps needed to get a proxy object of a webservice at the client side:
-Client communicates to UDDI node for webservice either through browser or UDDI’s public web service.
-UDDI node responds with a list of webservices.
-Every service listed by webservice has a URI pointing to DISCO or WSDL document.
-After parsing the DISCO document, we follow the URI for the WSDL document related to the webservice which we need.
-Client then parses the WSDL document and builds a proxy object which can communicate with Webservice.

We can make Asynchronous method calls by using delegates.

Use the ScriptManager class. This class contains several methods like the RegisterStartupScript(), Register Client ScriptBlock(), Register Client Script Include(), Register Array Declaration(), Register Client Script Resource(), Register Expand oAttribute(), Register On SubmitStatement() which helps to add javascript while performing an asynchronous postback.

Follow these steps to create a CLR trigger of DML (after) type to perform an insert action:
• Create a .NET class of triggering action
• Make an assembly (.DLL) from that Class
• Enable CLR environment in that database.
• Register the assembly in SQL Server
• Create CLR Trigger using that assembly

Yes, it is often relatively straightforward to regenerate high-level source from IL. Lutz Roeder'sReflector does a very good job of turning IL into C# or VB.NET.

ViewState persist the values of controls of particular page in the client (browser) when post back operation done. When user requests another page previous page data no longer available.

SessionState persist the data of particular user in the server. This data available till user close the browser or session time completes.

ViewState Relate to Controls, it me when Client send request in the form of Controls' value to server,In case any validation problem relating to Clients data then the entire data is not cleaned as it was occur is asp,it can restore the existing data in the form of hidden control and render data by server to respective controls,as a result user will not enter the complete information again, where as SessionState relates to individual user,it manages the user related information and maintain the session between client server.

DCOM is a distributed extension of COM. It differs from COM in that it allows for creating objects distributed across a network, a protocol for invoking that object's methods, and secure to the object. DCOM provides a wrapper around COM, hence it is a backward compatible extension.

You create an instance in a using statement to ensure that Dispose is called on the object when the using statement is exited. A using statement can be exited either when the end of the using statement is reached or if, for example, an exception is thrown and control leaves the statement block before the end of the statement.

The using directive has two uses:

Create an alias for a namespace (a using alias).

Permit the use of types in a namespace, such that, you do not have to qualify the use of a type in that namespace (a using directive).

Each process is allocated its own block of available RAM space, no process can access another process code or data. If the process crashes, it dies alone without taking the entire OS or a bunch of other applications down.

Using Visual Studio Web Developer Express 2005 & versions above it, Ajax based applications may easily be created. Note that the Ajax Framework & Ajax Extensions should be installed (In case of VS 2005). If using Visual Studio 2008 Web Developer Express or above, Ajax comes along with it (so no need of a separate installation).