System.Windows.Forms.AxHost.InvalidActiveXStateException was unhandled

荒凉一梦 提交于 2019-12-01 01:24:11

问题


I am continuously struggling with this exception

An unhandled exception of type 'System.Windows.Forms.AxHost.InvalidActiveXStateException' occurred in AxInterop.SBXPCLib.dll

any help please, am i missing some thing.


回答1:


Try this,it will solve your problem:

For each and every active x control, it is needed to create it first, so that all the events and handles should be initialized.

So try this:

axMDocView1.CreateControl()




回答2:


The answer by Vishal 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

axMDocView1.CreateControl();
axMDocView1.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.



来源:https://stackoverflow.com/questions/22727633/system-windows-forms-axhost-invalidactivexstateexception-was-unhandled

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!