Solved

Process.Start and issues with psapi.dll

Posted on 2010-08-25
9
702 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
Comment Utility
Hi,

Try this way:

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

Regards,
VSS
0
 
LVL 23

Author Comment

by:Michael74
Comment Utility
????
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
Comment Utility
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
 
LVL 23

Author Comment

by:Michael74
Comment Utility
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
What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

 
LVL 14

Expert Comment

by:jake072
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Join & Write a Comment

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…
If you have done a reformat of your hard drive and proceeded to do a successful Windows XP installation, you may notice that a choice between two operating systems when you start up the machine. Here is how to get rid of this: Click Start Clic…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

744 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

16 Experts available now in Live!

Get 1:1 Help Now