Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to get this config value from app.config?

Tags:

c#

My friend has the following app.config. He wants to get the value of address. how to do it?

<configuration>
    <system.serviceModel>
...
           <client>
            <endpoint address="http://ldo:8080/LLService" binding="wsHttpBinding"
                bindingConfiguration="WSHttpBinding_ILLService" contract="LLServiceReference.ILLService"
                name="WSHttpBinding_ILLService">
                <identity>
                    <userPrincipalName value="[email protected]" />
                </identity>
            </endpoint>
        </client>
    </system.serviceModel>
...
</configuration>
like image 833
5YrsLaterDBA Avatar asked Jul 09 '10 16:07

5YrsLaterDBA


People also ask

What is app config in C#?

App. Config is an XML file that is used as a configuration file for your application. In other words, you store inside it any setting that you may want to change without having to change code (and recompiling). It is often used to store connection strings.

How read app config file in VB NET?

You can mark the settings as public in the C# project ("Access Modifier" in the property pane of settings) and then you can access it from the vb project (don't forget to add the reference). Edit: Just saw that your question was for the other direction (setting in vb project, read it in c# project).


1 Answers

try this to Get first endpoint

Configuration configuration =    ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.PerUserRoamingAndLocal);
ServiceModelSectionGroup serviceModelSectionGroup = ServiceModelSectionGroup.GetSectionGroup(configuration);
ClientSection clientSection = serviceModelSectionGroup.Client;
var el = clientSection.Endpoints[0];
return el.Address.ToString();
like image 69
Edgars Avatar answered Oct 04 '22 05:10

Edgars