简体   繁体   中英

WCF service not running on non-dev machine

I've used this MSDN tutorial on how to get WCF working with net.tcp binding using Windows Services as the host:

http://msdn.microsoft.com/en-us/library/ff649818.aspx

I need nettcp because of callbacks, and don't want to use IIS as a host.

This tutorial works 100% on my computer and, i've done a second version using my own project name and methods etc and this also works 100% on my computer - both when run from VS2010 and when I use InstallUtil and run as a service.

I downloaded Juval Lowy's Metadata explorer and run this on my computer and it finds the service. (from www.idesign.net )

I can't get this to work on another computer - ie, the production server. I've also tried installing on a spare pc to see if this was a server related issue. Neither of these have VS2010 however, that shouldn't matter because I'm running as a windows service.

I copy the /bin/Release folder from my vs2010 project and put this on the other computer in a folder named myapp . I run InstallUtil on the service exe (just as I did on my computer) and it installs fine. I also change permissions on the folder to give NETWORK SERVICE full rights.

I then start the service in Control Panel, Admin Services, Services. I have logging to a database and I verify that the service process starts. I can't tell if the WCF hosted service starts.

On my computer whenever WCF hosted services start I get a balloon notification and a window I can look at to see the mex address etc. This doesn't happen when I install onto other computer.

I have installed Juval Lowy's metadata explorer on the target machine but it states invalid address using exact same address as I did on my computer (ie references localhost not IP Address).

I figure something is wrong in my methodology to install on other computer.

The relevant code is:

if (myServiceHost != null)
            myServiceHost.Close();

myServiceHost = new ServiceHost(typeof(MyAppService));
myServiceHost.Open();

and app.config :

<system.serviceModel>
<services>
   <service behaviorConfiguration="netTCPBehavior" name="MyAppDll.MyAppDll">
      <endpoint 
          address="" 
          binding="netTcpBinding" bindingConfiguration=""
          contract="MyAppDll.IMyAppDll">
         <identity>
            <dns value="localhost" />
         </identity>
      </endpoint>
      <endpoint 
          address="mex" 
          binding="mexTcpBinding" bindingConfiguration=""
          contract="IMetadataExchange" />
         <host>
            <baseAddresses>
               <add baseAddress="net.tcp://localhost:7200/MyAppDll" />
            </baseAddresses>
         </host>
      </endpoint>
   </service>
</services>
<behaviors>
  <serviceBehaviors>
    <behavior name="netTCPBehavior">
      <serviceMetadata httpGetEnabled="false" />
      <serviceDebug includeExceptionDetailInFaults="false" />
    </behavior>
  </serviceBehaviors>
</behaviors>
</system.serviceModel>

Where am I going wrong ?

You may have to enable the Net.TCP Port Sharing Service .

Windows Communication Foundation (WCF) uses a Windows service called the Net.TCP Port Sharing Service to facilitate the sharing of TCP ports across multiple processes. This service is installed as part of WCF, but the service is not enabled by default as a security precaution and so must be manually enabled prior to first use.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM