问题描述
我创建了一个Windows服务(服务器)和一个使用WCFs wsdualhttpbinding回调函数的WPF(客户端)。两个软件之间的一切正常工作,但我遇到的问题是,客户端需要提高到管理员权限工作(这是可以理解的,因为它必须打开端口,以便与服务器通信)
I've created a Windows Service (server) and a WPF (client) that uses WCFs wsdualhttpbinding callback functionality. Everything between the two pieces of software works correctly but the problem I'm having is that the client needs to run elevated to administrator privileges to work (which is understandable because it has to open ports in order to communicate with the server)
有没有办法配置客户端在没有高程的情况下工作?或者可以创建一个一次性的永久连接,以便客户端不需要一直提高?
我的想法和Google搜索字词。
I'm running out of ideas and google search terms..
UPDATE
。
我向运行netsh打开的客户端应用程序添加了一个启用和禁用按钮(或关闭)并预订港口。
I've added an 'Enable' and 'Disable' buttons to the client application that runs netsh to open (or close) and reserve a port.
启用
Process process = new Process();
process.StartInfo = new ProcessStartInfo("netsh", @"http add urlacl url=http://+:" + PortNumber + @"/ user=DOMAIN\username");
process.StartInfo.Verb = "runas";
process.Start();
process.WaitForExit();
停用
Process process = new Process();
process.StartInfo = new ProcessStartInfo("netsh", "http delete urlacl url=http://+:" + PortNumber + "/");
process.StartInfo.Verb = "runas";
process.Start();
process.WaitForExit();
推荐答案
我向运行netsh打开的客户端应用程序添加了一个启用和禁用按钮(或关闭)并保留港口。
I've added an 'Enable' and 'Disable' buttons to the client application that runs netsh to open (or close) and reserve a port.
启用
Process process = new Process();
process.StartInfo = new ProcessStartInfo("netsh", @"http add urlacl url=http://+:" + PortNumber + @"/ user=DOMAIN\username");
process.StartInfo.Verb = "runas";
process.Start();
process.WaitForExit();
停用
Process process = new Process();
process.StartInfo = new ProcessStartInfo("netsh", "http delete urlacl url=http://+:" + PortNumber + "/");
process.StartInfo.Verb = "runas";
process.Start();
process.WaitForExit();
这篇关于WCF wsdualhttpbinding客户端没有高程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!