Referring to a video tutorial about WCF service in windows service,i have created a sample WCF service and hosted that Service with netTcpBinding in Windows Service.(since i want this WCF service to run as windows service)
Its a simple service which adds/deletes/loads employee details, and is consumed by a windows forms application.that worked fine,when i build the whole solution(consisting wcf service + windows service + client app), however when i wanted to verify that my client isn't directly referring to the project in the solution, so i excluded both the services(wcf+windows) from my solution. it stopped working throwing an error, reading:
Could not connect to net.tcp://localhost:8010/EmployeeService.Service1/. The connection attempt lasted for a time span of 00:00:02.0180000. TCP error code 10061: No connection could be made because the target machine actively refused it 127.0.0.1:8010.
Important point that might help to answer:
- WCF service and windows service have identical app.config
- Windows service is running as a service
this is my client app.config
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<bindings>
<netTcpBinding>
<binding name="netTcpEndPoint" closeTimeout="00:01:00" openTimeout="00:01:00"
receiveTimeout="00:10:00" sendTimeout="00:01:00" transactionFlow="false"
transferMode="Buffered" transactionProtocol="OleTransactions"
hostNameComparisonMode="StrongWildcard" listenBacklog="10"
maxBufferPoolSize="524288" maxBufferSize="65536" maxConnections="10"
maxReceivedMessageSize="65536">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<reliableSession ordered="true" inactivityTimeout="00:10:00"
enabled="false" />
<security mode="Transport">
<transport clientCredentialType="Windows" protectionLevel="EncryptAndSign" />
<message clientCredentialType="Windows" />
</security>
</binding>
</n开发者_运维技巧etTcpBinding>
</bindings>
<client>
<endpoint address="net.tcp://localhost:8010/EmployeeService.Service1/"
binding="netTcpBinding" bindingConfiguration="netTcpEndPoint"
contract="Service1.IService1" name="netTcpEndPoint">
<identity>
<userPrincipalName value="user@company.com" />
</identity>
</endpoint>
</client>
</system.serviceModel>
</configuration>
any help would be greatly appreciated....
Found the answer myself, hope it helps other looking for it...
I found that event of worker_DoWork() is not triggered, so add worker.RunWorkerAsync(); as shown in the code below to your windows service
protected override void OnStart(string[] args)
{
worker = new BackgroundWorker();
worker.RunWorkerAsync();
worker.DoWork += new DoWorkEventHandler(worker_DoWork);
}
Delete the Service reference from client project, add it again, since it makes changes to your app.config file.
Just a quickie note that may help some folk:
This error came up between two computers that controlled a Perkin Elmer - Thermo Fisher Scientific Liquid Handling apparatus (robot).
McAfee Antivirus was interfering with their communication and uninstalling McAfee banished the error. MS Security Essentials Antivirus did NOT interfere.
精彩评论