Saturday 10 December 2011

Imp qus in asp .net3


What can be stored in Web.config file? 

There are number of important settings that can be stored in the configuration file. Here are some of the most frequently used configurations, stored conveniently inside Web.config file..
1. Database connections
2. Session States
3. Error Handling
4. Security

Difference between Web.config and machine.config. 

web.config:
Web.config file, as it sounds like is a configuration file for the Asp .net web application. An Asp .net application has one web.config file which keeps the configurations required for the corresponding application. Web.config file is written in XML with specific tags having specific meanings.

machine.config
As web.config file is used to configure one asp .net web application, same way Machine.config file is used to configure the application according to a particular machine. That is, configuration done in machine.config file is affected on any application that runs on a particular machine. Usually, this file is not altered and only web.config is used which configuring applications.

Where we can use DLL made in C#.Net ? 

Supporting .Net, bcoz DLL made in C#.Net semicompiled version. Its not a com object. It is used only in .Net Framework.As it is to be compiled at runtime to byte code

If A.equals(B) is true then A.getHashcode & B.getHashCode must always return same hash code. 

The answer is False because it is given that A.equals(B) returns true i.e. objects are equal and now its hashCode is asked which is always independent of the fact that whether objects are equal or not. So, GetHashCode for both of the objects returns different value.

To Configure .Net for JIT activation what do you do? 

Actually JIT activation is required for COM+ components which can be done by setting JustInTimeActivation attribute to true (choice A). For .net applications / components JIT comes in by default.

How do you import Activex component in to .NET? 

An application called AXImp.exe shipped with .Net SDK is used.
This application does something similar as Tlbimp.exe does for non graphical COM components.
It creates a wrapper component that contains the type information that the .Net runtime can understand.

What is the use of fixed statement? 

The fixed statement sets a pointer to a managed variable and “pins” that variable during the execution of statement.
Without fixed, pointers to managed variables would be of little use since garbage collection could relocate the variables unpredictably. (In fact, the C# compiler will not allow you to set a pointer to a managed variable except in a fixed statement.)
Eg:

Class A { public int i; }
A objA = new A; // A is a .net managed type
fixed(int *pt = &objA.i) // use fixed while using pointers with managed
// variables
{
*pt=45; // in this block use the pointer the way u want
}

What is the order of destructors called in a polymorphism hierarchy? 

Destructors are called in reverse order of constructors. First destructor of most derived class is called followed by its parent’s destructor and so on till the topmost class in the hierarchy.
You don’t have control over when the first destructor will be called, since it is determined by the garbage collector. Sometime after the object goes out of scope GC calls the destructor, then its parent’s destructor and so on.
When a program terminates definitely all object’s destructors are called.

How can you sort the elements of the array in descending order? 

int[] arr = new int[3];
arr[0] = 4;
arr[1] = 1;
arr[2] = 5;
Array.Sort(arr);
Array.Reverse(arr);

Is it possible to Override Private Virtual methods. 

No, First of all you cannot declare a method as ‘private virtual’.

What does the volatile modifier do? 

The system always reads the current value of a volatile object at the point it is requested, even if the previous instruction asked for a value from the same object. Also, the value of the object is written immediately on assignment.
The volatile modifier is usually used for a field that is accessed by multiple threads without using the lock statement to serialize access. Using the volatile modifier ensures that one thread retrieves the most up-to-date value written by another thread.

Is it possible to debug the classes written in other .Net languages in a C# project. 

It is definitely possible to debug other .Net languages code in a C# project. As everyone knows .net can combine code written in several .net languages into one single assembly. Same is true with debugging.

How do you debug an ASP.NET Web application? 

Attach the aspnet_wp.exe process to the DbgClr debugger.

What debugging tools come with the .NET SDK? 

1.� � CorDBG – command-line debugger.� To use CorDbg, you must compile the original C# file using the /debug switch.
2.� � DbgCLR – graphic debugger.� Visual Studio .NET uses the DbgCLR.

What is the difference between structures and enumeration? 

Unlike classes, structs are value types and do not require heap allocation. A variable of a struct type directly contains the data of the struct, whereas a variable of a class type contains a reference to the data. They are derived from System.ValueType class.
Enum->An enum type is a distinct type that declares a set of named constants.They� are strongly typed constants. They are unique types that allow to declare symbolic names to integral values. Enums are value types, which means they contain their own value, can’t inherit or be inherited from and assignment copies the value of one enum to another.
public enum Grade
{
A,
B,
C
}

What is Value type and refernce type in .Net? 

Value Type : A variable of a value type always contains a value of that type. The assignment to a variable of a value type creates a copy of the assigned value, while the assignment to a variable of a reference type creates a copy of the reference but not of the referenced object.
The value types consist of two main categories:
* Stuct Type
* Enumeration Type

Reference Type
:Variables of reference types, referred to as objects, store references to the actual data. This section introduces the following keywords used to declare reference types:
* Class
* Interface
* Delegate

This section also introduces the following built-in reference types:
* object
* string

What are the types of assemblies? 

There are four types of assemblies in .NET:

Static assemblies
These are the .NET PE files that you create at compile time.

Dynamic assemblies

These are PE-formatted, in-memory assemblies that you dynamically create at runtime using the classes in the System.Reflection.Emit namespace.

Private assemblies
These are static assemblies used by a specific application.
Public or shared assemblies These are static assemblies that must have a unique shared name and can be used by any application.

An application uses a private assembly by referring to the assembly using a static path or through an XML-based application configuration file. While the CLR doesn’t enforce versioning policies-checking whether the correct version is used-for private assemblies, it ensures that an application uses the correct shared assemblies with which the application was built. Thus, an application uses a specific shared assembly by referring to the specific shared assembly, and the CLR ensures that the correct version is loaded at runtime.
In .NET, an assembly is the smallest unit to which you can associate a version number

What is manifest? 

It is the metadata that describes the assemblies.

What distributed process frameworks outside .NET do you know? 

Distributed Computing Environment/Remote Procedure Calls (DEC/RPC), Microsoft Distributed Component Object Model� (DCOM), Common Object Request Broker Architecture (CORBA), and Java Remote Method Invocation (RMI).

How do you retrieve the customized properties of a .NET application from XML .config file? 

Initialize an instance of AppSettingsReader class. Call the GetValue method of AppSettingsReader class, passing in the name of the property and the type expected. Assign the result to the appropriate variable.

When would you use ErrorProvider control? 

ErrorProvider control is used in Windows Forms application. It is like Validation Control for ASP.NET pages. ErrorProvider control is used to provide validations in Windows forms and display user friendly messages to the user if the validation fails.� E.g. if we went to validate the textBox1 should be empty, then we can validate as below
1). You need to place the errorprovide control on the form

private void textBox1_Validating(object sender,System.ComponentModel.CancelEventArgs e)
{
ValidateName();
}
private bool ValidateName()
{
bool bStatus = true;
if (textBox1.Text == "")
{
errorProvider1.SetError (textBox1,"Please enter your Name");
bStatus = false;
}
else
errorProvider1.SetError (textBox1,"");
return bStatus;
}

it check the textBox1 is empty . If it is empty, then a message Please enter your name is displayed.

No comments:

Post a Comment