没有 UAC/管理员权限的主机 WCF 应用程序 [英] Host WCF application without UAC/admin privilege

查看:36
本文介绍了没有 UAC/管理员权限的主机 WCF 应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我编写了一个托管 WCF 服务的应用程序.我尝试使用此配置运行应用程序.

I have written a application which is hosting a WCF Service. And I try to run the application with this config.

<?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>

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

But it cause the application need to run as administrator.
Is it possible to run this application without admin privilege? (If possible, change the config only.) In addition, I also need to add service references in Visual Studio to write a client program. If possible, please keep the application can be added service references in Visual Studio 2010.

推荐答案

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

If you want to keep it on an HTTP binding so a nonadmin can run it, you'll need to add permissions using the command

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

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

This will allow the user you specify to carve off a chunk of the URL-space for the machine. If you don't want to do this, you'll need to change to a different binding (netTcp, for instance) that doesn't require special privileges to listen.

这篇关于没有 UAC/管理员权限的主机 WCF 应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆