locked
InvalidActiveXStateException RRS feed

  • Question

  • I have a program I wrote in VB6 that I was letting VB2008 update.  It won't run due the following:

     

    An error occurred creating the form. See Exception.InnerException for details.  The error is: Exception of type 'System.Windows.Forms.AxHost+InvalidActiveXStateException' was thrown.

     

    "AxInterop.MSFlexGridLib"   at AxMSFlexGridLib.AxMSFlexGrid.Clear()    at SLOCOM.frmWaveform.cmbProfileSelect_SelectedIndexChanged(Object eventSender, EventArgs eventArgs)    at System.Windows.Forms.ComboBox.OnSelectedIndexChanged(EventArgs e)    at System.Windows.Forms.ComboBox.set_SelectedIndex(Int32 value)    at System.Windows.Forms.ComboBox.set_Text(String value)    at SLOCOM.frmWaveform.InitializeComponent()    at SLOCOM.frmWaveform..ctor()

     

    The offending code, according to the IDE, is...

     

    grdToolProfile.Clear() ' Clear grid for new values

     

    I also found this in the View Detail dialog.  However, I fail to see how this helps since all I'm doing at this point in the code is clearing the grid contents.

     

    In order to evaluate an indexed property, the property must be qualified and the arguments must be explicitly supplied by the user.

     

    What could cause such a non-descript error?

    Tuesday, August 12, 2008 10:05 PM

All replies

  • Try replacing the Flexgrid with a datagrid control or try this link http://support.microsoft.com/?id=318597

     

     

    Code Snippet
    You must have a design-time license to use Visual Basic 6.0 ActiveX controls. These errors occur because the system registry does not contain the design-time license information. When you upgrade a project that contains Visual Basic 6.0 ActiveX controls, or when you try to use Visual Basic 6.0 ActiveX controls on a form in Visual Studio 2005 or in Visual Studio .NET, those controls must be installed and licensed on the target system.

    Visual Studio 2005 and Visual Studio .NET do not install the license information for Visual Basic 6.0 ActiveX controls unless the Visual Basic 6.0 controls are installed on the computer that is running Visual Studio 2005 or Visual Studio .NET. This behavior may occur if Visual Basic 6.0 was never installed on the computer.

    You do not receive these errors on a computer on which both Visual Basic 6.0 and Visual Studio 2005 or Visual Studio .NET are installed because Visual Basic 6.0 installs the components and registers the licenses.

    Back to the top

    RESOLUTION

    To resolve this problem, you must install the .ocx files for the ActiveX controls on the computer before you upgrade the project or before you use Visual Basic 6.0 ActiveX controls on a form in Visual Studio 2005 or in Visual Studio .NET. To do this, use one of the following methods:

    Install Visual Basic 6.0 on the computer that is running Visual Studio 2005 or Visual Studio .NET.

    Add the licensing keys to the registry.

     

     

     
    MS Flex Grid in Vb.net.Since MS- Flex grid is a Com component. You need to Convert that first into dotnet component using AxImp.exe(from command line) or if you are using Visual Studio.Net Add reference to the MS-flex Grid COM component.Visual studio automatically converts that into .Net component. For more Details of how to use COM component check your MSDN documentation.

     
    Windows Forms ActiveX Control Importer (Aximp.exe)  http://msdn.microsoft.com/en-us/library/8ccdh774(VS.80).aspx

    The ActiveX Control Importer converts type definitions in a COM type library for an ActiveX control into a Windows Forms control.

    Windows Forms can only host Windows Forms controls — that is, classes that are derived from Control. Aximp.exe generates a wrapper class for an ActiveX control that can be hosted on a Windows Form. This allows you to use the same design-time support and programming methodology applicable to other Windows Forms controls.

     
     

     

    Tuesday, August 12, 2008 10:28 PM
  •  

    >"You do not have a license to use this control"

     

    I'm not receiving any license error, nor is the upgrade wizard failing.

     

    The statement below is completely false (unless there is some other detail involved), as I do IN FACT have both on the same machine.

     

    "You do not receive these errors on a computer on which both Visual Basic 6.0 and Visual Studio 2005 or Visual Studio .NET are installed..."

     

    However, does the order of the install matter?  I added VB6 after installing 2008.  Does it refer to versions other than 2008?  Would I need to re-install 2008 in order for it to find this?

     

    I did eventually find AXIMP in the Microsoft SDKs\Windows\v6.0A\bin folder.  The OCX is named MSFLXGRD.OCX.  It ran OK and claimed it generated an "assembly".

     

    Yet, it still isn't any different.  Same error in the same place. 

    Thursday, August 14, 2008 3:25 PM
  • Hi TexasTall,

     

    The order of installing doesn't affect this. Can you directly use this control in a new windows project? As far as I know, some ActiveX control isn't supported in the .NET enviroment. You can download this book and read Chaper13 about Upgrading ActiveX Controls and Components.

     

    Best regards,

    Riquel

    Friday, August 15, 2008 12:00 PM
    Moderator
  • We are changing the issue type to “Comment” because you have not followed up with the necessary information. If you have more time to look at the issue and provide more information, please feel free to change the issue type back to “Question” by editing your initial post and changing the radio button at the top of the post editor window. If the issue is resolved, we will appreciate it if you can share the solution so that the answer can be found and used by other community members having similar questions. Thank you!

    Monday, August 18, 2008 4:34 AM
    Moderator
  •  

    >We are changing the issue type to “Comment” because you have not followed up with the necessary information.

     

    What "necessary information"?  I see no request for anything additional nor do I see any concrete resolution.

     

    >Can you directly use this control in a new windows project?

     

    Yes, without any complaint.

     

    Additionally, I"ve added the control as a reference in the project and used "Imports" without any difference.

     

    >...we will appreciate it if you can share the solution ...

     

    I'll be happy to, once (if) there is one.  You might note the detail I included with what I did find on 14 Aug.

     

    >You can download this book and read Chaper13 ...

     

    There is no chapter 13 nor any other chapter:  "We apologize for the inconvenience, but the location you are seeking cannot be found."  http://msdn.microsoft.com/en-us/ms123402.aspx?missingurl=%2fvbrun%2fstaythepath%2fadditionalresources%2fupgradingvb6%2fchapter13.pdf

     

    It appears it is available for D/L at:  http://www.microsoft.com/downloads/thankyou.aspx?familyId=94baac98-6a0a-4fbb-9cc3-2534b671c299&displayLang=en

    Wednesday, August 20, 2008 3:47 PM
  • Hi TexasTall,


    I change the thread state to comment because you don't follow up this thread with the required information about this issue for three days. I also notify you if you focus on this issue, you can give us the more information to discuss it further.

    Also note that I don't tell you to directly read the chapter13 in my post. Just tell you to download this book and read it.  You can download it by clicking Entire Book in that web page.


    Best regards,

    Riquel

    Friday, August 22, 2008 8:13 AM
    Moderator
  • Hi TexasTall,

    I check the explanation of this exception in MSDN: The exception that is thrown when the ActiveX control is referenced while in an invalid state. The public properties and methods of an ActiveX control can only be referenced after the ActiveX control has been instantiated and initialized completely. Maybe you need to check InitializeComponent subroutine to ensure that the code doesn't refer the property before its instantiation and initialization. Also read this thread about the same issue.


    Best regards,
    Riquel
    Friday, August 22, 2008 10:17 AM
    Moderator
  • > Also note that I don't tell you to directly read the chapter13 in my post.  Just tell you to download this book

     

    You can note that you didn't tell me NOT to.  When I see a link on a page that says Chapter 13, there is a reasonable expectation there is something at the end of that link.  Otherwise, why have it.  This is just a "bridge to nowhere"...

     

    You still haven't told me what information you think is missing. 

     

    This post  (PostID=701869&SiteID=1) doesn't tell me anything about where it should go.  I cannot find any place in the code where auto complete picks up "createcontrol" for my control.  The other post states he has no GUI and I have no idea what he is doing.

     

    YourActivexControl.CreateControl();

     

    I replaced the control with the version in the toolbox with no different result.  What I don't understand is that I can pick the control off the toolbox and use it.  But, the "wizard" won't convert my working VB6 code.  I even replaced the MSFlexGrid with MSHFlexGrid.  The result is the same.

     

    So, nothing has yet addressed this issue.

    Friday, September 5, 2008 10:17 PM
  • I got this exact same error when trying to convert Kofax ImageControls ActiveX VB6 demo to VB .NET 3.5. In my case there was code in the form resize event that was firing off before the form was initialized. since i did an upgrade from VB6 code through VS2008 the following warning was included in the code.

        'UPGRADE_WARNING: Event frmMain.Resize may fire when form is initialized. Click for more: 'ms-help://MS.VSCC.v90/dv_commoner/local/redirect.htm?keyword="88B12AE1-6DE0-48A0-86F1-60C0686C026A"'

    which basically says,

    In Visual Basic 6.0, events for a form or control were not raised until the form was finished loading. In Visual Basic 2008, the InitializeComponent method handles the initialization of the form and its controls; the order in which objects are initialized cannot be modified. In some cases, this may cause events to be raised during initialization. If the event handler references other components that have not yet been initialized, this could cause a run-time error.



    • Proposed as answer by SMD- Monday, November 15, 2010 9:04 PM
    Thursday, November 20, 2008 8:40 PM
  • Read the chapter12 in the above book(download it). The event order is one reason here.

    A subtle difference between Visual Basic 6 and Visual Basic .NET is that some events do not fire in the same relative order. For example, in Visual Basic 6 the Load event is the first event you expect to fire. This is not true for Visual Basic.NET, however, where the Resize event occurs before the Load event. Also, depending on the control properties you set at design time, a number of other events can occur before the Load event. Table 12-3 lists the events that can occur before the Form.Load event.


    Tuesday, November 25, 2008 9:50 AM
    Moderator
  • TexasTall,  I realize this is an older posting but I have been headed down the same road you seem to have experienced.  We have 2 vb6 ActiveX controls which we are attempting to use in a WPF Application.  We have followed all the steps to create the Interop libraries needed and the ActiveX controls do actually run in a Windows Forms application.  However, when we put them into the WPF applcation one seems to work while the second does not.  I have the CreateControl call on both but the second gives the exception on any number of the Properties for that control.

    Did you ever have any success in finding a solution?  Did you ever find out what is meant by 'InvalidActiveXState' as to a 'ValidActiveXState' and how to get from one to the other?

     

    I feel your pain .....

    -RAD


    Richard
    Wednesday, January 28, 2009 4:04 PM