我编写了一个托管 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 绑定(bind)上以便非管理员可以运行它,则需要使用以下命令添加权限
netsh http add urlacl (see help for the rest of the params)
这将允许您指定的用户为机器分割出一大块 URL 空间。如果您不想这样做,则需要更改为不需要特殊权限即可监听的其他绑定(bind)(例如 netTcp)。
关于c# - 在没有 UAC/管理员权限的情况下托管 WCF 应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5774606/