[英]Host WCF application without UAC/admin privilege
我写了一个托管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>
但它导致应用程序需要以管理员身份运行。
是否可以在没有管理员权限的情况下运行此应用程序? (如果可能,仅更改配置。)此外,我还需要在Visual Studio中添加服务引用以编写客户端程序。 如果可能,请保留应用程序可以在Visual Studio 2010中添加服务引用。
如果要将其保留在HTTP绑定上,以便非管理员可以运行它,则需要使用该命令添加权限
netsh http add urlacl (see help for the rest of the params)
这将允许您指定的用户为该机器分割出一大块URL空间。 如果您不想这样做,则需要更改为不需要特殊权限才能侦听的其他绑定(例如netTcp)。
此解决方案适用于我(使用HTTP绑定),在此URL上打开您的服务:
http://localhost:80/Temporary_Listen_Addresses/
必须承认我在google-ing之后在这个网站http://www.paraesthesia.com/archive/2010/06/11/developing-as-a-non-admin-testing-wcf-services.aspx/上找到了它一段时间......所以归功于那个人。
基于对我的其他答案的评论,您将无法使用内置的HTTP绑定执行此操作 - 它们都基于HTTP.sys,这需要授予非管理员用户注册URL的权限。 如果您的部署方案允许,请考虑切换到netTcpBinding - 没有权限问题。 否则,您使用内置绑定是SOL - 您需要构建一个不基于HTTP.sys的原始HTTP传输。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.