我必須使用COM可見組件來使用Windows服務中託管的WCF服務。Com可見組件中使用WCF服務
我有一個WCF服務託管在Windows服務中,我必須使用COM Visible程序集中的服務,我創建了一個COM +應用程序併爲其添加了服務引用。以下是app.config
。
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<bindings>
<netTcpBinding>
<binding name="TcpEndpoint" 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="None">
<transport clientCredentialType="Windows" protectionLevel="EncryptAndSign" />
<message clientCredentialType="Windows" />
</security>
</binding>
</netTcpBinding>
</bindings>
<client>
<endpoint address="net.tcp://serverMachine:9600/DocumentsWcfService/Tcp"
binding="netTcpBinding" bindingConfiguration="TcpEndpoint"
contract="MysWcfService.IMysWcfService" name="TcpEndpoint" />
</client>
</system.serviceModel>
</configuration>
當我在傳統的ASP項目中使用這個程序集並調用初始化服務的方法時,我得到如下的錯誤。但是當我在Console應用程序中引用相同的WCF服務時,它工作正常。在COM可見應用程序中是否需要使用特定更改?
找不到在ServiceModel客戶端配置部分中引用合同'MyWcfService.IMysWcfService'的默認端點元素。這可能是因爲沒有爲您的應用程序找到配置文件,或者因爲在客戶端元素中找不到與此合同匹配的端點元素
,如果這是一個正被調用的DLL通過com組件,您將無法依賴應用程序配置,但必須通過代碼進行配置。 – PatFromCanada
@PatFromCanada我將WCF服務引用直接添加到Com組件並使用ASP中的COM組件。如果我們必須通過代碼進行配置,我們如何使用沒有硬編碼地址的端點,請指出任何資源謝謝您。 – Arvind
Adrian的回答是一種可行的方式,當然你總是可以創建一個文本(XML)文件並在其中放置一個地址,我從來不必處理這個特定的問題。 – PatFromCanada