• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 355
  • Last Modified:

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();
                }
0
shabrandi
Asked:
shabrandi
  • 7
  • 2
1 Solution
 
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
 
shabrandiAuthor Commented:
the exeption throwing in my app code
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
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
 
Miguel OzSoftware EngineerCommented:
Yes it will work, because windows service does not require UI
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

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 7
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now