Exception of type 'System.Windows.Forms.AxHost+InvalidActiveXStateException' was thrown

autthapone picture autthapone · Aug 30, 2011 · Viewed 16.2k times · Source

I am getting an error in my simple project.

This is my code:

if (axZKFPEngX1.InitEngine() == 0) {
    label1.Text = "Connected";
}
else {
    label1.Text = "Connection Failed";
}

I already added reference composites AxInterop.ZKFPEngXControl and Interop.ZKFPEngXControl.

While debugging, I click the button, and a warning appears:

InvalidActiveXStateException was handled.

"Exception of type 'System.Windows.Forms.AxHost+InvalidActiveXStateException' was thrown"**

Answer

Constantin picture Constantin · Oct 14, 2011

try to call CreateControl() from your component first.