Category Archives: microsoft

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!

 

how to safely run destructive sql statements

christmas afternoon

This tip is one of those “Why didn’t I think of that before” things when I saw it being used first. You see, sometimes you’re on this production database and you need to run some SQL statements in Microsoft SQL Management Studio. Statements that if you mess them up will end up ruining your customer’s day, and most certainly yours too.
Of course you’ve already taken a backup, but that isn’t perfect. It takes time to restore those and the most recent changes might be lost. The database might also be humongous, making backup & restore operations rather annoying.

Enter:

BEGIN TRANSACTION

You know this! Before you run any statement doing anything destructive on your database, first run the BEGIN TRANSACTION statement. It feels like spring doesn’t it? With fluffy little bunnies hopping around merrily in the green grass and yellow flowers.
Whatever you run next, nothing will actually happen until you run:

COMMIT TRANSACTION

If in the meanwhile however that delete statement turns out to act like the Spanish Flue and wipes out half of the precious records stored in your database table, there’s always:

ROLLBACK TRANSACTION

Undo. Restore from last save. You don’t lose a life.
Awesome. More fluffy bunnies.

One thing to keep in mind though. As long as your transaction isn’t committed your statements will be putting locks on rows and perhaps even tables. The longer you keep those, the more chance other people’s queries will have to wait for you to release those locks and might even time out. This is bad. So keep your transaction trickery as short as possible.

For more details on those magical statements, see MSDN.

WCF service throws an msmqBinding error on a http binding

™™™™™™

So you have this WCF service with a typical HTTP binding on it. When you try to use it with a client, or when you simply open up the .svc file link in your browser, it throws an error message telling you your MSMQ binding is incorrect. MSMQ!

Contract requires TwoWay (either request-reply or duplex), but Binding ‘NetMsmqBinding’ doesn’t support it or isn’t configured properly to support it.

But it’s a HTTP binding! Of course it’s two-way!

It took me a while to figure out what was happening, but apparently it was all caused due to a typo in the binding configuration for the service in the web.config.
So when you run into this, check your web.config binding configuration for that service. An incorrect class path or class name in the service’s name attribute can be causing this effect. Also check for mismatches between the used class in the binding and the class used in the service’s .svc file.

I’m guessing the “missing binding” is causing WCF or WAS (which is installed) to try and activate the MSMQ protocol as a default oslt. I don’t get it really. So if someone reads this and understands why this misleading error occurs, feel free to enlighten me.

Photo by greg biché, cc-licensed.

install multiple windows applications at once

patient

Getting a new computer is awesome. Installing all your most frequently used and essential bits of Windows software on it isn’t. So I searched the web for something that could do this boring task for me. Computers are usually good at that. I remember using something called AppSnap in the past, but that hasn’t been updated since 2008 which makes it so 2008 that I didn’t think of using it anymore. A few well placed Google queries later I ended up with something called Ninite.

Ninite gives you a list of well-chosen and good free and open source software (I’m just saying this cause most of my personal favs are in the list), check some boxes and download a lightweight installer. After that, the installer gets the list of your preselected software and goes off to download them one by one and installs them for you. Like a nice little helper robot monkey oslt. Awesome.
Saved me a bunch of time, which I used to write this little review. Ain’t that something!

Photo by Robert S. Donovan, cc-licensed.

visual studio 2010 becomes slow after saving on Windows 7

Rust and oil inside "Niles machine tool" (HDR)

Ran into this annoying bugger of a problem with Visual Studio 2010 on Windows 7 where every time I saved a file (any file, no matter how large or small it was) the GUI started reacting extremely slow on me. Menu’s didn’t react, keystrokes didn’t appear, scrolling didn’t work. It acted like a whole bunch of stuff was going on, but nothing really was. After a few minutes or so responses where back to normal, until I saved a file again…

While it was happening CPU usage of devenv.exe was fine (very low). Cleaning the solution didn’t help either, which in some cases fixes odd VS behaviour. In short, I was at a loss. Googling for a solution didn’t really bring up a solid answer, until I found a post that mentioned something about jumplists in Windows 7 and VS 2010 being slow. In that post the antivirus software is blamed but that was not the issue in my case, since the issue only started occurring recently without any changes to my setup.

Using the Systems Internals (great tools there btw if you want to dig deeper into your Windows system) file monitoring tool I noticed that a file in a specific path was sort of hanging things. When I looked up the file it did point to those so-called jumplist thingies again. After clearing these shortcut files, VS started acting like normal again.

So, if you’re having issues with a slow VS 2010 on Windows 7 on saving, try clearing the jumplists like this:

  1. Right-click the Start button
  2. Choose Properties
  3. Uncheck both checkboxes under the Privacy group
  4. Click the Apply button
  5. Re-check both checkboxes
  6. Press OK

If you’re lucky, VS should be running smooth as butter again.

Photo by Morgennebel, cc-licensed.

cleaning up disk space on windows round-up

I installed my PC initially with a separate C drive dedicated for Windows and system specific files. Unfortunately it turned out that I picked that drive too small as I didn’t foresee that there is plenty of software out there that simply won’t allow you to install to a different location than C:\Program Files. To add to that, Windows itself had its share of service packs and updates which doesn’t actually make it smaller in size either. And then there’s the .NET framework, in all it’s versions.

So soon I ran into the very annoying issue that Windows kept telling me I was running low on disk space on my C drive. This eventually causes updates unpacking to your temp folder (also on the C drive of course) to fail, stuffing up even more hard drive space. Over the years I found a few tricks to avoid or fix this issue and as a good blogger I also documented those right here.

Here’s a little round-up of what you can do to free up some disk space, or create some more:

Spread the word if any of these tips helped you out and saved you from wasting hours reinstalling your machine. It saved me from doing just that a few times, so I’m hoping this post can be a huge time-saver for anyone coming across it.

will windows phone 7 cut it?

867-5309

A few weeks ago I was in the lion’s den at Schiphol watching a presentation of the new to come Microsoft Windows Phone 7. It was supposed to be Windows Phone development thing, but it turned out to be more of a marketing rant than a geeky app development preview. Bummer.

But hey, since we where there, we might as well get a glance of that sexy (or so they want us to believe) new phone the MS guys came up with right? Well, apparently the phone’s hardware is going to be almost completely fixed. No matter what brand you’re getting the GPU, CPU, amount of RAM, OLED display (including resolution) and Windows buttons (like the Android buttons) are fixed. If it doesn’t that the specs set my MS, it’s not going to be a WinPhone. Manufactures do get to play with the design, a potential hardware keyboard and the on board camera which has to be at least 5 mega pixels. Apparently that’s what the manufacturers want. When it comes to competing it’ll be all about making a pretty phone then I guess.

That the hardware is fixed also makes it easier to to maintain the OS and the device drivers. Both of these will be in the hands of the Redmond lads which is interesting. Microsoft will be the one to blame when the phone doesn’t work as expected and not Motorola, HTC, Samsung or whoever built the damn thing. This could be a good thing for quality and could avoid issues like on Android phones where one brand of phone gets it’s OS updates a lot faster than the other.

When it comes to the OS features it’s what you expect and know of the competing phones. It has a native IE, searches using Bing and integrates as expected with a bunch of online Microsoft services like Live/Hotmail, XBox Live (if available in your country) and the Zune for music (if available in your country). This sort of makes me think about iTunes lock-in on the iPhone. It was to be expected MS wasn’t going to shy away from some vendor lock-in mechanism’s here and there right. This phone is going to integrate nicely with your Windows Media Player and your Windows 7 or Vista OS of course. Oh yeah and they support Flash. They made sure that was clear.

So what about apps? Well, they are mainly taking the iPhone route there. There’s going to be an app-store and they are going to approve every app published on it. All under the guise of quality assurance they are training a bunch of developers in India to routinely approve each submitted app before it gets unleashed on their phones. In fact, they are going to sign each app with a Microsoft certificate after it’s approved. This means that as an app developer you have to submit your source code as well. Creepy. Releasing apps through the Marketplace  isn’t going to be cheap either. 99$ a year. You then get 5 apps “free” and for each additional app you have to pay an extra 20$. So watch out how you version those apps I’d say. 99$ is the same cost as for access to the the iPhone app store. Google’s Android store is cheaper with only a 25$ to pay.

Developing the apps is done with Visual Studio. You can use the freely downloadable (but crippled) Visual Studio Express editions to develop a WP7 (WordPress 7? No! Windows Phone 7!) app using C# (or any other .NET language I suppose) and a WPF-like XAML for the user interface. For developers working in .NET this will make app development a breeze using their trusty and known toolkit. Integration with a bunch of online Microsoft services to make your apps location aware, do searches using Bing and use apps in the Azure cloud are also available. Interesting to see if these idea’s are going to give this phone the edge it’ll need to drag people away from their Android devices and iPhones.

Personally I’m hooked on Android. Both WP7 and iPhone reek of vendor lock-in to me which is enough to not even consider them. DRM’d Zune downloads and iTunes requirements annoy me, but since not everyone cares about these issues I’m sure there will be adopters for this as well.

If hipsters go for Apple phones and geeks go for Android phones, will mom and pop go for the Windows phones?

Photo by bitzcelt, cc-licensed.