We help IT Professionals succeed at work.
Get Started

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

Teenu R
Teenu R asked
on
145 Views
Last Modified: 2017-12-24
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;
    }
Comment
Watch Question
Freelance programmer / Consultant
CERTIFIED EXPERT
Commented:
This problem has been solved!
Unlock 2 Answers and 3 Comments.
See Answers
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE