Friday, January 7, 2011

ASP Qns

What is the difference between Finalize() and Dispose()?

Dispose() is called by as an indication for an object to release any unmanaged resources it has held.
Finalize() is used for the same purpose as dispose however finalize doesn’t assure the garbage collection of an object.
Dispose() operates determinalistically due to which it is generally preferred

______________
What is the difference between XML Web Services using ASMX and .NET Remoting using SOAP?

XML Web services are more restricted than objects exposed over .NET Remoting.
XML Web services support open standards that target cross-platform use.
XML Web services are generally easier to create and due to the restricted nature of XML Web services, the design issues are simplified.
XML Web services support only SOAP message formatting, which uses larger XML text messages.
Communication with .NET Remoting can be faster than XML Web service communication with a binary formatter.
XML Web services are designed for use between companies and organizations.
XML Web services don't require a dedicated hosting program because they are always hosted by ASP.NET.
Consumers can use XML Web services just as easily as they can download HTML pages from the Internet. Thus there's no need for an administrator to open additional ports on a firewall as they work through MS-IIS and ASP.NET

______________
Explain how to add controls dynamically to the form using C#.NET.

The following code can be called on some event like page load or onload of some image or even a user action like onclick

protected void add_button(Button button)
{
try
{
panel1.Controls.Add(button); // Add the control to the container on a page
}
catch (Exception ex)
{
label1.Text += ex.Message.ToString();
}
}

______________
Why is an Object Pool required?

The request for the creation of an object is served by allocating an object from the pool.

This reduces the overhead of creating and re-creating objects each time an object creation is required.

C#.Net - Why is an object pool required?

To enhance performance and reduce the load of creating new objects, instead re using existing objects stored in memory pool. Object Pool is a container of objects that are for use and have already been created. Whenever an object creation request occurs, the pool manager serves the request by allocating an object from the pool. This minimizes the memory consumption and system's resources by recycling and re-using objects. When the task of an object is done, it is sent to the pool rather than being destroyed. This reduces the work for garbage collector and fewer memory allocations occur.

______________

What are ILDASM and Obfuscator in NET?

ILDASM (Intermediate Language Disassembler)
De-Compilation is the process of getting the source code from the assembly.
ILDASM is a de-compiler provided by Microsoft.
This ILDASM converts an assembly to instructions from which source code can be obtained.
Obfuscated code is source code or intermediate language that is very hard to read and understand.
An obfuscator is a medium of making a program difficult to understand.
The way the code runs remains unaffected although the obfuscator makes it harder to hack the code and hijack the program.
C#.Net - What is ILDASM and Obfuscator in NET?

ILDASM is MSIL Disassmbler. This take a portable executable (PE), which consists of MSIL code, and creates a text file which can then be used as an input for ILASM.exe, which is MSIL assembler. ILDASM can parse any .Net dll or exe and shows information in human readable form. It displays MSIL, namespaces, types and interfaces. It's normally used to examine assemblies and understand what the assembly is capable of.

Obfuscator is a tool to protect .Net assemblies and exe files. The tool renames all possible symbols, types, interfaces, namespaces etc into meaningless values and removes all unnecessary information. This reduces the size of the assemblies and also helps in protecting the code. It's normally used to protect the assemblies from exposing information for reverse engineering.

_____________

What is the GAC? What problem does it solve?

Global Assembly Cache (GAC):

Any system that has the CLR (common language runtime) installed, has a machine-wide code cache known as GAC.

Assemblies deployed in the global assembly cache need to have a strong name.

The Global Assembly Cache tool (Gacutil.exe), provided by the .NET Framework SDK can be used to deploy assemblies to GAC.
____________

No comments:

Post a Comment