tags:

views:

26

answers:

1

This is very odd. I've written a windows form tool in C# to return the default IE proxy. It works (See code snippets below). I've created a service to return the proxy using the same code, it works when I step into the debugger, BUT it doesn't work when the service is running as binary code. This must be some sort of permissions or context thing that I cannot recreate. Further, if I call the tool from the windows service, it still doesn't return the proxy information.... this seems isolated to the service somehow. I don't see any permission errors in the events log, it's as if a service has a totally different context than a regular windows form exe.

I've tride both:

WebRequest.GetSystemWebProxy()

and

Uri requestUri = new Uri(urlOfDomain);
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(requestUri);
IWebProxy proxy = request.Proxy;

if (!proxy.IsBypassed(requestUri)){
    Uri uri2 = proxy.GetProxy(request.RequestUri);
}

Thanks for any help!

A: 

This article is quite old, but still relevant for Windows Services, although it does not cover IE proxy settings. These settings depend on the user, so the answer to your question is related to the user context of the service. If the service runs as Local System, it will not have the same IE settings as your own user account.

Timores
Its running as the "local system account" and "allow service to interact with desktop". So that reasoning sounds about right. I'll have to resume testing tomorrow.
mytwocents
What is odd is why was it running a user when debugging?
mytwocents
Did you attach to the service for debugging or did you write code in Main to not run as a service when debugged ? In the 2nd case, you are running in your own context.
Timores