windows service in C#

hi, i have a windows service in win 7, my service will run an exe to mailing a folder at specified time,but when the exe run  by the service , it don't work and throw this error
object refrence not set to  an instance of an object.
but send my error report mail
when i run my exe it works.
 what should be this issue? is there any solution for this
the code to run my app in the service is :
        ProcessStartInfo pInfo = new ProcessStartInfo(path);
                        Process pHandle= Process.Start(pInfo);
                if (pHandle != null)
                {
                    pHandle.WaitForExit();
                    pHandle.Close();
                }
shabrandiAsked:
Who is Participating?
 
Miguel OzConnect With a Mentor Software EngineerCommented:
Yes it will work, because windows service does not require UI
0
 
Todd GerbertIT ConsultantCommented:
Does the exception thrown include the line of code that throwing the exception?
0
 
shabrandiAuthor Commented:
i don't know whitch line exactlly  throwing this but i think it should be the part of code that attempt to  the directory of folder
can it be  an access permmission probelm ?
the directory is not in use or not locked
0
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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.

 
shabrandiAuthor Commented:
the exeption throwing in my app code
0
 
Miguel OzSoftware EngineerCommented:
Can you tell me if your exe is a console application? a window app will not run if being fired from a windows service
0
 
shabrandiAuthor Commented:
it's a windows app, so if i change to console  app it will work ?
0
 
shabrandiAuthor Commented:
i don't need user interface,i can use console if it will  work
0
 
shabrandiAuthor Commented:
thx so,u right
0
 
shabrandiAuthor Commented:
sorry ,the result is same in console app,the application(both of win app or console app) will run and send me it's Exeptions by mailing,but can't sent the folder  
0
 
shabrandiAuthor Commented:
the Exeption is in access to  windows registry keys, before sending the folder
a method should get the  folder information from windows registry but can't do this
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.