.NET WCF not working in VM

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.

c#
.net
vb.net
wcf
asked on Stack Overflow Feb 3, 2015 by (unknown user) • edited Jul 28, 2017 by BanksySan

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0