2011-04-25 189 views
7

我写了一个托管WCF服务的应用程序。 我试着用这个配置运行应用程序。没有UAC /管理员权限的主机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中

回答

5

增值服务引用如果你想保持它的HTTP绑定,一个非管理员可以运行它,你需要使用命令

添加权限
netsh http add urlacl (see help for the rest of the params) 

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

+1

我的目标是让我的程序可以在没有管理员权限的用户帐户上运行,并且没有管理员可以帮助用户。这意味着用户不能添加分配的URL,但这个问题仍然无法解决。 – user554712 2011-04-30 15:45:09

4

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

+1

这不应该编辑为您的原始答案? – 2011-05-01 09:52:08

+0

是否有其他的方式来做到这一点,如果HTTP绑定不是必须的?(像NetTcpBinding,NetMsmqBinding等)我已经发现,使用netTcpBinding绑定没有请求管理权限,但它不能添加服务引用Visual Studio 2010. – user554712 2011-05-02 07:25:52

+1

工作正常 - 请参阅http://stackoverflow.com/questions/2335338/can-i-add-a-service-reference-with-nettcpbinding-in-wcf – nitzmahone 2011-05-03 00:06:28

2

该解决方案为我工作(使用HTTP绑定),打开这个网址服务:

http://localhost:80/Temporary_Listen_Addresses/ 

必须承认,我以后-ING谷歌在一段时间发现在这个网站上http://www.paraesthesia.com/archive/2010/06/11/developing-as-a-non-admin-testing-wcf-services.aspx/ ...所以信贷给那个家伙。

+1

这只适用于'http:// localhost:80/Temporary_Listen_Addresses /'已经添加到http绑定(在大多数情况下已经在标准安装中完成),在运行“netsh http show urlacl”时看到控制台已经有一个用于该地址的urlacl(win10)! – Sebastian 2016-11-07 10:58:40

相关问题