As Time Goes By

I looked at the following code and thought it should replace a file’s existing extension with “.xml”.

string newName = null;
newName =
Path.GetFileNameWithoutExtension(
                    fileName +
".xml"
                );

It might be easy to spot in isolation, but when “foo.log” didn’t transform into “foo.xml” on disk, I went looking for the hard stuff first – swallowed exceptions, bad conditional logic, etc. I didn’t see the misplaced paren until later.

string newName = null;
newName =
Path.GetFileNameWithoutExtension(fileName)
                    +
".xml";

Another waste of time was a production app that looked like it was running under a user’s credentials instead of the NETWORK SERVICE account. A quick glance at the badly formatted web.config file seemed to indicate everything was setup properly. Impersonation should only be on for requests in the ManagementStuff directory.

<configuration>   
<
system.web>
   <
compilation debug="true"/>
   <
authentication mode="Windows"/>
   <
authorization>
      <
deny users="?"/>
      <
allow users="*"/>
   </
authorization>
   <
customErrors mode="Off" />      
</
system.web>
   
<
location path="ManagementStuff" />
   <
system.web>
      <
identity impersonate="true"/>
   </
system.web>
</
configuration>

This time I went off looking at IIS settings, machine.config settings, and even had FileMon and Process Explorer running. After some time I returned to the web.config and noticed someone closed the location element tag too early. ASP.NET was using impersonation for the entire application.

<location path="ManagementStuff" >
   <
system.web>
      <
identity impersonate="true"/>
   </
system.web>
</
location>

While on the topic of wasting time – when using Google to search for “Tablet PC”, the first ‘sponsored link’ to appear is www.Dell.com. It’s nice of the Dell sales and marketing department to sponsor this link, considering they don’t sell a Tablet PC. I wonder how long it takes the average web surfer to figure out there are no Tablet’s available, and how many of them feel deceived.

Occam’s razor can save us time with the debugger, but can’t save us from salespeople.

Print | posted @ Tuesday, February 21, 2006 4:04 AM

Comments on this entry:

Gravatar # re: As Time Goes By
by roy at 2/21/2006 2:23 PM

I feel for you. We have an awesome build setup that made myself using NAnt and WiX and one day the build just kept on failing. After wasting half a day, turns out one of the developers had edited an xml file using wordpad! What a waste of time. I then proceeded to show him the wonders of Notepad++. Can't live without it.
  
Gravatar # re: As Time Goes By
by Mitchell Land at 2/22/2006 5:20 PM

Scott,

Not sure why you were searching for a Tablet, but I'm using the tc4200 (HP), and it's pretty good. It's a company machine though, and they opted to remove the Bluetooth components. I'm honestly surprised they left the wireless in.
  
Gravatar # re: As Time Goes By
by scott at 2/23/2006 5:09 AM

Thanks, Mitchell. I've been kicking around the idea of picking one up, but I've also been wondering if I should wait till Vista is out and running on them...
  
Gravatar # re: As Time Goes By
by Fabrice at 3/1/2006 12:56 PM

A way to avoid the first problem may be to use Path.ChangeExtension() :-)
  
Gravatar # re: As Time Goes By
by scott at 3/1/2006 7:05 PM

Good catch, Fabrice :)
  
Comments have been closed on this topic.
Scott Allen
Posts - 869
Comments - 4493
Stories - 14