Click here to Skip to main content
15,908,674 members
Home / Discussions / C#
   

C#

 
GeneralRe: eRROR AND HOW TO RAPAIR IT Pin
papa198028-Nov-05 6:09
papa198028-Nov-05 6:09 
GeneralRe: eRROR AND HOW TO RAPAIR IT Pin
leppie28-Nov-05 6:20
leppie28-Nov-05 6:20 
GeneralRe: eRROR AND HOW TO RAPAIR IT Pin
Stanciu Vlad28-Nov-05 6:37
Stanciu Vlad28-Nov-05 6:37 
Questiongeting address of function in c# Pin
mostafa.hk28-Nov-05 2:14
mostafa.hk28-Nov-05 2:14 
AnswerRe: geting address of function in c# Pin
Stanciu Vlad28-Nov-05 4:52
Stanciu Vlad28-Nov-05 4:52 
AnswerRe: geting address of function in c# Pin
Dave Kreskowiak28-Nov-05 5:09
mveDave Kreskowiak28-Nov-05 5:09 
QuestionC# and dynamic report in cristal reports Pin
omichalowski28-Nov-05 1:53
omichalowski28-Nov-05 1:53 
QuestionProcess.HasExited property does not work as expected Pin
Ricardo Mendes28-Nov-05 1:40
Ricardo Mendes28-Nov-05 1:40 
I've created a windows service to ensure another service is running. First of
all, I look for the process relative to the service I'm monitoring. The code
is:

Process[] processes = Process.GetProcesses();
foreach(Process process in processes)
if(!process.HasExited &&
process.Id > 0 &&
process.ProcessName.ToLower() != "system" &&
process.MainModule.FileName.ToLower() == serviceDetail.ExecutablePath.ToLower())
...

The problem is with the MainModule property, called at the end of the if
statement. Internally, the MainModule property gets all modules for the
process and looks for the main one. So, if the process has exited, the search
for the process modules fails and we get an exception.

In order to solve this issue, I test the HasExited property at first place.
However, I still get an exception: "Cannot process request because the
process (3248) has exited." Why this exception occurs if I have tested the
HasExited property? Am I doing somethig wrong or missing something?

Another exception is thrown too. Sometimes I get an "Access is denied"
exception from this code piece.

Does anyone have any idea that could help me?
Thanks in advance.

Ricardo

AnswerRe: Process.HasExited property does not work as expected Pin
Stanciu Vlad28-Nov-05 5:05
Stanciu Vlad28-Nov-05 5:05 
QuestionAccessing PDA from an Application Pin
rnvrnv28-Nov-05 1:38
rnvrnv28-Nov-05 1:38 
QuestionNested class accessibility Pin
Jon Hulatt27-Nov-05 23:40
Jon Hulatt27-Nov-05 23:40 
AnswerRe: Nested class accessibility Pin
leppie28-Nov-05 6:19
leppie28-Nov-05 6:19 
QuestionWindow service Repair give fatal error Pin
basantsahu27-Nov-05 23:36
basantsahu27-Nov-05 23:36 
QuestionHow to Re-open the systray application Pin
basantsahu27-Nov-05 23:20
basantsahu27-Nov-05 23:20 
Questionhow to convert hex to string Pin
orrjiao27-Nov-05 22:56
orrjiao27-Nov-05 22:56 
GeneralRe: how to convert hex to string Pin
Guffa28-Nov-05 2:24
Guffa28-Nov-05 2:24 
GeneralRe: how to convert hex to string Pin
orrjiao28-Nov-05 13:24
orrjiao28-Nov-05 13:24 
AnswerRe: how to convert hex to string Pin
Guffa28-Nov-05 22:00
Guffa28-Nov-05 22:00 
QuestionImage to to Stream of Byte[]? Pin
majidbhutta27-Nov-05 22:03
majidbhutta27-Nov-05 22:03 
AnswerRe: Image to to Stream of Byte[]? Pin
Guffa27-Nov-05 22:37
Guffa27-Nov-05 22:37 
Questioncan i refresh DBGrid in c#? Pin
iman_kh27-Nov-05 22:01
iman_kh27-Nov-05 22:01 
AnswerRe: can i refresh DBGrid in c#? Pin
Mark DeVol29-Nov-05 11:22
Mark DeVol29-Nov-05 11:22 
Questioncan i run an execute file in c#? Pin
iman_kh27-Nov-05 21:50
iman_kh27-Nov-05 21:50 
AnswerRe: can i run an execute file in c#? Pin
Maqsood Ahmed27-Nov-05 22:49
Maqsood Ahmed27-Nov-05 22:49 
Questionproblem with instalation Pin
papa198027-Nov-05 21:45
papa198027-Nov-05 21:45 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.