I got this exception . How to solve this ? Exception :Exception of type 'System.Windows.Forms.AxHost+InvalidActiveXStateException' was thrown.

I have a windows form  and two ocx controls are  added in this form. At runtime i got this exception.I think the exception is occurred when initialize the occ controls. i attached my code below. please help me . its very urgent.


using AxVSpinAccess2Lib;
using AxVSpinLib;
namespace VspinCentrifugeIntegration
{
    partial class frmInstrument
    {
        /// <summary>
        /// Required designer variable.
        /// </summary>
        private System.ComponentModel.IContainer components = null;

        /// <summary>
        /// Clean up any resources being used.
        /// </summary>
        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
        protected override void Dispose(bool disposing)
        {
            try
            {

                if (disposing && (components != null))
                {
                    components.Dispose();
                }
                base.Dispose(disposing);
            }
            catch
            {
            }

        }

        #region Windows Form Designer generated code

        /// <summary>
        /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {
           
                System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(frmInstrument));
                this.axVSpin1 = new AxVSpinLib.AxVSpin();
               // axVSpin1.CreateControl();
                this.axVSpinAccess21 = new AxVSpinAccess2Lib.AxVSpinAccess2();
                this.performanceCounter1 = new System.Diagnostics.PerformanceCounter();
                ((System.ComponentModel.ISupportInitialize)(this.axVSpin1)).BeginInit();
                ((System.ComponentModel.ISupportInitialize)(this.axVSpinAccess21)).BeginInit();
                ((System.ComponentModel.ISupportInitialize)(this.performanceCounter1)).BeginInit();
                this.SuspendLayout();
               
                //
                // axVSpin1
                //
                this.axVSpin1.CausesValidation = false;
                this.axVSpin1.Enabled = true;
                this.axVSpin1.Location = new System.Drawing.Point(46, 23);
                this.axVSpin1.Name = "axVSpin1";
                this.axVSpin1.OcxState = ((System.Windows.Forms.AxHost.State)(resources.GetObject("axVSpin1.OcxState")));
                this.axVSpin1.Size = new System.Drawing.Size(100, 50);
                this.axVSpin1.TabIndex = 0;
                this.axVSpin1.Visible = false;
                //
                // axVSpinAccess21
                //
                this.axVSpinAccess21.CausesValidation = false;
                this.axVSpinAccess21.Enabled = true;
                this.axVSpinAccess21.Location = new System.Drawing.Point(64, 89);
                this.axVSpinAccess21.Name = "axVSpinAccess21";
                this.axVSpinAccess21.OcxState = ((System.Windows.Forms.AxHost.State)(resources.GetObject("axVSpinAccess21.OcxState")));
                this.axVSpinAccess21.Size = new System.Drawing.Size(100, 50);
                this.axVSpinAccess21.TabIndex = 1;
                this.axVSpinAccess21.Visible = false;
                //
                // frmInstrument
                //
                this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
                this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
                this.ClientSize = new System.Drawing.Size(231, 151);
                this.Controls.Add(this.axVSpinAccess21);
                this.Controls.Add(this.axVSpin1);
                this.Name = "frmInstrument";
                this.Text = "frmInstrument";
                ((System.ComponentModel.ISupportInitialize)(this.axVSpin1)).EndInit();
                ((System.ComponentModel.ISupportInitialize)(this.axVSpinAccess21)).EndInit();
                ((System.ComponentModel.ISupportInitialize)(this.performanceCounter1)).EndInit();
                this.ResumeLayout(false);
           

        }

        #endregion

        private AxVSpin axVSpin1;
        private AxVSpinAccess2 axVSpinAccess21;
        private System.Diagnostics.PerformanceCounter performanceCounter1;
    }
Teenu RAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

AndyAinscowFreelance programmer / ConsultantCommented:
       /// Required method for Designer support - do not modify
        /// the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {
           
                System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(frmInstrument));
                this.axVSpin1 = new AxVSpinLib.AxVSpin();
              // axVSpin1.CreateControl();


Have you modified the file yourself?  Also see the comment supplied by system.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
sarabandeCommented:
there are no google results neither for AxVSpinAccess2Lib, nor AxVSpinLib, nor AxVSpin. so it must be a private class.

can you post the source code for this class?

from exception it seems that the class is managed by class AxHost. if you google for InvalidActiveXStateException you will find solutions which tell that you need o call method CreateControl in order to get the active x control into a correct state. so the question is why you commented the call to CreateControl (see also comment of Andy)?

Sara
0
AndyAinscowFreelance programmer / ConsultantCommented:
Probably modifying the file (despite warnings not to) is causing the problem.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C#

From novice to tech pro — start learning today.