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

use*_*712 9 c# wcf

我写了一个托管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>
Run Code Online (Sandbox Code Playgroud)

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

nit*_*one 7

如果要将其保留在HTTP绑定上,以便nonadmin可以运行它,则需要使用该命令添加权限

netsh http add urlacl (see help for the rest of the params)
Run Code Online (Sandbox Code Playgroud)

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


nit*_*one 5

基于对我的其他答案的评论,您将无法使用内置的HTTP绑定执行此操作 - 它们都基于HTTP.sys,这需要授予非管理员用户注册URL的权限.如果您的部署方案允许,请考虑切换到netTcpBinding - 没有权限问题.否则,您使用内置绑定是SOL - 您需要构建一个不基于HTTP.sys的原始HTTP传输.


小智 5

该解决方案为我工作(使用HTTP绑定),请在以下URL上打开服务:

http://localhost:80/Temporary_Listen_Addresses/
Run Code Online (Sandbox Code Playgroud)

必须承认我在Google搜索后在此网站http://www.paraesthesia.com/archive/2010/06/11/developing-as-a-non-admin-testing-wcf-services.aspx/上找到了它一段时间...所以归功于那个家伙。

  • 仅当已经在http绑定中添加了“ http:// localhost:80 / Temporary_Listen_Addresses /”(大多数情况下在标准安装中已完成)时,该命令才能运行;在运行“ netsh http show urlacl”时查看控制台该地址的urlacl(win10)! (3认同)