[英]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.