IpcServerChannel属性问题

时间:2011-08-19 19:58:29

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

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

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

这是我的清单

IDictionary properties = new Hashtable();

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

channel = new IpcServerChannel(properties,null);

尝试运行时,出现IdentityNotMappedException错误。你们有什么想法吗?

2 个答案:

答案 0 :(得分:2)

用户名取决于Windows languange:

您可以使用帐户的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);

答案 1 :(得分:0)

好的,我有东西。

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

相关问题