When doing custom control development, here are some frequent design-time issues:
1. Why my custom controls are added to the form designer as an empty box?
Most likely your custom control is device specific (the assembly that your custom control resides uses P/Invoke, or references another assembly that uses P/Invoke). In Visual Studio 2005 .net Compact Framework designer, once we detected a custom control is device specific, it will be replaced with an empty box because this custom control is regarded as dangerous to be created in the design-time (Creating this custom control in design-time may cause P/Invoke code to be executed. Most of the P/Invoke calls are specific to WinCE OS, and will fail during design-time.).
If your custom control is safe to be created in design-time, you will need to add “DesktopCompatibility” design-time attribute on this custom control to mark is to be desktop compatible. You can take a look at the links to my previous blog on how to do it. It’s pretty easy.
2. Why some properties are missing in the property browser?
Same as 1). Try adding “DesktopCompatible” design-time attribute.
3. Why my design-time components, such as designer, editor or type converter are not being used in design-time?
There could be many reasons for this. For example, the design-time assembly can not be loaded, or the design-time components throws exceptions. Debugger will help you to figure this out. Attaching debugger is a relative straight forward step. First, start another Visual Studio instance, select “Tools / Attach to process” menu, set the code type to “Common Language Runtime”. This will enable you to debug managed code. If the code you want to debug involves both managed and native code, you can check both “Common Language Runtime” and “Native” to enable both managed and native debugging.
Once the debugger is attached, you can browse to your source code and set break points. If the corresponding module hasn’t been loaded yet, the break points will appear to be disabled. This is ok. The debugger will automatically enable them once the module is loaded. If not, check Tools\Options page, select "Debugging" on the left side and uncheck "Enable Just My Code (Managed only)" option.
In many cases you will need to debug why exception happens. All you need is to attach the debugger before the exception and set the debugger to catch any exceptions being thrown. To do this, select “Debug\Exceptions” from the menu and check the specific exceptions you want to catch. Often I started with catching every managed exception. Once I know what exception it is, I can narrow the scope of the catching to that one.
After attaching the debugger and setting up exception catching, run your test scenario and it will break into debugger once an exception is thrown. Remember, some exceptions are expected (Visual Studio itself uses exceptions internally to communicate success / failure status). So be sure to locate the right exception you want to debug.