Verify that the current user is granted access in the appropriate allowAccounts section of SMSvcHost.exe.config

Quick tip that maybe will save others time:

In Windows 7 ( and maybe Vista) when hosting a WCF Service in a console application AS A USER and not as administrator, you might get an exception telling you that you don't have access to register with the net.tcp port sharing service.

To resolve this problem:

In the end you should have something like this:

 1 < ?xml version="1.0" encoding="utf-8"?>
 2 <!-- The configuration file for SMSvcHost.exe -->
 3 <configuration>
 4     <runtime>
 5         <gcconcurrent enabled="false" />
 6     </runtime>
 7     <system.serviceModel>
 8         <diagnostics performanceCounters="Off" etwProviderId="{f18839f5-27ff-4e66-bd2d-639b768cf18b}"/>
 9     </system.serviceModel>
10  <system.serviceModel.activation>
11         <net.tcp listenBacklog="10" maxPendingConnections="100" maxPendingAccepts="2" receiveTimeout="00:00:10" teredoEnabled="false">
12             <allowaccounts>
13                 <add securityIdentifier="S-1-5-21-1754548885-2506776180-2303324228-4659"/>
14             </allowaccounts>
15         </net.tcp>
16     </system.serviceModel.activation>
17 </configuration>

Also you might need to grant access to the user to register as a listener for an url:

netsh http add urlacl url=http://+: <port>/MyUri user=DOMAIN\user

I have to admin the most of the time i've spent on this issue was because i was modifying the commented section in the the config xml.

Comments