October 04, 2003
Visual C# .NET Gotchas
Design Gotchas
- Properties of New project: When creating a new project that will be referred to by the main project in your solution, you might wonder what properties can be customized so as to keep the projects more cohesive. The following might be obvious to you but not to a novice like me: the default namespace property can be set to be the same as the main project's; however, the assembly name has to be unique.
- Typed DataSet in a Separate Project: Separating your code into separate projects can have unexpected consequences. When you create a typed dataset by designing an XML Schema using the built-in XML Designer, you would expect your dataset to be listed as a referenced Typed DataSet when dragging the Dataset icon from the Toolbox onto a form. This does happen if the dataset and the form are in the same project. But if they're in separate projects, you won't be able to find it, even after you've properly added a reference to the dataset's project. What is not explained in the documentation is that you will need to build the dataset's project first, before it will listed by "Referenced Datasets..." in the drop-down.
- Disappearing User Controls from Separate Project: If you define a user control in a separate project, you might suffer from disappearing control instances when building. Take the situation where you define a new user control in a project separate from your main form's project. Assume you already had a proper reference from the main form's project to this separate control project. If your main form contains an instance of your new user control and you rebuild, you might see the control instance disappear in front of your eyes. What you need to do to fix this problem is delete the reference and re-create it. This might even be considered a bug.
- Missing Form Resize Handles: If you have a user control that takes up all the space of your form, you won't be able to find the resize handles of either the form or the occupying control. So how do you resize them? No idea. Just avoid letting controls take up all the space in the form in the first place; leave a bit of margin at least on one side.
Visual Studio .NET 2002 Bugs
These are some of the annoying bugs that I encountered when using this 7.0 version of Microsoft Visual Studio .NET.
- Intelli-non-sense: As you're typing code into the text editor, Visual Studio (VS) sometimes seems to lose track of how to parse it. What happens is that all the syntax coloring disappears and Intellisense's completion features stop functioning. I'm not exactly sure what triggers this annoying behavior.
- Designer code corruption: Once in a while, VS will actually corrupt code. Stupidly, but fortunately, it seems to only corrupt its own designer-generated code. For example,
this.button2.Anchor = (System.Windows.Forms.AnchorStyles.Bottom |
System.Windows.Forms.AnchorStyles.Right);
will become
this.button2.Anchor = (System.Windows.Forms.AnchorStyles.Bottom |
stem.Windows.Forms.AnchorStyles.Right);
You find out when you compile and get a syntax error.
- TabControl in Designer: Designer has the nice feature that allows you to click on TabPages of a TabControl as it would behave at run-time. You can even click on the left and right arrows. But somtimes, the TabControl stops working and you can no longer scroll through or click on the tabs.
- Failed compilation due to locked DLL: Sometimes it takes two consecutive compilations to get the solution buil because the compiler says that the DLL is lockedt. This can happen if the Object Browser is opened. So just close it.
Posted by juliob at October 04, 2003 10:01 PM
Regarding "Disappearing User Controls from Separate Project": The Microsoft patch did not work for me. The bug only occurs to my "Shared" listbox controls; As a fix, I removed
'WithEvents' from my listbox declaration. This has relieved me of the bug, though, when I modify the control using the form editor, the editor re-writes the declation which adds the 'WithEvents' to my ListBox declaration. I can live with this fix.
License: