My Windows Service is not able to Identify Process
<p>I have written an windows service application in c# to find wether the applications configured are running in the process or not. For instance if I have configured OUTLOOK and checking in the application process list if outlook is open/closed if my application didnt find OUTLOOK in process list then it emails me saying your application OUTLOOK is either closed or crashed.</p>

<p>When I am trying to run this in code it is sending email only if OUTLOOK is closed but when I am running using Service it is sending an email even if OUTLOOK is running.</p>

<p>Can anyone please explian me why my Service is not able to recognize applications in application process list.</p>

<pre><code>    public void GetListofApplications(List&lt;string&gt; applicationsInConfig)
    {
        if (AppsInActive.Count &gt; 0)
        {
            AppsInActive.Clear();
        }
        StringBuilder sb = new StringBuilder();
        foreach (Process p in Process.GetProcesses("."))
            try
            {
                if (p.MainWindowTitle.Length &gt; 0)
                {
                    APPsInProcess.Add(p.ProcessName.ToString());
                }
            }
            catch(Exception ex)
            {
                Logger.Log("Exception in Finding Process" + ex);
            }

        foreach (var application in applicationsInConfig)
        {
            if (APPsInProcess.Contains(application))
            {
                AppsActive.Add(application);
            }
            else
            {
                AppsInActive.Add(application);
            }
        }

        foreach (var item in AppsInActive)
        {
            Logger.Log("Following application is either crashed/closed :" + item);
        }

        Helper.EmailSetup setup = new Helper.EmailSetup();
        setup.ApplicationFailedEmailSetup(AppsInActive, DateTime.Now);
               }
</code></pre>
