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?

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
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()