views:

28

answers:

1

I just grappled with an annoying, extremely persistent bug that had me scratching my head for several hours. I'm using C# (.Net Framework 2.0) in conjunction with the built in Settings, which generates an XML file. The settings worked wonderfully... until today. Today, whenever I ran the program from the IDE, it gave me this error:

Configuration system failed to initialize.

Root element missing at (C:\Documents and Settings\... several directories in ... \ user.config)

I checked the folder it referenced, which included a long string of seemingly random characters and didn't exist. I even went so far as to create it and populate it with the necessary user.config file, to no avail.

Eventually, I changed the folder name. I'd just renamed that folder from "NanoMETER#" to "NanoMETE#" temporarily. It worked.

So I got rid of the revision, and added the R back onto the end of "NanoMETE". It errored. Removed the R, it worked. Any folder named "NanoMETER#", exactly as such, crashes when it tries to load the application configuration settings. If I name the folder to anything else, it works beautifully.

I ... I just don't get it. Nowhere in the entire project is the name of the folder referenced, nor is "NanoMETER#" used as a variable anywhere. Does anyone have any idea what could have caused this? I'm just completely stumped. It's probably been one of the most WTF bugs I've had on the project...

+1  A: 

The error message indicates that it can actually open the file, but then finds the file empty or corrupted. Renaming the folder ensures that the user.config file gets recreated, that will indeed solve the problem. If you can't find it back then there's something pretty icky going on with your file system. High time to run a thorough disk scan. Don't quite remember how for XP, chkdsk.exe or scandisk.exe, something like that. Ask at superuser.com

Hans Passant
Alright, I can see how that makes sense. Still, I'll probably go run a scandisk just to be sure nothing weird is up.
KChaloux