I am writing a simple server (publisher) and client (subscriber) application to imagine inter-process communication between two managed C# processes.
I need to write a server (that's working as a publisher) that will publish the contents to the subscriber on the basis of its subscriptions and client (subscriber). For this I have to write two seperate configuration files (app.config
) on both the publisher's and subscriber's end.
It's creating a problem. When the publisher wants to publish the data, it starts the process (client which is working as subscriber) with Process.Start
statement. On start, the client process is unable to initialize remoting because it loads app.config
which is being used on the server side, where it didn't find its own configurations (subscriber's configurations).
I need to write both subscriber and publisher configuration on a single app.config
file.
How do I go 开发者_如何学Pythonabout doing this?
Are the publisher and subscriber running under the same exe? If not, then you can use application specific config files (.config) rather than "app.config".
From MSDN:
The configuration file for an application hosted by the executable host is in the same directory as the application. The name of the configuration file is the name of the application with a .config extension. For example, an application called myApp.exe can be associated with a configuration file called myApp.exe.config.
You can put the connection info here, and specify the StartInfo for the Process.Start and make sure you specify where the app is launched from. That should force it to read from the config file in that directory.
精彩评论