Dude, where’s my Window???

I recently wrote a simple utility app in C# that really wasn’t very taxing.  It’s been working fine and has been really useful for me.  However, I went to use it today and it started, appeared in the task bar, but didn’t display a Window!  As far as I could make out, it had simply hung for no apparent reason.  There were no errors, no exceptions, no excessive CPU usage, no disk thrashing – just no Form!

I tried every debugging approach that I knew to get to the bottom of this, but everything told me quite clearly – “your app is running fine”!  In fact, running it under Visual Studio 2005 caused the app to work perfectly – it was only the ‘Release’ build when run outside of VS that exhibited the problem!  

Finally, in desperation, I fired up Spy++, knowing full well that it would be no use for a hang of this sort, and I tried to execute a ‘Move’ by right-clicking on the taskbar.  Interestingly, this showed me that I was trying to move from a ‘Top’ of -32000, and a ‘Left’ of -32000!  This was particularly strange since I loaded these values from the app.config file and I could clearly see that these values were each set as 100!

I searched my whole PC to try and find a different version of the app.config file (or App.exe.config) that might have been cahced, but found nothing.  In the end, I simply decided to code round the problem and to check for negative values being returned, fixing any negatives to zero.  This fixed the problem, but I was curious (and you know what I’m like when I get curious…!) 😉

I looked at my config files after moving my Window and quitting the application.  This should have updated the file, which it clearly did not – it was still set to the defaults.  However, when I re-ran the app, it opened in the previously stored location!!!  So, I was now certain that a private version of the config file was being cached, but not knowing what it was called meant I couldn’t even Google for it!  All that was left was for me to take an educated guess where it might be and start a pain-staking, manual search through the directories to see if anything stood out.

Eventually, I spotted it!  You know when you set the properties for an application in Visual Studio 2005 and you have the option (under ‘Assembly Information’) to set the company name?  Well I’d done just that, and I spotted the company name under C:\Documents and Settings\<user>\Local Settings\Application Data\!  When I looked in here, I found three directories – one being the name of my executable with some seemingly random characters on the end, the other two being the same, but with .vshost inserted before the .exe.  When I looked in here, I found a sub-directory named the same as the version of my assembly which contained a single file – user.config.  You guessed it – the is the cached copy of the app.config file that’s being giving me so much grief!

I hope that this will be useful to someone else and that what I’ve just spent half an hour typing isn’t simply obvious to every other .NET developer in the World….! 😉

About The Author


John is a Senior Solutions Engineer for a U.S. IT company, specialising in Software Defined IT Infrastructure. He has an extensive background in IT and spends way too much time sitting at his PC's, making videos for himself and other Internet marketers and dreaming of spending more time boating. He's also passionate about Jesus.

Comments are closed.