Click here to Skip to main content
15,888,112 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I'm trying to pass system default proxy from windows application to windows service. While passing the value I get the below error.

C#
//Type 'System.Net.WebRequest+WebProxyWrapper' cannot be serialized. Consider marking it //with the DataContractAttribute attribute, and marking all of its members you want //serialized with the DataMemberAttribute attribute.


Same code works with a Windows application, In which I can get system proxy and send it to the webrequest.

Is there alternative way to pass proxy settings from windows application to windows service

What I have tried:

Below is the code.

WebProxyClass _WebProxy = new WebProxyClass();
_WebProxy.WebProxy = WebRequest.DefaultWebProxy; // This line successfully fetches system proxy
var WebProxy_default = _WebProxy.WebProxy;


_pipe.RegisterApp(IPC_Client, WebProxy_default); // I get error on this point



using System.Net;

 public class WebProxyClass
    {
        public IWebProxy WebProxy { get; set; }
    }


Also tried to manually set proxy in windows service as below...

System.Net.NetworkCredential cr = new System.Net.NetworkCredential("UserName", "Password", "Domain");
WebProxy pr = new WebProxy("127.0.0.1", 8888);
pr.Credentials = cr;
restRequest.Proxy = pr;
Posted
Updated 30-Mar-17 2:12am
v4

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