如何修复它Sysytem.windows.form AxHost.InvalidActiveXStateException"通过 [英] How to fix it error that Sysytem.windows.form AxHost.InvalidActiveXStateException " was through
问题描述
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);
}
推荐答案
Hello Dipika。
我想你想在Acrobat中打开PDF文件吗?
那段代码对我来说似乎没问题。但是消息说它不是正确[情绪;]]状态。
如果只需要显示PDF文件,请使用.NET内置Webrowser和将该文件传递给该控件。我对ActiveX Interop感到非常沮丧。
也许我没有解决Code问题但是对于PDF阅读器来说不再需要那个任务了。
cu一个快乐的编码
Hello Dipika.
I think you want to Open the PDF-File inside Acrobat ?
That Code seems allright to me. But the message says it was not in the right [mood ;)] State.
If it is only needed to display the PDF file use the .NET builtin Webrowser and pass that file to that Control. Ist so frustrating with ActiveX Interop.
Maybe i didnt solved that Code issue but for a PDF Reader there is no need for that task anymore.
c.u. an happy coding
对于每个活动的x控件,首先需要创建它,以便初始化所有的事件和句柄。
试试.. :)
For each and every active x control, it is needed to create it first, so that all the events and handles should be initialized.
try.. :)
AxAcroPDF.CreateControl()
[已解决]系统.Windows.Forms.AxHost.InvalidActiveXStateException未处理 [ ^ ]
AxHost.InvalidActiveXStateException [ ^ ]
再次问好。< br $> b $ b
Hello again.
AxAcroPDF a = new AxAcroPDF();
a.LoadFile(Application.StartupPath + "\\Reports\\");
a.Show();
您的变量/实例名为 a
我认为你需要尝试这个。
Your Variable/Instance is named a
I 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"通过的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!