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 )
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.
This has been fixed for 10.2B FCS.
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
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.
Thanks for replying. Hmmm. I'll have to look into this.
Laura
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!