On Mon, 6 May 2002 10:18:44 -0400, Curtis Koppang <[EMAIL PROTECTED]> wrote:
I was hoping there was another solution. I'm going with your suggestion.
Thanks for the reply...
KC
>I don't find this suprising. We use a two phase construction pattern to
>work around issues like this. The constructor does stuff which gets the
>class up an running (at a system level) but does not depend on many (as
>close to zero as possible) external dependencies. Then you call a custom
>constructor which does the application level code - which is in ~some~
sense
>business logic. I believe this is the model other frameworks (i.e. MFC)
>have recommended.
>
>So the code which creates the form would look something like the
>following...
>
>class Controller
>{
> MainForm myMainForm;
>
> public Form GetMainForm()
> {
> // could throw and execption, but if it does you won't have class
> myMainForm = new MainForm();
>
> try
> {
> // do the application logic
> myMainForm.SecondaryConstructor();
> }
> finally
> {
> // if it fails we need to blow away the instance
> myMainForm = null;
> }
>
> return myMainForm;
> } // ShowForm
>} // Controller
>
>
>Hope this helps,
>curt
>
>
>----- Original Message -----
>From: "K C" <[EMAIL PROTECTED]>
>To: <[EMAIL PROTECTED]>
>Sent: Monday, May 06, 2002 8:58 AM
>Subject: [DOTNET] Close() in mainform constructor
>
>
>> In my application the constructor of the main form goes through its'
usual
>> routine, if something critical happens like a missing important file, I
>> call the Close() method of the form to quit immediately. I get a dispose
>> exception, I can't seem to quit the application while im in the
>> constructor. Anyone know the best way to do this?
>>
>> Thanks
>> KC
>>
>> You can read messages from the DOTNET archive, unsubscribe from DOTNET,
or
>> subscribe to other DevelopMentor lists at http://discuss.develop.com.
>>
>>
>
>You can read messages from the DOTNET archive, unsubscribe from DOTNET, or
>subscribe to other DevelopMentor lists at http://discuss.develop.com.
You can read messages from the DOTNET archive, unsubscribe from DOTNET, or
subscribe to other DevelopMentor lists at http://discuss.develop.com.