Click to See Complete Forum and Search --> : How to display a message box, if any dll is missing in bin directory


itchock
July 31st, 2008, 02:04 AM
IDE : VS 2005 VISUALBASIC.NET, Platform : .NET 2.0,


Hi,

In my project, i have many dll file in the bin directory. If any dll is deleted or missing. which is required by the project. Then it shows the below two message boxes.

1. Exception has been thrown by the target of an invocation.
2. Object variable or With block variable not set.

I need to give a custom MessageBox by specifying the name of the dll missing like "ActiveImage.Dll is missing, Please contact support" instead of the above two MessageBoxes. How to solve this. Thanks for any support.

Thanks and Regards,
V.Chock.

javajawa
July 31st, 2008, 02:38 AM
In the code, you need to catch the exceptions (example code below). If you've got losts of code, I might consider doing a check at the initialisation of the program by call some method from each of the DLLs.
Try
'Main Code Here
x = 1 / 0
Catch ex as Exception
MsgBox("Oh Dear! An Error" & vbNewLine & "Error Info: " & ex.Message)
End Try


*EDIT*: I've just discovered that 1 / 0 does not result in an error. That's, actually, really annoying, as (strictly speaking) the answer it gives could be wrong.

DataMiser
July 31st, 2008, 02:53 AM
*EDIT*: I've just discovered that 1 / 0 does not result in an error. That's, actually, really annoying, as (strictly speaking) the answer it gives could be wrong.

Interesting... I remember in the old dos days a system would Halt on 1/0. I actually lost a program due to such an error in a basic program. Turned out to be a misspelled variable name in a division statement that triggered the div by 0 error and afterwards what used to be several k in code was 14 bytes with only part of the first comment remaining. Luckily I had a recent backup.