As Time Goes By

Tuesday, February 21, 2006

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.


Comments
roy Tuesday, February 21, 2006
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.
Mitchell Land Wednesday, February 22, 2006
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.
scott Thursday, February 23, 2006
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...
Fabrice Wednesday, March 1, 2006
A way to avoid the first problem may be to use Path.ChangeExtension() :-)
scott Wednesday, March 1, 2006
Good catch, Fabrice :)
Comments are now closed.
by K. Scott Allen K.Scott Allen
My Pluralsight Courses
The Podcast!