2013-08-28

Where in the world is WCF Test Client?

I keep myself making that question on a new VS install.

It's tipically here:

C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE\WcfTestClient.exe

Although it will change according to your Visual Studio version (i.e. "10.0") and CPU architecture (i.e. "x86").

2013-08-09

Mocking an internal interface with Moq

If by some reason you need to Mock an internal interface using Moq, you might get the infamous exception while running your unit tests:
System.TypeLoadException : Type 'ISomething`1ProxyRandomGuid' from assembly 'DynamicProxyGenAssembly2, Version=0.0.0.0, Culture=neutral, PublicKeyToken=YetAnotherGuid' is attempting to implement an inaccessible interface.

Assuming that you already added the InternalsVisibleTo from your library to your unit test project, you'll also need to add an InternalsVisibleTo to DynamicProxyGenAssembly2. However, unlike the author in the blog post, in my machine it only works if I remove the PublicKey, something like:

[assembly:InternalsVisibleTo("DynamicProxyGenAssembly2")] 

Trouble with MSMQ

This week I had an interesting issue with a project that used MSMQ. The issue was that I was sending messages using the MessageQueue class, but the messages didn't get there. No exception, no error code, nothing in the Event Viewer. Then I started "mmc", and added the "Computer Management" snap-in, and navigated to Services and Applications > Message Queuing. There I found that all my queues were OK (Private Queues), but no message was getting there. Then I found some errors in the "Outgoing Queues" folder, telling me that the queue did not exist.
So, what was the issue? Well, it happens that the NetBIOS name on my machine did not match my computer name. Our machine names are based on a convention which includes the  user surname, and mine is a little bit longer that most my colleague developers, which goes over the 15 character limit for NetBIOS naming conventions. Probably the administrator that configured my machine just cut the last character from the NetBIOS name, and never looked back again...