2

As the question title states, my WCF communications do not work when running in a VM environment. The VM is Windows 7 x64 same as the host system.

I have a .Net service running with a .Net windows form client that attempts to connect to the service. On the physical machine, it works without any errors. When I run it in the VM I get an error when trying to register with the service. The error is

There was an error reading from the pipe.  The pipe has been ended. (109, 0x6d).

The HResult value in the exception is

-2146233087 (0x80131501)

and the stack trace ends at

System.ServiceModel.Channels.PipeConnection.Read()

I can't see it being a coding issue if it works on the host system. I also reuse the same code skeleton in some other projects that work without any problem (although I haven't tested those in the VM). But because people generally ask here are some snippets

Interface definition

<ServiceContract(CallbackContract:=GetType(ClientCallback))> _
Public Interface ClientInterface
    <OperationContract(IsOneWay:=False)> _
    Function RegisterClient() As Integer

    <OperationContract(IsOneWay:=False)> _
    Function ShutDown() As Integer
End Interface

Service implementation

<ServiceBehavior(InstanceContextMode:=InstanceContextMode.Single, IncludeExceptionDetailInFaults:=True, ConcurrencyMode:=ConcurrencyMode.Single)> _
Public Class ClientFunctions
    Implements ClientInterface

    Public Function ShutDown() As Integer Implements ClientInterface.ShutDown
        'Do Stuff
    End Function

    Public Function RegisterClient() As Integer Implements ClientInterface.RegisterClient
        Dim channel = OperationContext.Current.GetCallbackChannel(Of ClientCallback)()
        'Do Stuff
    End Function
End Class

Service pipe setup

Try
    gClientPipe = New ServiceHost(GetType(ClientFunctions), New Uri() {New Uri("net.pipe://localhost")})
    gClientPipe.AddServiceEndpoint(GetType(ClientInterface), New NetNamedPipeBinding(), "ClientSvc")
    gClientPipe.BeginOpen(AddressOf OnConnectPipe, gClientPipe)
Catch ex As Exception
    'Error
End Try

Client code to connect

Dim cscb As New ClientCallbackClass
Dim ret As Integer = 0

Try
    gCaPipeFactory = New DuplexChannelFactory(Of ClientInterface)(cscb, New NetNamedPipeBinding(), New EndpointAddress("net.pipe://localhost/ClientSvc"))
    gCaPipeProxy = gCaPipeFactory.CreateChannel()

    ret = gCaPipeProxy.RegisterClient()  <- ERROR
Catch ex As Exception
    ret = 0
End Try

I'm running as admin on both host and VM so unless there is some other permissions involved, I can't see that being the problem same with any isolation restrictions between service and application.

It'd be nice if the exception was more detailed because I'm having trouble figuring this one out.

BanksySan
  • 27,362
  • 33
  • 117
  • 216
  • How do you configure network on your VM? Is it configured to be in the same network, not NAT? EDIT: I guess the problem is in invalid data being transferred, look in these threads: http://stackoverflow.com/questions/15836199/wcf-namedpipe-communicationexception-the-pipe-has-been-ended-109-0x6d and http://stackoverflow.com/questions/22334514/wcf-named-pipe-error-the-pipe-has-been-ended-109-0x6d – Orif Khodjaev Feb 03 '15 at 20:29
  • VM uses a bridged connection but I just tried NAT and still same error. Read both of the linked articles already and neither helped. Thanks though. –  Feb 03 '15 at 20:52

0 Answers0