Dynamics CRM doesn’t enable search on Address ZIP/Postal Code by default

In the “oh my, how did that slip through?” category comes this one: in Dynamics CRM 2011, the ZIP/Postal Code field on the Address (CustomerAddress) entity is not searchable by default.

Weirder is that the ZIP/Postal Code fields on the Account, Lead, and Contact entities are searchable by default. Weird only because they use the same underlying table (CustomerAddress).

Keep this in mind when you wonder why you can’t search for additional addresses by ZIP code. Make that ZIP/Postal Code field on the Address entity searchable, and you’re good to go.

Damn the documentation: FtpWebRequest.Timeout default value is NOT Infinite

For the past few weeks, an FTP upload has been failing, rather religiously, with the following .Net error:

System.Net.WebException: The underlying connection was closed: An unexpected error occurred on a receive.

For the FTP upload, I was using the .Net FtpWebRequest class, in a rather simple code snippet:

FtpWebRequest request = (FtpWebRequest)WebRequest.Create(config.Uri);
request.UsePassive = config.UsePassive;
request.Method = WebRequestMethods.Ftp.UploadFile;
request.Credentials = new NetworkCredential(config.UserName, config.Password);

The FTP connection was dropping, but why? The transfer file was rather large (over 50MB), but reading the MSDN documentation for the FtpWebRequest.Timeout property, it was pretty clear that the .Net Framework wasn’t timing out, because:

FtpWebRequest.Timeout Property

Type: System.Int32
An Int32 value that contains the number of milliseconds to wait before a request times out. The default value is Infinite.

I tried active and passive connections; both failed. I checked the firewall; nothing unusual. I tried other external servers; they all failed. What gives?

Finally, exasperated, I tried forcing the timeout:

FtpWebRequest request = (FtpWebRequest)WebRequest.Create(config.Uri);
request.UsePassive = config.UsePassive;
request.Method = WebRequestMethods.Ftp.UploadFile;
request.Credentials = new NetworkCredential(config.UserName, config.Password);
request.Timeout = -1;

Viola! The FTP upload did not fail! Stepping through the code, I found that, contrary to the documentation, the default value for FtpWebReqeust.Timeout is not infinite:

That is right, my friends: contrary to what you read in the documentation, the default value is 100,000 milliseconds, or about 1 minute, 40 seconds.

Lessons learned:

  1. Don’t believe everything you read.
  2. Trust, but verify.
  3. Infinite is not infinite when it is not infinite.