Derived ComboBox Designer/Component Error
I am using VS 2005 Beta 2 for a PocketPC 2003 VB project, developing with a physical device. I am trying to derive my own ComboBox control, and then drag it onto a form. My code for the derived ComboBox is simple so far, the class just inherits from ComboBox and provides a default constructor which calls MyBase.New().
My problem is in using the designer. I can see my new component in the toolbox, however when I drag it onto the form I get the following error:
"Failed to create component 'ListCombo'. The error message follows:
'System.InvalidCastException: Unable to cast object of type 'Microsoft.CompactFramework.Design.UnsafeControl' to type 'System.Windows.Forms.ListControl'............
Am I doing something wrong here, or is this a known bug? Workarounds?
Thanks in Advance,
ChrisD
[822 byte] By [
ChrisD] at [2008-2-24]
I have now isolated the problem. It happens when there is an InputPanel control already on the form. To recreate:
- Create a new form
- Place an InputPanel control on the form
- Rebuild project (makes a difference, don't know why)
- Drag the derived ComboBox component onto the form
- Recieve error message stated in above thread
If you delete the InputPanel from the form, and then rebuild, you can now drop the derived ComboBox control on the form without incident.
I hope this helps,
Regards,
Chris
Hi, Chris,
You will need to add a design-time attribute, "DesktopCompatible(true)" to your custom control.
When you add an InputPanel control to your project, your assembly will reference Microsoft.WindowsCE.Forms assembly, which makes your custom control device specific (it contains implementation specific to devices) and thus in VS designer, it was replaced with this "UnsafeControl".
After adding "DesktopCompatible(true)" desitn-time attribute, VS designer will skip the device-specific checking and create your custom control in the designer.
Look at this article http://symbian.sys-con.com/read/113332.htm on how to add design-time attributes to your custom control. It should take you less than one minute to do this.
Hope this helps.
Thanks
Xin
I have a problem similar to the one described in the article you suggested: I am trying to create a custom TextBox control which displays the inputPanel in the OnFocus() handler (inputPanel.Enabled = true
.
After implementing the custom control, all designers in my application display a blanc field showing the message "Visual inheritance is currently disabled because the base class references a device-specific component or contains P/Invoke".
The DesktopCompatible attribute does not work on my System (Windows Mobile 2005, Compact Framework 2.0, Visual Studio 2005 Version 2.0.50727).
Do you know another possibility to skip the device-specific checking so that the designer is always shown ?
WM2005Coder
WM2005Coder wrote: |
| I have a problem similar to the one described in the article you suggested: I am trying to create a custom TextBox control which displays the inputPanel in the OnFocus() handler (inputPanel.Enabled = true. After implementing the custom control, all designers in my application display a blanc field showing the message "Visual inheritance is currently disabled because the base class references a device-specific component or contains P/Invoke". The DesktopCompatible attribute does not work on my System (Windows Mobile 2005, Compact Framework 2.0, Visual Studio 2005 Version 2.0.50727). Do you know another possibility to skip the device-specific checking so that the designer is always shown ? WM2005Coder | |
I, too, have a compact app on CF 2.0 sp2, ppc with WM5.0, VS2005 sp1 and Vista ultimate. I added the input panel to a custom control that is added to a tabpage control. When I do this, all forms have the same behavior as mentioned above. I have followed the links and added the custom attributes to all of the classes in my app and none of the changes have any effect. When I completely remove all references to the input panel, the form display returns to normal.
Thanks in advance...
John