How do I set the debugger to Break on Exception
1) In VS.NET go to the Debug Menu >> 'Exceptions...' >> 'Common Language Runtime Exceptions' >> 'System' and select 'System.NullReferenceException' 2) In the bottom of that dialog there is a 'When the exception is thrown:' group box, select 'Break into the debugger' 3) Run your scenario. When the exception is thrown, the debugger will stop and notify you with a dialog that says something like: 'An exception of type 'System.NullReferenceException' has been thrown. [Break] [Continue]' Hit [Break]. This will put you on the line of code that’s causing the problem. (from sburke_online@microsoft..nospam..com on microsoft.public.dotnet.framework.windowsforms)
In Visual Studio, all my docking windows are out of whack. How can I reset them so things will be docked properly
You can use the menu item Tools|Options, and then select Reset Window Layout. A second alternative is to close Visual Studio, and then delete the suo file in your project folder. (suo=Studio User Options)
How to Reinitialize extender provider dependencies (the logic within CanExtend) from within the designer
Parse through all the Controls in the designer and call TypeDescriptor.Refresh() on them. // From inside your custom IDesigner implementation: private void UpdateExtendedProperties() { IDesignerHost idh = this.GetService(typeof(IDesignerHost)) as IDesignerHost; foreach (Component comp in idh.Container.Components) { // Ignoring the Form if ((comp is Control) && ((comp is Form) == false)) { Control ctrl = comp as Control; TypeDescriptor.Refresh(ctrl); } } }
How do I desaturate a specific color?
Jon Skeet provided this solution in the MS Windows Forms News Group. [C#] double greyLevel = original.R * 0.299 + original.G * 0.587 + original.B * 0.144; if (greyLevel > 255) { greyLevel = 255; } Color desaturated = new Color.FromArgb((byte)greyLevel, (byte)greyLevel, (byte)greyLevel); [VB.NET] Dim greyLevel As Double = original.R * 0.299 + original.G * 0.587 + original.B * 0.144 If greyLevel > 255 Then greyLevel = 255 End If Dim desaturated As New Color.FromArgb(CByte(greyLevel), CByte(greyLevel), CByte(greyLevel))
How to serialize properties of items that do not implement IComponent in a collection?
You have to set DesignerSerializationVisibility attribute on the property whose type is a strongly-typed collection to Content. You have to ensure the collection is created at startup or on demand. In order to support serialization of items that do not implement IComponent into your code you have to write a TypeConverter for that class that can convert to InstanceDescriptor. See the documentation on InstanceDescriptor for an example.