Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / VB.NET / March 2008

Tip: Looking for answers? Try searching our database.

Error Handling in Declarations Section

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Workaholic - 06 Mar 2008 17:27 GMT
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/>


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.