【问题标题】:Retrieve IP information of a .NET Remoting client检索 .NET Remoting 客户端的 IP 信息
【发布时间】:2012-10-01 15:39:18
【问题描述】:

我需要获取通过 .NET Remoting TcpChannel 调用函数的客户端的 IP 地址。我发现this 帖子似乎正是我所需要的,但是,我不确定如何使用 app.config 文件来实现它,这是我的项目的要求。我在 MSDN 上找不到任何关于 app.config 文件在这种情况下的工作原理的好的文档,可能是因为 .NET Remoting 是一项遗留技术。有谁知道我如何使用 app.config 文件实现 Kev 答案第二部分中的配置代码?

非常感谢您对此提供的任何帮助。

【问题讨论】:

    标签: c# .net-4.0 .net-remoting


    【解决方案1】:

    This 回答为我创造了奇迹。我能够在 app.config 文件中实现这一点,如下所示:

    <configuration>
       <system.runtime.remoting>
          <application>
             <channels>
                <channel ref="tcp" port="1234">
                   <serverProviders>
                      <provider ref="clientinfo" />
                      <formatter ref="binary" />
                   </serverProviders>
                </channel>
             </channels>
          </application>
          <channelSinkProviders>
             <serverProviders>
                <provider
                   id="clientinfo"
                   type="MyNameSpace.ClientInfoServerSinkProvider, MyAssemblyName" />
             </serverProviders>
          </channelSinkProviders>
       </system.runtime.remoting>
    <startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup></configuration>
    

    我将整个 serverProviders 元素添加到 tcp 通道,并添加了您看到的整个 channelSinkProviders 元素。其他一切都已经作为我们已经拥有的现有配置存在。

    【讨论】:

    • 我也实现了访问客户端IP地址的参考方案,但发现不需要额外的配置。我不需要 部分或 中的 部分。 (其他部分已经存在。)
    猜你喜欢
    • 2020-05-08
    • 1970-01-01
    • 2018-06-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-08-21
    • 1970-01-01
    • 2019-07-26
    相关资源
    最近更新 更多