if you get any exception like “ Request for the permission of type ‘System.Net.WebPermission, System, Version=2.0.0.0, Culture=neutral,PublicKeyToken=b77a5c561934e089‘ …”
then check for the trust your application is having.
Even my application WPF browser application when trying to consume a web serice had this problem and finally found that the project ( wpf) should have the full trust.
to make your application full strust follow the instructions.
1. select the project —> right click and select properties
2. you will get all the properties listed. select — > security tab from left panel.
3. now select/ check the radio button that says ” This is full trust application”
4. save and run ur application. this should solve ur problem.
source : original source