I
I
Ivan Vyrov2016-02-17 07:55:02
C++ / C#
Ivan Vyrov, 2016-02-17 07:55:02

How to set up a client on the fly?

Good afternoon!
Given:
The Updater program connects to WCF and checks for the current version of the program.
The Monitor program works the same way with WCF.
2 WCF servers on Windows Server 2008 R2
It is necessary to:
Configure the configs (*.exe.config) of client programs on the fly so that WCF is connected to internal addresses (if the PC is located in the enterprise network) or external addresses (if the PC is located outside outside the enterprise)
Example:
A piece of code for connecting to an internal address:

<endpoint address="http://192.168.2.8:10202/Monitoring" binding="basicHttpBinding"
                bindingConfiguration="BasicHttpBinding_IMonitoring" contract="svc.IMonitoring"
                name="BasicHttpBinding_IMonitoring" />
            <endpoint address="net.tcp://192.168.2.8:10203/Monitoring" binding="netTcpBinding"
                bindingConfiguration="MetadataExchangeTcpBinding_IMonitoring"
                contract="svc.IMonitoring" name="MetadataExchangeTcpBinding_IMonitoring" />

Example:
A piece of code for connecting to an external address:
<endpoint address="http://231.18.50.8:10202/Monitoring" binding="basicHttpBinding"
                bindingConfiguration="BasicHttpBinding_IMonitoring" contract="svc.IMonitoring"
                name="BasicHttpBinding_IMonitoring" />
            <endpoint address="net.tcp://231.18.50.8:10203/Monitoring" binding="netTcpBinding"
                bindingConfiguration="MetadataExchangeTcpBinding_IMonitoring"
                contract="svc.IMonitoring" name="MetadataExchangeTcpBinding_IMonitoring" />

Question:
How to change configs on the fly? those. so that the program loads the working config and does not give an error.
My thoughts:
When starting the Updater program, check the availability of the server at the internal address; if it is not available, then change the ip in the configs to an external one and try again.
The question then boils down to how to edit the already involved config of the Updater program?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question