Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/wcf/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 没有UAC/admin权限的主机WCF应用程序_C#_Wcf - Fatal编程技术网

C# 没有UAC/admin权限的主机WCF应用程序

C# 没有UAC/admin权限的主机WCF应用程序,c#,wcf,C#,Wcf,我已经编写了一个应用程序,它承载着一个WCF服务。 我尝试用这个配置运行应用程序 <?xml version="1.0"?> <configuration> <system.serviceModel> <services> <service name="MyApp.Service" behaviorConfiguration="ServiceBehavior">

我已经编写了一个应用程序,它承载着一个WCF服务。 我尝试用这个配置运行应用程序

<?xml version="1.0"?>
<configuration>
    <system.serviceModel>
        <services>
            <service name="MyApp.Service" behaviorConfiguration="ServiceBehavior">
                <host>
                    <baseAddresses>
                        <add baseAddress="http://localhost:8000/service"/>
                    </baseAddresses>
                </host>
                <endpoint address="" binding="wsHttpBinding" contract="MyApp.IService"/>
                <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
            </service>
        </services>
        <behaviors>
            <serviceBehaviors>
                <behavior name="ServiceBehavior">
                    <serviceMetadata httpGetEnabled="true"/>
                    <serviceDebug includeExceptionDetailInFaults="False"/>
                </behavior>
            </serviceBehaviors>
        </behaviors>
    </system.serviceModel>
<startup><supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/></startup></configuration>

但这会导致应用程序需要以管理员身份运行。

是否可以在没有管理员权限的情况下运行此应用程序?(如果可能,只更改配置。)此外,我还需要在VisualStudio中添加服务引用来编写客户端程序。如果可能,请保留该应用程序,以便在Visual Studio 2010中添加服务引用。

如果希望将其保留在HTTP绑定上,以便非管理员可以运行它,则需要使用命令添加权限

netsh http add urlacl (see help for the rest of the params)

这将允许您指定的用户为机器分割一块URL空间。如果您不想这样做,则需要更改为其他绑定(例如,netTcp),该绑定不需要特殊权限来侦听。

根据对我的另一个答案的评论,您将无法使用内置HTTP绑定执行此操作-它们都基于HTTP.sys,它要求授予非管理员用户注册URL的权限。如果部署场景允许,则考虑切换到NETTCPB绑定,而不是在那里出现权限问题。否则,您将无法使用内置绑定—您需要构建一个不基于HTTP.sys的原始HTTP传输。

此解决方案适合我(使用HTTP绑定),请在此URL上打开您的服务:

http://localhost:80/Temporary_Listen_Addresses/

必须承认,我在谷歌搜索了一段时间后在这个网站上找到了它……所以要归功于那个家伙。

我的目标是让我的程序可以在一个没有管理员权限的用户帐户上运行,这个帐户从来没有管理员权限,也没有管理员会帮助用户。这意味着用户无法添加分配的URL,并且此问题仍然无法解决。URL格式应与绑定时遇到的错误相同。。。对我来说,这是
http:\\+:port\u number\sub\u url
如果http绑定不是必须的,是否有其他方法可以做到这一点?(如NetTcpBinding、NetMsmqBinding等)我发现,使用netTcpBinding绑定并不是请求管理员权限,但不能在Visual Studio 2010中添加服务引用。工作正常-仅当
http://localhost:80/Temporary_Listen_Addresses/
已添加到http绑定中(在大多数情况下,已在标准安装中完成)运行“netsh http show urlacl”时,请查看控制台,该地址(win10)已经有一个urlacl!