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
Solved

Process.Start and issues with psapi.dll

Posted on 2010-08-25
9
713 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
  • 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
Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

 
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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Sometimes people don't understand why download speed shows differently for Windows than Linux.Specially, this article covers and shows the solution for throughput difference for Windows than a Linux machine. For this, I arranged a test scenario.I…
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…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

789 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