1

I have a pretty simple TimeClock application written in VB (.net4) that I'm trying to add to. The addition will allow the user to change where the service is coming from.

In short, I want to be able to programatically change the in the App.Config file.

For reference:

<client>
        <endpoint address="net.tcp://localhost:8090/MyService/TimeClockService"
                  binding="netTcpBinding" 
                  contract="TimeClockService.ITimeClock" 
                  name="tcpBinding">
            <identity>
                <userPrincipalName value="susnick-PC\susnick" />
            </identity>
        </endpoint>
    </client>

The only part i'm really trying to change is the 'address'.

So far, i've seen some help on this site dealing with this in C# but I couldn't get it to work just right. Here is what i have so far. The 'newIp.text' is a text box that will allow the user to change the IP address.

Dim newAddress As String

    newAddress = "http://" & newIP.Text & "/"

Dim uri As Uri = New Uri(newAddress)
    Dim address = New EndpointAddress(uri)

The code will return the new uri as whatever IP address i type in. However, it doesn't update the App.config file with the new settings. Any help is appreciated.

Matt
  • 22,721
  • 17
  • 71
  • 112
MaylorTaylor
  • 4,671
  • 16
  • 47
  • 76
  • Take a look at this: http://stackoverflow.com/questions/2943148/how-to-programmatically-connect-a-client-to-a-wcf-service Using the app.config method of creating a client is going to have a static address. – Stefan H Dec 27 '12 at 23:28
  • Just to double check i am heading in the right direction-- I have a client and service app. I will be able to have a button on the client that updates the App.Config within the client app, correct? – MaylorTaylor Dec 28 '12 at 17:52
  • The client shouldn't really change the app.config. Instead, do not use the app.config for creating the client, just create the client programatically. – Stefan H Dec 28 '12 at 19:03

0 Answers0