Cannot start a WCF Service when connected on VPN

I found this very irritating behavior with WCF (at least with the Vista RC2 runtime of WinFX, I have not tried it with the other builds yet). When I am on an active VPN connection (in this case, connected to the Avanade corporate network) and I try and start a new WCF Service it fails spectacularly with a NetworkUnreachable exception. When I disconnect from the VPN everything is fine and executes as expected.

Also, some more context to my environment – the VPN type is L2TP IPSec and the service is of a unsecure netPeerTcpBinding type. I cannot even instantiate the ServiceHost class – so I don’t even get to the point of trying to configure the address, bindings and contract for the ServiceHost.

I have the exception details below. Although the stack trace itself is meaningless I have included it here for the sake of completeness.

How weird is that? Is it a bug or is that how it is supposed to work? Can anyone else also reproduce this?

Exception Details:

Error Message: “A socket operation was attempted to an unreachable network”

Socket Error Code: System.Net.Sockets.SocketError.NetworkUnreachable

Error Code: 10051

Stack Trace:

at System.ServiceModel.AsyncResult.End[TAsyncResult](IAsyncResult result)
at System.ServiceModel.Channels.PeerNodeImplementation.SimpleStateManager.EndOpen(IAsyncResult result)
at System.ServiceModel.Channels.PeerNodeImplementation.SimpleStateManager.Open(TimeSpan timeout, Boolean waitForOnline)
at System.ServiceModel.Channels.PeerNodeImplementation.Open(TimeSpan timeout, Boolean waitForOnline)
at System.ServiceModel.Channels.PeerChannelListenerBase.OnOpenCore(TimeSpan timeout)
at System.ServiceModel.Channels.PeerChannelListenerBase.OnOpen(TimeSpan timeout)
at System.ServiceModel.Channels.PeerChannelListener`2.OnOpenCore(TimeSpan timeout)
at System.ServiceModel.Channels.PeerChannelListener`2.OnOpen(TimeSpan timeout)
at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
at System.ServiceModel.Dispatcher.ChannelDispatcher.OnOpen(TimeSpan timeout)
at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
at System.ServiceModel.ServiceHostBase.OnOpen(TimeSpan timeout)
at System.ServiceModel.Channels.CommunicationObject.Open(TimeSpan timeout)
at System.ServiceModel.Channels.CommunicationObject.Open()
at QuickReturnTraderChat.Main.StartService() in C:\Users\Amit Bahree\Documents\Visual Studio 2005\Projects\QuickReturnTraderChat\ChatApplication\Main.cs:line 43
at QuickReturnTraderChat.Main.Main_Load(Object sender, EventArgs e) in C:\Users\Amit Bahree\Documents\Visual Studio 2005\Projects\QuickReturnTraderChat\ChatApplication\Main.cs:line 89
at System.Windows.Forms.Form.OnLoad(EventArgs e)
at System.Windows.Forms.Form.OnCreateControl()
at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
at System.Windows.Forms.Control.CreateControl()
at System.Windows.Forms.Control.WmShowWindow(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
at System.Windows.Forms.ContainerControl.WndProc(Message& m)
at System.Windows.Forms.Form.WmShowWindow(Message& m)
at System.Windows.Forms.Form.WndProc(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.SafeNativeMethods.ShowWindow(HandleRef hWnd, Int32 nCmdShow)
at System.Windows.Forms.Control.SetVisibleCore(Boolean value)
at System.Windows.Forms.Form.SetVisibleCore(Boolean value)
at System.Windows.Forms.Control.set_Visible(Boolean value)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.Run(Form mainForm)
at QuickReturnTraderChat.Program.Main() in C:\Users\Amit Bahree\Documents\Visual Studio 2005\Projects\QuickReturnTraderChat\ChatApplication\Program.cs:line 18
at System.AppDomain.nExecuteAssembly(Assembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()

Published by

Amit Bahree

This blog is my personal blog and while it does reflect my experiences in my professional life, this is just my thoughts. Most of the entries are technical though sometimes they can vary from the wacky to even political – however that is quite rare. Quite often, I have been asked what’s up with the “gibberish” and the funny title of the blog? Some people even going the extra step to say that, this is a virus that infected their system (ahem) well. [:D] It actually is quite simple, and if you have still not figured out then check out this link – whats in a name?

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.