Home > Net >  PipeException on local WCF service
PipeException on local WCF service

Time:12-02

I'm currently migrating a winforms app to WPF and the last thing I need to do is to migrate a WCF service

Config file sender side :

<behaviors>
  <serviceBehaviors>
    <behavior name="NetPipeBehavior">
      <serviceMetadata httpGetEnabled="false" httpsGetEnabled="false" />
      <serviceDebug includeExceptionDetailInFaults="True" httpHelpPageEnabled="True" />
    </behavior>
  </serviceBehaviors>
</behaviors>
<services>
  <service name="MyLibrary.WcfServiceController.GuiController" behaviorConfiguration="NetPipeBehavior">
    <endpoint address="" binding="netNamedPipeBinding" contract="MyLibrary.WcfServiceController.IGuiController" />
    <endpoint address="mex" binding="mexNamedPipeBinding" contract="IMetadataExchange" />
    <host>
      <baseAddresses>
        <add baseAddress="net.pipe://localhost/GUI-ORG/" />
      </baseAddresses>
    </host>
  </service>
</services>

Client side :

<bindings>
  <netNamedPipeBinding>
    <binding name="NetNamedPipeBinding_IGuiController"/>
  </netNamedPipeBinding>
</bindings>
<client>
  <endpoint address="net.pipe://localhost/GUI-ORG/" binding="netNamedPipeBinding"
            bindingConfiguration="NetNamedPipeBinding_IGuiController"
            contract="GuiUpdaterReference.IGuiController" name="NetNamedPipeBinding_IGuiController">
  </endpoint>
</client>

I have a wrapper looking like this :

public class GuiControllerClientWrapper
{
    private readonly LaunchType _launchType;
    private readonly GuiUpdaterReference.IGuiController _gc;

    public GuiControllerClientWrapper(LaunchType launchType)
    {
        _errorSent = false;
        _launchType = launchType;
        _gc = new GuiControllerClient();
        if (launchType == LaunchType.Manual)
        {
            ((GuiControllerClient)_gc).Open();
        }
    }

    /* other functions */
}

The exception occurs when calling Open() : EndpointNotFoundException: There was no endpoint listening at "net.pipe://localhost/GUI-ORG" that could accept the message. This is often caused by an incorrect address or SOAP action. See InnerException, if present, for more details.

InnerException is the following : The pipe endpoint 'net.pipe://localhost/GUI-ORG' could not be found on your local machine

and then a stacktrace pointing to my wrapper calling the open function

The thing is, if I add my old winforms GUI in the project and resintall everything, it does actually work, messages are sent and everything is normal

I have tried

  • using diagnostics, but it didn't give me any information I can work with
  • changing the address
  • recreating/updating the service reference

What am I missing ?

CodePudding user response:

Check if "Net.Pipe Listener Adapter" service is running in Services management console.

Start Windows service -> Net.Pipe Listener Adapter service 

No endpoint listening at net.pipe

CodePudding user response:

Found the problem, and it wasn't WCF that at fault even if the exception could have helped me

I have a service windows that runs everyday some code to check a local AD and do stuff I also have a GUI that allows me to control the service and start the processing manually

When the button is clicked, an endpoint is started on the client (to have updates through a progressbar) but I didn't know that WPF rises an exception when a backgroundworker accesses the main thread (which wasn't the case in WinForms).

My background worker would start, read the data source and then crash, going directly to the RunWorkerCompleted event that closes the endpoint

Here's where WCF could have helped me a bit more : when I started messing around with the background workers, the exception changed it was now telling me that the communication channel was closed prematurely

My code now uses a safe access to the UI thread, which make the channel stay alive as long as necessary

  • Related