Link to home
Start Free TrialLog in
Avatar of shabrandi
shabrandi

asked on

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();
                }
Avatar of Todd Gerbert
Todd Gerbert
Flag of United States of America image

Does the exception thrown include the line of code that throwing the exception?
Avatar of shabrandi
shabrandi

ASKER

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
the exeption throwing in my app code
Can you tell me if your exe is a console application? a window app will not run if being fired from a windows service
it's a windows app, so if i change to console  app it will work ?
i don't need user interface,i can use console if it will  work
ASKER CERTIFIED SOLUTION
Avatar of Miguel Oz
Miguel Oz
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
thx so,u right
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  
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