Avatar of Teenu R
Teenu R

asked on 

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;
    }
C#

Avatar of undefined
Last Comment
AndyAinscow

8/22/2022 - Mon