อ้างถึงวิดีโอ บทช่วยสอน เกี่ยวกับบริการ WCF ใน บริการ windows ฉันได้สร้างบริการ WCF ตัวอย่างแล้ว และโฮสต์บริการนั้นด้วย netTcpBinding ใน Windows Service (เนื่องจากฉันต้องการให้บริการ WCF นี้ทำงานเป็นบริการ windows)
เป็นบริการง่ายๆ ที่เพิ่ม/ลบ/โหลดรายละเอียดพนักงาน และถูกใช้โดยแอปพลิเคชันแบบฟอร์มของ Windows ซึ่งทำงานได้ดีเมื่อฉันสร้างโซลูชันทั้งหมด (ประกอบด้วยบริการ wcf + บริการ windows + แอปไคลเอนต์) แต่เมื่อฉันต้องการตรวจสอบ ลูกค้าของฉันไม่ได้อ้างอิงถึงโปรเจ็กต์โดยตรงในโซลูชัน ดังนั้นฉันจึงแยกทั้งบริการ (wcf+windows) ออกจากโซลูชันของฉัน มันหยุดทำงานโดยมีข้อผิดพลาด อ่าน:
ไม่สามารถเชื่อมต่อกับ net.tcp://localhost:8010/EmployeeService.Service1/ ความพยายามในการเชื่อมต่อดำเนินไปเป็นระยะเวลา 00:00:02.0180000 รหัสข้อผิดพลาด TCP 10061: ไม่สามารถทำการเชื่อมต่อได้เนื่องจากเครื่องเป้าหมายปฏิเสธอย่างแข็งขัน 127.0.0.1:8010
จุดสำคัญที่อาจช่วยตอบได้:
- บริการ WCF และบริการ windows มี app.config เหมือนกัน
- บริการ Windows กำลังทำงานเป็นบริการ
นี่คือ 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>
</netTcpBinding>
</bindings>
<client>
<endpoint address="net.tcp://localhost:8010/EmployeeService.Service1/"
binding="netTcpBinding" bindingConfiguration="netTcpEndPoint"
contract="Service1.IService1" name="netTcpEndPoint">
<identity>
<userPrincipalName value="[email protected]" />
</identity>
</endpoint>
</client>
</system.serviceModel>
</configuration>
ความช่วยเหลือใด ๆ ที่จะได้รับการชื่นชมอย่างมาก....