开发者

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

开发者 https://www.devze.com 2023-03-31 12:09 出处:网络
I am getting an error in my simple project. This is my code开发者_运维百科: if (axZKFPEngX1.InitEngine() == 0) {

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"**


try to call CreateControl() from your component first.


The answer by Constantin is Fulfill your requirement but here I wanted to add one more thing with it. If you wanted to reflected this changes via all the threads and not only by calling thread (in multiple thread scenario) then use

CreateControl();
InitWB();
SkinAllThreads();

Actually in multiple threading scenario if your skinning code is in one of the thread then may be it is not reflect change for other current thread so at that time this code is play important role in it.

Here is some Documents I mention kindly go through it for reference :

  1. initwb() method
  2. DirectSkin other Methods
  3. Adding Direct Skin to Application
0

精彩评论

暂无评论...
验证码 换一张
取 消