geek microsoft programming software tips

WAS crashes IIS 7 while searching for unexisting services for msmq endpoints

And now: a no thrills .NET WCF technology post in the hope of saving some developer’s time while trying to figure out wtf is going wrong.

The problem looks like this:

Your w3wp process crashes, or your IIS application pool gets stopped for no clear reason. Restarting it only causes it to stop again after a few seconds.
Deactivating the Net.Msmq Listener Adapter in the service control panel makes the problem stop.

Your Windows event log shows errors like this:

An unhandled exception occurred and the process was terminated.
Application ID: /LM/W3SVC/1/ROOT
Exception: System.ServiceModel.EndpointNotFoundException

Message: The service ‘~/foobarQueue’ does not exist.

StackTrace:    at System.ServiceModel.ServiceHostingEnvironment.NormalizeVirtualPath(String virtualPath)
at System.ServiceModel.Channels.MsmqHostedTransportManager.HostedBindingFilter.MatchFound(String host, String name, Boolean isPrivate)
at System.ServiceModel.Channels.MsmqBindingMonitor.MatchQueue(MatchState state)
at System.ServiceModel.Channels.MsmqBindingMonitor.ProcessFoundQueues(MessageQueue[] queues, Dictionary`2 knownQueues, Boolean isPrivate)
at System.ServiceModel.Channels.MsmqBindingMonitor.OnTimer(Object state)
at System.ServiceModel.Channels.IOThreadScheduler.CriticalHelper.WorkItem.Invoke2()
at System.Security.SecurityContext.Run(SecurityContext securityContext, ContextCallback callback, Object state)
at System.ServiceModel.Channels.IOThreadScheduler.CriticalHelper.WorkItem.Invoke()
at System.ServiceModel.Channels.IOThreadScheduler.CriticalHelper.ProcessCallbacks()
at System.ServiceModel.Channels.IOThreadScheduler.CriticalHelper.CompletionCallback(Object state)
at System.ServiceModel.Channels.IOThreadScheduler.CriticalHelper.ScheduledOverlapped.IOCallback(UInt32 errorCode, UInt32 numBytes, NativeOverlapped* nativeOverlapped)
at System.ServiceModel.Diagnostics.Utility.IOCompletionThunk.UnhandledExceptionFrame(UInt32 error, UInt32 bytesRead, NativeOverlapped* nativeOverlapped)
at System.Threading._IOCompletionCallback.PerformIOCompletionCallback(UInt32 errorCode, UInt32 numBytes, NativeOverlapped* pOVERLAP)

What’s happening:

The problem is in the Net .Msmq Listener for the Windows Process Activation Service (or WAS for short). WAS checks all your MSMQ queues on the system and tries to figure out if there are any WCF services that it should poke to start reading the messages in the queues. Problem is in the case mentioned above there are also queues on the system which do not have WCF services that process them. WAS tries to activate a service for this “foobarQueue” anyway, which results in an exception.

And here is how you fix it:

  1. Make sure all WCF services that should be processing queues are in a virtual directory on IIS. For example http://localhost/foo/foobarservice.svc
  2. The queues to process will also have to resemble this virtual directory in the queue-name, like: .\private$\foo/foobarservice.svc
  3. Set your web site’s MSMQ bindings to localhost/foo instead of just the default localhost.
    You do this in the IIS Management tool by right clicking your web site, then click Edit Bindings in the pop-up, select the MSMQ binding and edit the bindings’ information as mentioned above.
msmq binding screenshot


That should do the trick.
Good luck!


2 replies on “WAS crashes IIS 7 while searching for unexisting services for msmq endpoints”

Yeah. I was equally surprised I couldn’t find a working solution for this problem either on most sites, which is why I put it up here as well. But I guess it isn’t very common indeed.

Thanks for the feedback. It might help whoever finds this post next.

This is one of handful of sites that talk about this issue. I’m surprised it wasn’t corrected in a fix pack years ago. I guess not many people need to mix WCF/non-WCF queues on the same machine.

Sadly, your tip only got me half way there. After adding the virtual directory path to the localhost binding, WAS would no longer crash but MSMQ Auto-activation stopped working.

The fix for me was to install AppFabric for Windows Server v1.1. (Must have for anyone using WAS/IIS hosted WCF services or WF applications.) I was also able to change the binding back to just “localhost”.


Leave a Reply

Your email address will not be published. Required fields are marked *

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