VS.NET 2003 is amazing but not without its faults. Those that spend a good part of their day using the designer are all to familiar with the InitializeCoponent bug in ASP.NET and the infamous disappearing controls bug in Windows Forms (which still happens even with the hotfix). Both of the bugs are designer related in that they butcher the code in InitializeComponent. I've finally cobbled together a workaround and thought I’d share it. It’s a little ugly but it works. I started off with source control but that almost tripled the # of check-ins I had and made rolling back a bit of a pain. My alternate solution is below. The post build event (batch file) will copy the file of our choice to the location of your choice and append a timestamp to the end of it. It may seem like overkill to copy the file after each build but I can tell you that it’s been a huge time/frustration saver.
for /F "tokens=2,3,4 delims=/ " %%i in ("%date%") do set FileTimeStamp=%%k-%%i-%%j_ for /F "tokens=1,2,3 delims=:. " %%i in ("%time%") do set FileTimeStamp=%FileTimeStamp%%%i-%%j-%%k
COPY "$(ProjectDir)MainWindow.cs" "$(TargetDir)\Backup\MainWindow_%FileTimeStamp%.cs" /YTo use the script above replace MainWindow.cs with the name the file to backup and $(TargetDir)\Backup\MainWindow with the directory and file name to backup up the file to. Alternatively, if you follow these strict usage guidelines you might not encounter the problem at all. Talk about working in a box. UPDATE Microsoft released hot fixes for the Windows Forms issues! See how they fixed Windows Forms designer bug here. But don't jump for joy just yet, you have to contact MS support for them. WTF?! ...
|