Solved

Process.Start and issues with psapi.dll

Posted on 2010-08-25
9
715 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

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.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
C# Formatting DateTime String Value 5 50
C# Service FileSystemwatcher isse 9 46
Adding where clause to entity statement c# 1 47
WPF Select Items 3 25
Step by step guide to Clean and Sort your windows registry! Introduction: Always remember: A Clean registry = Better performance = Save your invaluable time In this article we're going to clear our registry manually! Yes, manually! The e…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
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…

735 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