我不知道这是否是一个好方法,但是我使用以下步骤来解决我的问题。
<system.serviceModel>
<serviceHostingEnvironment aspNetCompatibilityEnabled="True">
</serviceHostingEnvironment>
<services>
<service name="Service" behaviorConfiguration="ServiceBehavior">
<endpoint address="" binding="basicHttpBinding" contract="IService">
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="ServiceBehavior">
........some othere setting
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
在system.web下添加我我使用如下代码
<system.web>
<authorization>
<allow users="?"/>
</authorization>
<identity impersonate="true" userName="registry:HKLM\SOFTWARE\MY_SECURE_APP\acctopsmain\ASPNET_SETREG,userName" password="registry:HKLM\SOFTWARE\MY_SECURE_APP\acctopsmain\ASPNET_SETREG,password" />
</system.web>
在我添加的 Service.vb 类上
<AspNetCompatibilityRequirements(RequirementsMode:=AspNetCompatibilityRequirementsMode.Required)> _
Public Class Service Implements IService