2011-12-17 81 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)项目中找到。