When i was converting VB to VB.NET, i found the error InvalidActiveXStateException.
My program ahs a main form and many sub forms, and while I am checking the sub forms, one of them has this error and can not open that form, but the other forms can be opened correctly.
The code is the same. Why i can not open that form?
I had been researched from internet and most of people said that :
((System.ComponentModel.ISupportInitialize)(this.ax)).BeginInit();
this.Controls.Add(ax);
((System.ComponentModel.ISupportInitialize)(this.ax)).EndInit();
but it seem C# not VB.NET and i dont know when can i found the name of ax in my program.
here is part of my program code.
Public Sub mnu_dceedc_enq_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles mnu_dceedc_enq.Click
If bolCheckSecurity("dcs_eedc_enq") Then
Unload_frm()
DCformfun = mnu_dceedc_enq.Name
frmDCEEDC.Show()
End If
End Sub
Private Sub chkfiltercase_CheckStateChanged(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles chkfiltercase.CheckStateChanged
'20090401
'fgdetail_Click
Call ShowFolderDetail(fgdetail.get_TextMatrix(fgdetail.Row, 1), fgdetail.get_TextMatrix(fgdetail.Row, 2), CShort(txtbatchno.Text))
End Sub
When I open a sub form, it will start from nu_dceedc_enq_Click and then go to chkfiltercase_CheckStateChanged but when ran into Call ShowFolderDetail, it auto returns back to form.show() and the exception occurs.
Why does this error occur and how can I solve it?
Update after testing:
I tried commenting all the Sub chkfiltercase_CheckStateChanged and the form occur success and I am try to test whether it will occur others or not.
Part of what the standard conversion/usage of active x controls does is create a state for the control. This state is not always set/created correctly and will sometimes get changed when you run the application in the debugger. When the state is invalid, this exception is thrown. I generally try to replace the active x control with a .net control (either one that already exists or creating an equivalent).
Supposedly some of the commercal alternatives to the standard tool will avoid this problem.