I have application #1 that configures its remoting through the
system.runtime.remoting
element in its
app1.exe.config
file. Then I have application #2 that needs to know which port application #1 is currently using for its remoted object (since it can be changed externally). Application #2 knows where to find the
app1.exe.config
file and what elements will be there. It should be easy.
<configuration>
<system.runtime.remoting>
<application name="XXXServer">
<channels>
<channel ref="tcp" port="12345">
. . .
</channel>
</channels>
. . .
</application>
</system.runtime.remoting>
</configuration>
The current approach for getting the port number is to read the config file with
XDocument
and drill down to the "channel"
XElement
. (There
ought to be an easier way, but I haven't been able to find it.) Further,
XDocument
seems to always open the file for exclusive access. I need it to share read access so other readers can access the same data. (Again, there must be a way, probably with
XmlReader
, but I need help figuring that one out.)
None of my many searches for a clean way to get that information have turned up any prospects. Does one exist?