2011-12-17 52 views
0

忍着我一會兒,我想佈置整個圖片。 我有一個WPF應用程序(.exe),當COM對象(VB6宏)調用應用程序方法時需要打開並顯示一個窗口。我已經使.exe解決方案COM中的一個託管代碼項目可見,並且VB6宏成功調用此託管代碼項目(COM存根)上的方法。帶WCF客戶端/服務的WPF應用程序找不到端點元素

我的COM存根接收方法調用,並在第一次傳入命令行參數的WPF EXE上運行Process.Start。我的應用程序按預期開始。我現在需要通過我的COM存根將VB6宏中的數據發送到連續調用的WPF exe文件中。我添加了一個WCF項目到我的WPF exe解決方案,產生一個「netNamedPipeBinding」服務。我已經在COM存根中添加了一個ServiceReference來與WPF exe進行通信。我已經使用控制檯應用程序單獨測試了WCF服務,它可以工作。我已經使用與我的測試用例相同的元數據地址構建了COM存根ServiceReference,並且它通常構建了引用。

我的測試驅動程序調用COM存根方法,並啓動WPF應用程序。我對COM stub的下一次調用嘗試實例化服務客戶端,並且收到可怕的錯誤: 「無法在ServiceModel客戶端配置部分中找到名稱爲'internal'並與合同'SelectedStudentReference.ISelectedStudent'的端點元素。」

這裏是我的WPF exe解決方案的WCF服務項目部分中的app.config的內容。

<system.serviceModel> 
    <bindings /> 
    <client /> 
    <services> 
    <service name="AwardManager.Service.SelectedStudentService"> 
     <host> 
     <baseAddresses> 
      <!--<add baseAddress = "http://localhost:8080/SelectedStudent" />--> 
      <add baseAddress="net.pipe://localhost/SelectedStudent" /> 
     </baseAddresses> 
     </host> 
     <endpoint 
      name="internal" 
      address="net.pipe://localhost/" 
      binding="netNamedPipeBinding" 
      contract="AwardManager.Service.ISelectedStudent" 
     /> 
     <endpoint 
     address="mex/pipes" 
     binding="mexNamedPipeBinding" 
     contract="IMetadataExchange" 
     /> 
    </service> 
    </services> 
    <behaviors> 
    <serviceBehaviors> 
     <behavior> 
     <serviceMetadata httpGetEnabled="False"/> 
     <serviceDebug includeExceptionDetailInFaults="False" /> 
     </behavior> 
    </serviceBehaviors> 
    </behaviors> 
</system.serviceModel> 

我試着將其複製到WPF app.config中,但沒有成功。此服務可與控制檯應用程序測試驅動程由於這是我第一次使用WCF,因此我對下一個故障排除步驟感到茫然。我看着another Stackflow question,但無法弄清楚它是否適用於我的情況。有任何想法嗎?

回答

0

它總是你最後看的地方。我的控制檯應用程序測試驅動程序正在調用帶有ServiceReference的COM存根。我在創建ServiceClient的調用之前添加了這行代碼。

string dir = System.IO.Directory.GetCurrentDirectory(); 

這表明客戶端正在測試驅動程序目錄中創建。我將它從我的COM存根複製到測試驅動程序的app.config中。像現在的冠軍一樣工作。

<system.serviceModel> 
    <bindings> 
     <netNamedPipeBinding> 
     <binding name="internal" closeTimeout="00:01:00" openTimeout="00:01:00" 
      receiveTimeout="00:10:00" sendTimeout="00:01:00" transactionFlow="false" 
      transferMode="Buffered" transactionProtocol="OleTransactions" 
      hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="524288" 
      maxBufferSize="65536" maxConnections="10" maxReceivedMessageSize="65536"> 
      <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" 
       maxBytesPerRead="4096" maxNameTableCharCount="16384" /> 
      <security mode="Transport"> 
       <transport protectionLevel="EncryptAndSign" /> 
      </security> 
     </binding> 
     </netNamedPipeBinding> 
    </bindings> 
    <client> 
     <endpoint 
     address="net.pipe://localhost/" 
     binding="netNamedPipeBinding" 
     bindingConfiguration="internal" 
     contract="SelectedStudentReference.ISelectedStudent" 
     name="internal"> 
     <identity> 
      <userPrincipalName value="[email protected]" /> 
     </identity> 
     </endpoint> 
    </client> 
</system.serviceModel> 
0

這導致我的解決方案:服務裁判的東西轉移到「主」 app.config文件,那麼它可以通過「孩子」(WPF)項目中找到。

相關問題