Logan1337

I deleted a resource that I (thought I) wasn't using and all of a sudden visual studio craps out some message boxes telling me all it can't find a certain file, etc, and it wouldn't shut up so i put the file back into the resources directory manually and it finally stopped beeping at me, but when I went back to my form, my menu strip, tool strip and context strip were all empty!

I checked the .Designer.cs file and all of the definitions for the items were still there, but all of the AddRange()s were gone!

This is unbelievably frustrating, my file is a complete mess now because I've had to go back and manually create these AddRange() calls, and half of the 20 or so toolstrip separators i don't know where they should go so most of them are just floating around; i had to create new ones and now i have a lot of garbage.

Anyway is this a known problem I think it has happened to me before on a smaller scale. I was wondering are there any utilities for cleaning up a .Designer file It seems to me they can get awfully messy with control defs that aren't even used anymore and unbound defs.


Re: Windows Forms Designer Visual Studio just trashed my toolstrips!!

theblueeyz

Hi there,

Yes, this is a known issue in the Designer. Actually, it's not really a bug - it's the consequence of the designer throwing an exception and not continuing its business. When the exception gets thrown before the designer completes building a control, the control will get lost, as you're experiencing.

The solution to this is to make sure the designer never throws an exception . Since that seems to be impossible, I have set up myself a repository on my computer where I check in my code periodically. If the designer craps out on one of my forms or controls, I will simply check out the old copy and if there have been changes since, I'll just redo them. This is generally easier than going in and repairing all of the AddRange() calls by hand.

If you don't want to go to the extent of setting up your own repository (although TortoiseSVN makes it ridiculously easy to set up a local repository), you can just keep backup copies in zip files or something. That's what I did for the longest time.





Re: Windows Forms Designer Visual Studio just trashed my toolstrips!!

Logan1337

Yes I suppose this is what I will have to do. It's a shame VS doesn't do this automatically, considering that the "bug" is well known.

The problem as I see it stems from the extremely complex system of generating source code, as opposed to storing the visual information in its own format. Perhaps WPF will be more to my tastes in this regard.

I've decided to redesign my form from scratch, which will take a bit of work, but at least it will be clean. I can't stand to have dirty resources in the background of my application.

Thanks for the quick reply.




Re: Windows Forms Designer Visual Studio just trashed my toolstrips!!

theblueeyz

 Logan1337 wrote:
I've decided to redesign my form from scratch, which will take a bit of work, but at least it will be clean. I can't stand to have dirty resources in the background of my application.


I can't stand it either and I've rebuilt my forms several times too. That's part of what encouraged me to finally install a repository, actually, because I lost a very complex form once that took a day to rebuild and I didn't want to lose that kind of time ever again.