Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C# / September 2007

Tip: Looking for answers? Try searching our database.

InvalidOperationException in Process.WaitForExit

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Sangeetha - 06 Sep 2007 14:18 GMT
The requirement is to detect closing of a word document opened by a process.
There is some piece of code which has to be executed after the document is
closed.

Using Process.Start()  document is opened, I used process.WaitForExit() to
stop further execution until the document is closed.

But once the document is closed, Process.WaitForExit() throws
“InvalidOperationException-No process is associated to the object”  exception.

Even on using process.HasExited property/process.WaitForInputIdle(),same
exception is thrown.

This exception is thrown during Release as well as Debug mode.

Any idea why this exception occurs ?
Doug Semler - 06 Sep 2007 15:42 GMT
On Sep 6, 9:18 am, Sangeetha <Sangee...@discussions.microsoft.com>
wrote:
> The requirement is to detect closing of a word document opened by a process.
> There is some piece of code which has to be executed after the document is
[quoted text clipped - 12 lines]
>
> Any idea why this exception occurs ?

I don't think you are waiting on the correct Process variable.  Make
sure you aren't forgetting to assign the result of Process.Start() to
a variable of type Process.

Process p1 = new Process();
Process p2 = Process.Start("notepad.exe");

p1.WaitForExit(); <-- will throw
p2.WaitForExit(); <-- will not throw.

or....
p1.StartInfo = new ProcessStartInfo("notepad.exe");
p1.Start();
p1.WaitForExit(); <-- will not throw

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.