In .NET, What is the runtime equivalent of my app.config setup?

If I have the following option in my app.config file. This is the parameter I need to make sure that my WCF client can negotiate the default proxy.

<system.net>
    <defaultProxy enabled="true" useDefaultCredentials="true"></defaultProxy>
</system.net>

Unfortunately, I cannot add the app.config file to my environment. How to provide these settings by setting them at runtime?

+3
source share
4 answers

I think you create an object System.Net.WebProxy, then set the appropriate variables, and then set System.Net.WebRequest.DefaultWebProxy:

System.Net.WebProxy proxy = new WebProxy();
proxy.UseDefaultCredentials = true;
WebRequest.DefaultWebProxy = proxy;

This post seems to be talking about everything: Link

Hope this helps!

0
source

. , , *.settings , app.config . ?

0

, , WSHttpBindingBase. , UseDefaultWebProxy . - :

myWSHttpBinding.UseDefaultWebProxy = True;

:. HttpBinding .

0

, ( dll), ".config" ...

,

AcmeWidgets.EastCoast.MyApplicationName.exe

app.config

AcmeWidgets.EastCoast.MyApplicationName.exe.config

( ) ...

instead, you can encode your application so that it fills and uses the static variables from these configuration parameters instead ... and then implements the dynamic "change value" functionality so that it modifies these static variables ...

This way you can "dynamically influence" runtime behavior, but avoid the hassle of writing to the configuration file, and Ops control can control the "default" values ​​in the configuration file by editing it ...

-2
source

All Articles