Fun with MSN Search

If you’re a computer geek, you probably know that MSN’s new search is now in beta. Since I have a mild case of the blogging vanity, I had to do this search. Sweet! (Compare this with Google, where I show up on the second page, despite my efforts to change that. (Damn it!). Although, after doing a Google search for this post, I see that my profile on blogshares comes up on the first page. Reading that blogshares thing is depressing for one with the vanity.) Since it’s still in beta, and Google is just too damn awesome, I’m sticking with Google. But if you give me an MSN Search Deskbar….

Anyway, others have been having some fun with MSN Search. I have to recommend Adam Barr’s searching. Go fast, MSN may change it. Especially the search for “anal sex.”

 

FxCop Globalization Rules and Exception Constructors

Update:

Looks like I was wrong again. (You know what they say about assuming?) Reflector is an even greater tool than I first realized: not only does it show the classes in an assembly, it also shows the resources for the assembly; something my eye does not see and brain does not look for, because I just haven’t been in the situation to really use them. Anyway, it shows them and every assembly in the framework that I looked at (um, two of them) have resources that are filled with? Exception messages. Interestingly, I found a way around the FxCop violation, but you shouldn’t use it unless you really, really intend to fix it later. Do you? Ok, here it is:

… = new MyException( String.Format( System.Globalization.CultureInfo.CurrentCulture, “my exception message“ ) );

End Update

I’ve been using FxCop a lot lately to fix up some of the templates in CodeSmith and some of my code at work. I get this violation a lot:

Do not pass literals as localized parameters.

Most of the cases, all if I’m not mistaken, are for messages in Exception constructors. This got me wondering:

If I install the .NET framework in French (or German, or Italian, or Thai, or Chinese,  or Brazilian Portuguese or …) do I get stack traces from thrown exceptions in that language?

If the answer is no (that’s what I think it is; especially after inspecting the framework with Reflector), FxCop should check to see to which method the literal is being passed, shouldn’t it? And if it should, I should just ignore those violations when I pass a string to an Exception constructor.

This is a tough one: 30 jk.ca points to whomever gets it. I’ll update this post once the answer is found. Good luck. 🙂

What kind of elitist are you?

HASH(0x8b28050)
You speak eloquently and have seemingly read every
book ever published. You are a fountain of
endless (sometimes useless) knowledge, and
never fail to impress at a party. What people love: You can answer almost any
question people ask, and have thus been
nicknamed Jeeves. What people hate: You constantly correct their
grammar and insult their paperbacks.

What Kind of Elitist Are You?
brought to you by Quizilla

Here’s another one for you. [via Wesner Moise]

Apps I use everyday

[Update: forgot a link to the excellent NUnit Gui Make Over. I figured to make up for it, I’ll link to it twice.]

I recently got an upgrade to a much faster machine at work. Doing so made me consider all the apps that I use daily for development. So here they are in no particular order:

  • RSSBandit: for the first two hours at work when I’m supposed to be working. Seriously, the best aggregator for the best price.
  • CLR Profiler: for profiling allocations in applications that run on the CLR.
  • Ethereal: network analysis tool that knows every network protocol known to man; very useful and very free.
  • TcpView: check out what ports are in use at a glance
  • TestDriven.NET: do TDD right in Visual Studio; and attach a debugger to the unit test case that is giving you some trouble
  • NUnit: to see that green, baby! I still use the NUnit GUI. Made over, of course.
  • VS 2003: duh!
  • FxCop: are you designing your libraries with the MS .NET design guidelines? You should be, and this will help you.
  • Regulator: excellent regular expression tool. Let’s you doodle.
  • Reflector: find out how MS did their thing with the Framework.
  • Codesmith: generate strongly-typed collections, data objects, or anything else with this template-based coding generator
  • Resharper: the only good refactoring tool for .NET. It’s not perfect but it’s the best out there. The only developer tool that I’ve been willing to shell out money for. (The rest on the list are all free; well VS isn’t but I got it for free.)
  • Notepad2 and Notepad++: two light weight text editors that do a lot more than Notepad.

Got any others that are indispensible?

Windows Socket Version 2 API error code documentation

[Update: Looks Mike, future PM of System.Net and all ’round genius, cleared things up in the comments. Thanks, Mike. He gets 20 jasonkemp.ca points! Save those up and you may get a toaster. Or a beer since I know you and you live in Victoria. Incidently, before I checked for comments to this post, I opened up MSDN help, typed in “socket“ without quotes and no filter, and found the error codes in a few links. Who knew? 🙂 Now we just have to correct that documentation UdpClient.]

So I’m trying to play with UdpClient from the System.Net.Sockets namespace in good ol’ .NET 1.1.

I’m using the code from the Receive() example in MSDN Help. Almost exactly. Only in my version, the fucking thing always throws a SocketException. Luckily the SocketExpection has an ErrorCode property so that I can “refer to the Windows Socket Version 2 API error code documentation in MSDN for a detailed description of the error.” And yet, I still don’t know what’s going wrong because as far as my local MSDN Library, MSDN for the Internet, and Google are concerned there is no such fucking Windows Socket Version 2 API error code documentation. (In fact, if Google is worth its salt, this post will begin coming up when that string is searched.) All I can use to debug is the stack trace. And it’s not my code that’s being difficult so break points won’t work. Could it be XP SP2? Don’t know; ’cause I can’t for the life of me find that info on MSDN either. I know it’s not Windows Firewall because I tried this code with the Firewall turned off. I haven’t used the excellent Reflector on this either, but I don’t see how that’ll help right now. And I know how to use Google, in case you were wondering! Sometimes Microsoft really pisses me off.

     1:         [STAThread]
     2:         static void Main(string[] args)
     3:         {
     4:             UdpClient udpClient = new UdpClient();
     5:  
     6:             IPEndPoint endPoint = new IPEndPoint(IPAddress.Any,  0);
     7:             try
     8:             {
     9:                 byte[] received = udpClient.Receive( ref endPoint );
    10:  
    11:                 string recvMessage = Encoding.ASCII.GetString(received);
    12:  
    13:                 Console.WriteLine("recvMessage = {0}", recvMessage);
    14:             }
    15:             catch ( SocketException e)
    16:             {
    17:                 Console.WriteLine(e);
    18:             }
    19:             catch( Exception e )
    20:             {
    21:                 Console.Out.WriteLine("e = {0}", e);
    22:             }
    23:  
    24:             Console.ReadLine();
    25:         }

It always throws an exception on line 9. Can anyone tell me why this is failing? 10 jasonkemp.ca points, and my eternal gratitude, to anyone who can. 10 jasonkemp.ca points to anyone can point to good Winsock 2 API documenation also.