Dll Error, then Show your Exception

Dll Error........

In my previous blog,i am telling you how to create a dll file.
You can write your method on that dll and link it for your app.
And when you distribute your app you also provide your dll with your app.

But if any body delete your dll then??
The window will occur that "yourapp.exe is not responding"
please tell it to microsoft or what ever....



Do you like this window???- Obiously not!
So make your own exception to show this Error.

Now i tell you how to overcome this problem & for your help
I upload here a simple source code!

The process is too eassy to implement.
 
Create an object of your dll in your form when loading that.
because if it is present then form load successfull otherwise am exceptin will genarete
that throws the dll file is missing.

Now we write the exception.
Open your Program.CS file  & modify your main() as:

 static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
try
{
Application.Run(new Form1());
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}

If ther is any exception in form1 then it's throws that.
You can modify your exception as you wish.

Now if the dll file is missing/rename/fake then your exception will shows that.
As profit "Not Responding" window will never appear.So user will be happy. :-)

If you have many dll during loading use backgroundworker & progressbar, so your app will attractive & user will appritiate your work.

I hope this blog will help you.
Thank you!