0

Bear with me for a moment, I want to layout the whole picture. I have a WPF application (.exe) which needs to open and display a window when a COM object (VB6 macro) calls an application method. I've made one managed code project in the .exe solution COM visible and the VB6 macro successfully calls a method on this managed code project (COM stub).

My COM stub receives the method call and runs Process.Start on the WPF exe passing in command line arguments the first time. My application starts as expected. I now need to send data from the VB6 macro, through my COM stub and into the WPF exe on successive calls. I added a WCF project to my WPF exe solution producing a "netNamedPipeBinding" service. I've added a ServiceReference in the COM stub to talk to the WPF exe. I've tested the WCF service separately with a console application and it works. I've built the COM stub ServiceReference using the same Metadata Address as my test cases, and it constructed the reference normally.

My test driver calls the COM stub method and the WPF application starts. My next call to the COM stub tries to instantiate the service client and I get the dreaded error: "Could not find endpoint element with name 'internal' and contract 'SelectedStudentReference.ISelectedStudent' in the ServiceModel client configuration section."

Here is the contents of my app.config in my WCF service project part of the WPF exe solution.

 <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>

I've tried copying this into the WPF app.config, without success. This service works with a console app test driver. Since this is my first experience with WCF, I'm at a loss for the next troubleshooting step. I looked at another Stackflow question but couldn't figure out if it applied to my case. Any ideas?

Community
  • 1
  • 1
JimBoone
  • 554
  • 1
  • 7
  • 27

2 Answers2

0

This led to my solution: move the service ref stuff to the 'main' app.config file,then it can be found by the 'child' (wpf) project.

Gary Huckabone
  • 402
  • 3
  • 10
0

It's always the last place you look. My console app test driver was calling the COM stub which carried the ServiceReference. I added this line of code just before the call that created the ServiceClient.

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

This showed that the client was being created in the test driver directory. I copied this from my COM stub into the app.config for the test driver. Works like a champ now.

<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="me@xyz.com" />
         </identity>
      </endpoint>
   </client>
</system.serviceModel>
JimBoone
  • 554
  • 1
  • 7
  • 27