Monday, March 28, 2005

.NET Remoting and App.config files

I am moving on to some remoting applications in my project and found another interesting tidbit. Almost all of the remoting examples in Microsoft .NET Distributed Applications: Integrating XML Web Services and .NET Remoting use console applications as component hosts (listeners) and of course call the RemoteConfigurationFile.Configure method. This really doesn't make sense since in the real world, you are probably going to be running your component host as a service. What isn't revealed is that when you start your service, it's local directory is your system dir (e.g. c:windowssystem32). In order to access your application configuration you either need to hard code the whole path (bad idea) or use the ever so handy AppDomain.CurrentDomain.SetupInformation.ConfigurationFile. This makes it much simpler to access the app.config file and load your remoting configuration correctly. I found a snip that this information is included in Ingo Rammer's Book Advanced .NET Remoting in VB.NET but I haven't read that one yet.

No comments:

Post a Comment