Solved

Process.Start and issues with psapi.dll

Posted on 2010-08-25
9
708 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
Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all 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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
C# Single Form 8 42
C#  Radio button search for Date not DateTime 4 46
MediaHelp 4 21
MMC - Computer Management / Display Properties 3 10
Can I legally transfer my OEM version of Windows to another PC?  (AKA - Can I put a new systemboard in my OEM PC?) Few of us are both IT and legal experts but we all have our own views of Microsoft's licensing rules and how they apply.  There are…
Issue: Unstable cursor in Windows XP and Windows runs extremely slow in that any click will bring up the Hour glass (sometimes for several seconds before giving you what you want) . Troubleshooting Process and the FINAL FIX: This issue see…
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…
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…

815 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

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now