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)
Who is Participating?
Miguel OzConnect With a Mentor Software EngineerCommented:
Yes it will work, because windows service does not require UI
Todd GerbertIT ConsultantCommented:
Does the exception thrown include the line of code that throwing the exception?
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
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
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
shabrandiAuthor Commented:
it's a windows app, so if i change to console  app it will work ?
shabrandiAuthor Commented:
i don't need user interface,i can use console if it will  work
shabrandiAuthor Commented:
thx so,u right
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  
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
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.