Solved

Process.Start and issues with psapi.dll

Posted on 2010-08-25
9
716 Views
Last Modified: 2012-05-10
I have C# Windows form application that I have running on HP Thin Clients.

The application uses a COM interface to retrieve data from a server and occasionally the app will have connectivity issues requiring it to be restarted.

To solve this I included code that restarts the application using
   Process.Start(Application.ExecutablePath)
   Application.Exit();
but I started getting intermittent errors such as "This application failed to start because psapi.dll was not found. Re-installing the application may fix this problem."

I thought this may be caused by the app starting a new copy before the old was closed and so I changed the code to restart the terminal using
Process.Start("ShutDown", "-r -t 01 -f");
but the system will still hang with the same messages.

Reading through the net I found that Process.Start uses psapi.dll but I cannot work out why this issue is occurring or what I can do to avoid it. It is especially annoying as the error will only occur intermittently.

Any help would be appreciated
0
Comment
Question by:Michael74
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
  • 2
9 Comments
 
LVL 16

Expert Comment

by:Vikram Singh Saini
ID: 33528421
Hi,

Try this way:

Process.Start(Application.ExecutablePath +"\\psapi.dll")

Regards,
VSS
0
 
LVL 23

Author Comment

by:Michael74
ID: 33528487
????
The application does not use psapi.dll, your suggestion only results in an error.

The errors are happening intermittently when Process.Start() is called and changing the process started did not solve the issue.
0
 
LVL 16

Expert Comment

by:Vikram Singh Saini
ID: 33528520
Hi,

Sorry for that. It was in hurry.

Please check link:
http://pcsupport.about.com/od/findbyerrormessage/a/psapi-dll-not-found-missing-error.htm

Regards,
VSS
0
Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

 
LVL 23

Author Comment

by:Michael74
ID: 33528552
Have already read through that article but it did not help.

The Terminal does not have a virus or adware, the registry has been cleaned, it has current windows updates and no drivers or other applications have been installed.
0
 
LVL 14

Expert Comment

by:jake072
ID: 33567307
Michael74,

I'm not sure why you would get that error, but is it possible that the multiple running copies are the problem?  If you do a Process.Start FROM your program, you will get 2 copies running...  Try making a quick app that just does a run of your program.  If that works all the time (when only 1 copy is running), then modify it to pause for a few seconds, then run your program.  Then from your program when you want to restart, call the intermediate program and kill your program, that way the intermediate program will pause for a few seconds while your program shuts down, then will relaunch it.

I'm thinking you COM interface maybe causing the issue with multiple copies running.

Let me know,

Jake
0
 
LVL 23

Author Comment

by:Michael74
ID: 33583511
Jake

This was my original thought when I first had the issue. To test this I changed the command from
Process.Start(Application.ExecutablePath);
to
Process.Start("ShutDown", "-r -t 01 -f");
Testing showed that the terminal would successfully restart and as the application was in the startup processes everything would return to normal.
Not the best solution but it worked...or so I thought...as after approx 4 days of running the same error reoccurred.
When I investigated psapi.dll I saw that this is the windows dll called by process.start
0
 
LVL 14

Accepted Solution

by:
jake072 earned 500 total points
ID: 33586162
Michael74,

If your code runs in a terminal and can detect when it needs to restart, perhaps you should set it up as a service, that way, you can simply tell your program to quit, and windows will restart it for you (if you set it up as a service).

I know it's not what your looking for, but sometimes you need to do "hacks" like this =)

Otherwise, without something to test or some code to look at I can't be of much more help...

Jake
0
 
LVL 23

Author Comment

by:Michael74
ID: 33593328
Thanks Jake

I would post the code but it would not work without access to our servers.

As you suggest I will have to work around the problem. The service sounds like a good idea

Cheers
0

Featured Post

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
C# XML Get Values 4 53
Using/Import statement in code doesn't see reference of dll just added. 3 40
Return array 3 35
Example code 13 42
This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…
Suggested Courses

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question