调用 RemoteConfiguration.Configure(configFile) 后修改设置?
我的应用程序调用 RemotingConfiguration.Configure()
来设置 .NET Remoting。但由于我需要每次运行应用程序时通道元素的 portName 属性都不同,因此我必须以编程方式配置此特定设置。
这听起来很简单(也可能是——但我一整天都在谷歌上搜索答案)。
到目前为止,我已经:
RemotingConfiguration.Configure(Program.ConfigFilePath, false);
IChannel[] regChans = ChannelServices.RegisteredChannels;
IpcChannel ipcChannel = (IpcChannel)ChannelServices.GetChannel(regChans[0].ChannelName);
调试器向我显示 ipcChannel._serverChannel._prop
将是我需要向其添加条目的哈希表,例如 ["portName"] = uniquePortName
,但我根本不知道如何访问和修改它。
我知道我总是可以废弃 *.config 文件并以编程方式完成整个事情,但我真的不想放弃大多数设置易于编辑的好处。
一旦 RemotingConfiguration.Configure()
返回后修改 IpcClientChannel
对象是否为时已晚?显然,我可以编写自己版本的 RemotingConfiguration.Configure()
,但这似乎也不是正确的做法。
My application calls RemotingConfiguration.Configure()
to set up .NET Remoting. But since I need the portName attribute of the channels element to be different each time the application is run, I have to configure this particular setting programatically.
It sounds very simple (and probably is - but I've been searching Google all day for an answer).
So far I have:
RemotingConfiguration.Configure(Program.ConfigFilePath, false);
IChannel[] regChans = ChannelServices.RegisteredChannels;
IpcChannel ipcChannel = (IpcChannel)ChannelServices.GetChannel(regChans[0].ChannelName);
The debugger shows me that ipcChannel._serverChannel._prop
would be the hash table to which I need to add an entry such as ["portName"] = uniquePortName
, but I simply cannot see how to access and modify this.
I know I could always scrap the *.config file and do the whole thing programatically, but I really don't want to throw away the benefits of having most of the settings easily editable.
Is it too late to modify an IpcClientChannel
object once RemotingConfiguration.Configure()
has returned? Obviously I could probably write my own version of RemotingConfiguration.Configure()
, but that doesn't seem like the Right Way to do things either.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我想我已经确定我想做的事情是不可能的。
您可以使用
RemotingConfiguration.Configure()
或类似的东西:您不能混合搭配。至少,情况似乎是这样。
(当然,您仍然可以从 *.config 文件中读取任何这些设置,但要点是您必须为您可能想要支持的所有选项显式编码。)
I think I've established that what I wanted to do is not possible.
You can either use
RemotingConfiguration.Configure()
or something like:You can't mix and match. At least, that seems to be the case.
(Of course you can still read any of these settings from the *.config file, but the point is you have to explicitly code for all of the options you might want to support.)