Click here to Skip to main content
15,881,715 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
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.
Posted
Updated 11-Apr-11 0:49am
v2
Comments
Slacker007 11-Apr-11 6:50am    
Edited for readability. Added tags.

1 solution

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
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900