Friday, August 26, 2011

Why to use DLL

A DLL is a collection of small programs, which can be called when needed by a larger program that is running in the computer. The small program that lets the larger communicate with a specific device such as printer or scanner is often packged as a a DLL program.

The advantages of DLL:
DLL's don't get loaded in RAM together with the program , so space is saved in RAM(Random Access Memory).

When and if a DLL file is needed, then it is loaded and run. For example, as long as a user of Microsoft Word is editing a document, the printer DLL file does not need to be loaded into RAM. If the user decides to print the document, then the Word application causes the printer DLL file to be loaded and run.

Wednesday, August 24, 2011

Why do we need Try-Finally block


The output that the code in the finally block will be executed after throwing the exception. However, the last statements in the program that followed the finally block will not be executed. This means that the exception
prevents control from being transferred to any part of the program except the finally block.



using System;
public class MyClass
{
static void Main()

{
string myString = "Finally";
object myObject = myString;
try
{
// The following conversion is invalid.
// It throws an exception.
int myInt = (int)myObject;
}
finally
{
// The code in this block is always executed:
Console.WriteLine("The program continues and ends here:");
Console.WriteLine("My String is: {0}", myString);
}
// The following code will not be executed:
Console.WriteLine("Hello again!");
}
}

It is also used for cleaning up the resource, like to close the open file stream..

Tuesday, August 9, 2011

How to Create Windows Services

What are Windows Services


  • Windows Service is a long running executable that perform specif function.

  • They do not require user intervention.

  • Windows services can be configured to start when the operating system is booted and run in the background as long as windows is running , or can be started/stopped manually when required.

  • Windows services can be developed using Microsoft visual studio.

  • Services can execute even when the user is not logged in.