Click here to Skip to main content
15,912,207 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi All,
I am working on windows service project in VS2005 c#, which monitors Database status after regular intervals and in case of any problem sends SMS to concerned person.

Now the problem is that when connecting to internet for sending SMS, the webclient class object through an error:
"The remote name could not be resolved".

But same code is working with windowsApplication on some button click. Is there any difference in credentials.


Code is as follow:

protected override void OnStart(string[] args)
{            
WebClient webClient = new WebClient();
try
{
   wtr = new StreamWriter(@"c:\SMS.txt");
   wtr.WriteLine("sms Application");                
   string sms = webClient.DownloadString("http://www.google.com");//Sample Domain
   wtr.WriteLine("sms");
   wtr.Close();   
}
catch (Exception ex)
{
   wtr.WriteLine(ex.Message);
   wtr.Close();                
}
}



Thanx in advance
Posted
Updated 24-Jun-10 2:17am
v3
Comments
Ankur\m/ 25-Jun-10 1:54am    
As you already said, LocalSystem is a privileged account. It should work under this account.
I would suggest you to debug the service that may give you the details why the code is failing.

1 solution

Did you try this[^]? Try using the suggested methods, I am sure you will find a solution. If you still cannot solve it, come back and give more details of what you tried.

Hope it helps!
 
Share this answer
 
Comments
Ankit Maini 24-Jun-10 9:24am    
Thanx 4 reply.
I tried the same thing under ADMINISTRATOR account and its working fine, previously it was running under LocalSystem account and according to MS it is also a privileged account.

Is it the limitation of LocalSystem account or am i doing some mistake ????

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900