P
Phill. W
Here's another little challenge.
I have a [base] Form from which lots of others will be derived.
One of the base Form properties is a communication "channel"
to an external application. If this external application isn't running,
I want to /prevent/ the creation of the derived Form (essentially
kill the [derived] application stone dead).
I tried throwing an Exception, but being in the Form constructors,
there's nowhere I can easily catch it again, so I get the JIT Debugger
dialog - presumably my users would get something similarly unpleasant.
I even tried (gasp) Application.Exit() but that doesn't seem to work as
I thought it would - given:
[base Form class]
#Region " Windows Form Designer generated code "
Public Sub New()
MyBase.New()
'This call is required by the Windows Form Designer.
InitializeComponent()
'Add any initialization after the InitializeComponent() call
Try
ConnectToExternalApp()
Catch ex as MyException
Me.Close()
Me.Dispose()
Application.Exit()
End Try
End Sub
Even with the above, execution resumes in the Sub New() of the
derived Form, although that immediately bombs out with an
ObjectDisposedException - which I can't seem to catch.
Any Suggestions?
TIA,
Phill W.
I have a [base] Form from which lots of others will be derived.
One of the base Form properties is a communication "channel"
to an external application. If this external application isn't running,
I want to /prevent/ the creation of the derived Form (essentially
kill the [derived] application stone dead).
I tried throwing an Exception, but being in the Form constructors,
there's nowhere I can easily catch it again, so I get the JIT Debugger
dialog - presumably my users would get something similarly unpleasant.
I even tried (gasp) Application.Exit() but that doesn't seem to work as
I thought it would - given:
[base Form class]
#Region " Windows Form Designer generated code "
Public Sub New()
MyBase.New()
'This call is required by the Windows Form Designer.
InitializeComponent()
'Add any initialization after the InitializeComponent() call
Try
ConnectToExternalApp()
Catch ex as MyException
Me.Close()
Me.Dispose()
Application.Exit()
End Try
End Sub
Even with the above, execution resumes in the Sub New() of the
derived Form, although that immediately bombs out with an
ObjectDisposedException - which I can't seem to catch.
Any Suggestions?
TIA,
Phill W.