Hi,
I have written an application in which I am using a third party
control. I have declared the control using a DIM statement in the
Declarations Section of the application, so that it is available to
all functions and sub-routines in the application. Everything works
fine on my development PC.
If I install the application onto a second PC, which does not have the
third party control installed, then I get problems (which you'd
expect!). The application dies immediately with a "Application has
generated an exception that could not be handled" messagebox.
Please can somebody tell me how I can handle this error. I can handle
errors in functions and sub-routines, but I don't know how to handle
an error that is coming from the declarations section!
Thanks
Terry - 06 Mar 2008 17:41 GMT
my guess is that your declaration is something like:
dim x as new y
change it to dim x as y
and in your classes Sub New()
add a try catch to instanciate it
Try
x = new y
etc.
You can also add an UnhandeledEvent handeler to your application level events.

Signature
Terry
> Hi,
> I have written an application in which I am using a third party
[quoted text clipped - 13 lines]
>
> Thanks
Workaholic - 07 Mar 2008 09:48 GMT
Thanks to everyone for their input. Terry's suggestion of making the
declaration (DIM) in the declarations section but then assigning it
within a function (within a TRY block) worked perfectly. Many thanks
kimiraikkonen - 06 Mar 2008 17:46 GMT
> Hi,
> I have written an application in which I am using a third party
[quoted text clipped - 13 lines]
>
> Thanks
If i understood correctly, you do not need to handle the exception in
declaration area (Dim x As New xxx....). Just handle it when you call
this library's one of functions using Try-Catch Block.
I mean;
(Untested)
Public Class Form1
Dim control As New <your_control>
Public Sub <Function>(........)
Try
' Code to be done
Catch
'...Msgbox is good
Msgbox("Error",.....)
Finally
' ...Optional
End Try
End Sub
The code sample is demo, modify and correct as you wish if you need.
Handle exception when you call a function of your library, but this
not a solution, i'd install the library on target machine not to have
an exception though.
Herfried K. Wagner [MVP] - 06 Mar 2008 23:51 GMT
"Workaholic" <workaholicme@hotmail.com> schrieb:
> I have written an application in which I am using a third party
> control. I have declared the control using a DIM statement in the
[quoted text clipped - 6 lines]
> expect!). The application dies immediately with a "Application has
> generated an exception that could not be handled" messagebox.
VB Application Model:
'My.Application.UnhandledException'.
Windows Forms:
'System.Windows.Forms.Application.ThreadException'.
[
Console applications:
'System.AppDomain.UnhandledException'.
ASP.NET:
'System.Web.HttpApplication.Error' event in "Global.asax".
]

Signature
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>