Set-Wait-State("general") gives a run-time error

Posted by jquerijero on 09-Oct-2009 09:49

Has anyone else seen this error when a .w calls the SET-WAIT-STATE before the .w is shown, and the .w is called from a .NET window?

System.InvalidCastException: Unable to cast object of type 'System.Windows.Forms.Form' to type 'Progress.Windows.Form'.
   at Progress.ClrBridge.ClrApi.SetWaitState(Object source, Int32 disableForm)
   at Progress.ClrBridge.BrgClrFromPro.SetWaitState(BrgClrFromPro* , Int32 , Int32 )
   at Progress.ClrBridge.BrgClrToPro.HandleUIEvent(Object , Object , Int32 , String , Int32 , Int32 )

All Replies

Posted by jquerijero on 19-Oct-2009 10:02

My co-worker stumbled upon the solution which is scary specially for those people who like to use USING.

Base form

USING Progress.Windows.Form

MyBaseForm INHERITS Form

Derived form

USING System.Windows.Forms.*

MyDerivedForm INHERITS MyBaseForm

Notice the System namespace. When that namespace is added, the form is compiled as System.Windows.Forms.Form instead of Progress.Windows.Form which is wrong. After removing the namespace from the USING block, the Set-Wait-State error went away.

Posted by Laura Stern on 20-Oct-2009 15:02

This has been fixed for 10.2B FCS.

Posted by Laura Stern on 26-Oct-2009 10:26

Just wanted to be sure - I believe there is a mis-statement here.  You stated that adding the USING in the derived form avoided the error.  But this USING statement should have no effect, since MyDerivedForm is not in the System.Windows.Forms namespace (regardless of the namespace of MyBaseForm).

Derived form

USING System.Windows.Forms.*

MyDerivedForm INHERITS MyBaseForm

I think you meant:

Base form

USING System.Windows.Forms.*

CLASS MyBaseForm INHERITS Form:

Derived form

CLASS MyDerivedForm INHERITS MyBaseForm:

i.e., If you use USING System.Windows.Forms.Form instead of Progress.Windows.Form in MyBaseForm then the error occurs (since the error only happens when the form is not a Progress.Windows.Form).  Please confirm if that's what you meant.  Thanks.

Laura

Posted by jquerijero on 26-Oct-2009 12:09

Laura,

Thanks for the reply. What I stated earlier is correct.

The base form is Progress.Windows.Form

USING Progress.Lang.*.
USING Progress.Windows.Form.

CLASS WindowBase INHERITS Form   :

The derived form HAS the "USING System.Windows.Form.*" which shouldn't have any effect on the actual type of derived form.  But if you look at the exception, it is saying the derived class is of type System.Windows.Forms.Form instead of Progress.Windows.Form. This tells me that the derived form was compiled using the wrong data type.

System.InvalidCastException: Unable to cast object of type 'System.Windows.Forms.Form' to type 'Progress.Windows.Form'.

After removing "USING System.Windows.Form.*" entry from the derived class. The Exception went away.

Posted by Laura Stern on 26-Oct-2009 12:49

Thanks for replying.  Hmmm.  I'll have to look into this.

Laura

Posted by Laura Stern on 29-Oct-2009 13:51

I just wanted to complete this thread.  I came up with a small example that does indeed generate the InvalidCastException in 10.2B Beta when SET-WAIT-STATE is called.  The problem is indeed fixed in 10.2B FCS.  However, relative to the USING statement question, I cannot duplicate what you saw there.  Having or not having the "USING System.Windows.Form.*" in the derived class does not have any effect on whether this error occurs or not - as it shouldn't.  So that remains a mystery!

This thread is closed