【问题标题】:IpcServerChannel properties problemIpcServerChannel 属性问题
【发布时间】:2011-08-19 19:58:28
【问题描述】:

我必须用 C# 编写一个服务程序和一个程序来维护它。我不能使用 .net 3 或 4,所以我坚持使用 .Net 2.0。我知道IPC 频道可以帮助我,但我在使用它们时遇到了问题。

我正在尝试使用IDictionary 作为属性列表来创建我的IpcServerChannel。但我找不到要发送的好属性。

这是我的清单

IDictionary properties = new Hashtable();

properties.Add("authorizedGroup", "Users");
properties.Add("portName", "ServerChannel");

channel = new IpcServerChannel(properties,null);

尝试运行此程序时,我收到了 IdentityNotMappedException 错误。你们有什么想法吗?

【问题讨论】:

    标签: c# multithreading .net-2.0 c#-2.0 ipc


    【解决方案1】:

    用户名取决于 Windows 语言:

    您可以使用帐户的 SID 代码以及 Sid 常量。例如“WellKnownSidType.WorldSid”与“EveryOne”相同。

    // Get SID code for the EveryOne user
    SecurityIdentifier sid = new SecurityIdentifier(WellKnownSidType.WorldSid, null);
    // Get the NT account related to the SID
    NTAccount account = sid.Translate(typeof(NTAccount)) as NTAccount;
    
    // Put the account locale name to the properties
    properties.Add("authorizedGroup", account.Value);
    

    【讨论】:

      【解决方案2】:

      好的,我有东西。

      事实上,我发现的所有关于 IPC 的信息都是英文的,所以它使用的是“用户”组。我正在使用的计算机是法语的,因此“用户”组被命名为“Utilisateurs”。我更正了它,它现在可以工作了。

      【讨论】:

        猜你喜欢
        • 2010-10-18
        • 2017-07-21
        • 2011-05-08
        • 2016-05-07
        • 1970-01-01
        • 2013-12-16
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多