VB.Net错误:Word Web应用程序中的错误 [英] VB.Net Error: Error in Word Web Application

查看:185
本文介绍了VB.Net错误:Word Web应用程序中的错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在选项卡控件中运行Word Web应用程序,但无法执行此操作.我已粘贴我的代码以供您参考.

I am trying to run a Word Web application in a tab control but unable to do it. I have pasted my code for your kind reference.

Private Sub TabControl1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles TabControl1.SelectedIndexChanged
    If (TabControl1.SelectedIndex = 1) Then
        Dim PR As Process = Process.Start("d:\\selvi\\wordweb6\\wweb32.exe")
        PR.WaitForInputIdle()
        ''PR.Refresh()
        ''PR.WaitForExit()
        SetParent(PR.MainWindowHandle, TabControl1.TabPages(1).Handle)
        SetForegroundWindow(PR.MainWindowHandle)
        SendMessage(PR.MainWindowHandle, WM_SYSCOMMAND, SC_MAXIMIZE, 0)
    End If
End Sub


我收到以下异常错误:


I get the following exception error:

Process has exited, so the requested information is not available.



非常感谢您的帮助.



Any help is greatly appreciated.

推荐答案

这就是它.异常消息是不言自明的.但是,在询问您的问题时,您始终需要注释掉与之完全相同的代码.

您启动了某个过程,该过程开始并结束,但是您仍然具有Process PR的实例.您假定该进程仍在运行,并使用PR的实例方法之一(在Process.Start之后),而不检查该进程是否退出.退出时,您的PR方法调用无效,因此您遇到了此异常.

我不知道您为什么要处理出口.手动运行它,看看它如何工作,需要什么参数(您未提供任何参数).使用可执行文件的硬编码名称是不好的.您可能需要某种方法来计算此路径名,可能是从应用程序配置中计算出来的.您不能假定相对于您的可执行目录的任何特定位置,并且绝对不能假定任何工作(数字)目录-这取决于使用方式启动应用程序的方式.它可以从任何目录启动.

—SA
This is what it is. The exception message is self-explanatory. You always need to comment exact like of code where it is thrown when asking your Question though.

You start some process, it starts and finishes, but you still have the instance of the Process PR. You assume the process is still running and use one of the instance methods of PR (after Process.Start), without checking is the process is exited or not. When it is exited, your PR method calls are invalid, so you got this exception.

I have no idea why you process exits. Run it manually and see how it works, what parameters it requires (you did not supply any). Using hard-coded name of the executable is bad. You need some way of calculating this path name, maybe from application configuration. You cannot assume any certain location relative to your executable directory and should never assume any working (currect) directory — it depends on how uses starts your application; it can be started from any directory.

—SA


这篇关于VB.Net错误:Word Web应用程序中的错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆