What is difference between dispose and destructor

Destructors are called by the CLR when the Garbage Collector destroys an object. In VB.NET it is called the Finalize() method. In C# it is declared by putting a til ‘~’ in front of the class name (~MyClass() {}).

Since when exactly GC will call Finalize method is not know you might land up holding critical resources like database connections. it not advice to leave connection close statements in finalized methods, instead use dispose. The Dispose() method is simply a method you call manually to clean up your object. In reality, this is just another method of your class and you can call. Dispose() is the recommended naming standard. You should put all cleanup code here rather than in the Finalizer


How to call External Application through ASP.NET

Well at first attempt it will sound like, what ? ASP.NET application is processed on server side, how will you get the output?. Well remember its not always that you want to run a visual application. it can be a background application like some utility. For eg: After uploading a file you want to zip it and store it on your disk. Infact any console output emitted by your application can be read and displayed back into webbrowser

You can use your System.Diagnostics namespace to interact with system processes. Here is a small tip.


string file = Server.MapPath(@"MyApp.exe");
ProcessStartInfo info = new ProcessStartInfo(file, "otherargs");
info.RedirectStandardOutput = true;
info.UseShellExecute = false;
Process p = Process.Start(info);
// Send whatever was returned through the output to the client.

Note that the ASP.NET worker process needs to have permissions to access the external application. The most simple way to ensure this is to place it under the bin folder.