本文介绍了如何修复它Sysytem.windows.form AxHost.InvalidActiveXStateException"通过的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 M使用下面的代码,但我得到了Sysytem.windows.form AxHost.InvalidActiveXStateException错误.. M using folloing code but I get Sysytem.windows.form AxHost.InvalidActiveXStateException error..OpenFileDialog openFileDialog1 = new OpenFileDialog(); //openFileDialog1.InitialDirectory = Application.StartupPath + "\\Reports\\"; openFileDialog1.RestoreDirectory = true; openFileDialog1.Filter = "Pdf Files|*.pdf"; try { if (openFileDialog1.ShowDialog() == DialogResult.OK) { AxAcroPDF a = new AxAcroPDF(); a.LoadFile(Application.StartupPath + "\\Reports\\"); a.Show(); } } catch (ArgumentException ex) { MessageBox.Show(ex.Message.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } catch (Exception ex) { MessageBox.Show(ex.Message.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } 推荐答案 AxAcroPDF.CreateControl() [已解决]系统.Windows.Forms.AxHost.InvalidActiveXStateException未处理 [ ^ ] AxHost.InvalidActiveXStateException [ ^ ] AxAcroPDF a = new AxAcroPDF(); a.LoadFile(Application.StartupPath + "\\Reports\\"); a.Show(); 您的变量/实例名为 a 我认为你需要尝试这个。 Your Variable/Instance is named aI think you need to try this instead.a.CreateControl()a.LoadFile(Application.StartupPath + "\\Reports\\");a.Show(); AxAcroPDF是控制类型, a 是实例,它将与选定的PDF文档一起显示。 错误:AxAcroPDF is the Type of Control, and a is the Instance, which will be shown with the selected PDF document.Wrong: axAcroPDF1.CreateControl(); 正确Right a.CreateControl(); 如果第一个问题中的代码同时没有改变。 ...即使这是答案标记为已解决。不要打那个东西......;) c.u。If the Code in the first Question doesn´t changed meanwhile....even if this is Answer is marked as solved. Don´t hit me with that thing... ;)c.u. 这篇关于如何修复它Sysytem.windows.form AxHost.InvalidActiveXStateException"通过的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 10-26 22:48