StrataFrame Forum
Home
»
StrataFrame Application Framework - V1
»
WinForms (How do I?)
Bloated Designer.cs file
http://forum.strataframe.net/Topic23931.aspx
By Aaron Young
-
7/28/2009
Hi guys,
This is a general observation rather than a specific SF problem.
I noticed by total accident that the designer.cs file for a relatively large form contained references to comboboxes that were no-longer displayed on the form and which I thought had long since been deleted. The form had 15 SF comboboxes but the designer file created, initialized and databound 27 comboboxes - the other 12 were never shown or used and were totally hidden. During early form development I have no doubt I added and removed the other 12 comboboxes but their references remained within the designer file for some reason. Since removing the 12 "ghost" comboboxes from the designer file, the form loads faster - dramatically so in the form designer which always stalled for 20 seconds on loading after clicking on the first field. The problem isn't only restricted to the combobox as there are numerous labels as well.
It appears Visual Studio is not very good at cleaning up the designer file. If you have a reasonably complex form which has undergone editing over a period of time, it would be worth checking the designer file if you are experiencing slow loading and stalling in the form designer.
I am off to try and find a utility which will scan the designer file and report on un-used objects.
Aaron
By Russell Scott Brown
-
7/28/2009
Thanks for pointing this out. I would never have thought to look for this type of thing happening.
Hope you find a good utility to do this.
By Aaron Young
-
7/28/2009
Just as a follow-up, the final count of "ghost" controls in this form is:-
Combobox x 12
Checkbox x 3
Date time picker x 4
Label x 33
NumericUpDown x 1
Textbox x 21
ThemedGroupBox x 5
All of these controls appeared in the designer.cs with settings that should have made the controls visible and positioned correctly on the form to have been seen - yet none were visible in the designer or at runtime. None of these controls appeared in the document outline yet they were listed in the properties window.
I don't know how this happened but the designer.cs file is now much smaller after they have been removed and it loads faster
I have started checking other forms and the next one in the sequence has similar problems so it doesn't look like a one off.
Aaron
By Trent L. Taylor
-
7/29/2009
I have seen this once or twice, and we have some massive forms, but generally this happens under some relatively stricti and strange conditions. Like I said, I saw this once before a while back and haven't seen it since. I think it had to do with the assembly being loaded into the AppDomain and not being dumped when run (F5) through VS while the designer is open. To prevent this, I think that if you totally close the designer and run this is less likely to happen.
By Aaron Young
-
7/29/2009
Ah that could explain it. I have a habit of keeping the designer open when I hit F5.
Thanks for the info - will try it and keep a lookout.
Aaron