arpitbandi Posted January 15, 2012 Posted January 15, 2012 hi ive an activex made in vb6. Am new to .net and attempting to use it in vb2008. i made a reference to it and added the following code to my form_load Dim mycon As New Axpass.Axiepass TextBox1.Text = mycon.GetIE() but when the form loads it gives the error, Exception of type 'System.Windows.Forms.AxHost+InvalidActiveXStateException' was thrown. i also tried to add it as a control and call the method but it returns "" as the result, though the same method if called from a vb program works fine.. plz help and guide me.. Quote
Leaders snarfblam Posted January 15, 2012 Leaders Posted January 15, 2012 Based on what Google has to say, System.Windows.Forms.AxHost.InvalidActiveXStateException is often thrown when you try to access an ActiveX component that is not fully initiailized. (It's hard to do more than guess and Google when I don't know anything about the control in question.) Not being much of an expert on the subject, if the Axpass.Axiepass class is written as an ActiveX control, I'm wondering whether the problem could be related to the fact that after you instantiate it, you don't place it in a control. After all, you don't get the exception when you place the control on a form. The empty string that gets returned could likely be a completely separate issue. I have no idea what the function does, how it does it, or whether it does it 100% right. (Just because it works in VB6 doesn't mean everything is 100% kosher. It's possible to do something incorrectly and still have it succeed in certain circumstances.) You can try double-checking the ActiveX source to make sure everything looks spiffy, and you should definitely check and make sure you are using the control exactly the same in .NET that you are in VB6. Maybe there's an initialization method that needs to be called or a property that needs to be set. The .NET WinForms designer may also be setting some properties that the VB6 designer did not, or vice-versa. Quote [sIGPIC]e[/sIGPIC]
Recommended Posts