Cut and Paste is NOT your friend!

Spent 2 fruitless hours debugging an ASP.NET development environment this morning. I’d changed the source code using a replace all type find/change to upgrade the error logging, when this didn’t work I reverted the source code and from there-on in the system hung whenever I tried to log on.

Checked I could still use my compiled dev system and that was fine. Ran Windiff to compare both sets of source code and they matched except for the 3 changes I knew about. Rebuilt the Visual Web Developer 2005 Express project from scratch and reviewed countless futile google hits. Even ran the development environment for a different application and all of the above worked perfectly.

By elimination, this left the error SOMEWHERE in my source code … no s**t sherlock! So with heavy (as it turned out blinkered) coding eyes I looked again at the Error Logging function, yep seems fine. Or so I thought, how can it fail if the app compiles ok during load right?

The answer comes from overuse of our old friend cut and paste. I’d very sensibly made a copy of the original function to work on. Always leave yourself a way out – 20 years of IBM system programming taught me that. But I’d inadvertanly ended up with an exact duplicate line of code. Compiles fine of course but is complete semantic crap AND this routine is multi-purpose and also used during log-on and I think you can now see where this is going. Never make rookie coding errors in common error logging functions, it wastes your life 🙁

Leave a Reply

Your email address will not be published. Required fields are marked *