Search code examples
visual-studio-2008compact-frameworkvisual-studio-designer

Compact Framework: Failed to use InputPanel in a control


I developed a control that uses the PDA's InputPanel to interact with the user. The relevant part of the code is below:

namespace MyNamespace
{
     // ...
     using Microsoft.WindowsCE.Forms;
     // ...

     public class MyControl
     {
         // ...
         public InputPanel MyPanel { get; set; }
         // ...
     }
}

Whenever I try to drag the Control to a Form, I get the following error:

System.IO.FileNotFoundException: Could not load file or assembly ‘Microsoft.WindowsCE.Forms, Version=2.0.0.0, Culture=neutral,
PublicKeyToken=969db8053d3322ac’ or one of its dependencies. The system cannot find the file specified. File name: ‘Microsoft.WindowsCE.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=969db8053d3322ac’

If I remove the InputPanel line from MyControl I can add it to the Form without any problems. Once the Control is added I can add the line again and the whole program compiles and works fine.

As soon as the form with the Control is viewed in the Designer, it crashes with a similar error as written above and I can't add it to any other Form again.

I am using Visual Studio 2008 SP1 with the Windows Mobile 6 SDK.


So my questions is: Has anyone experienced a similar problem or found a workaround?


EDIT: Gave up and used the parent form as a property. The form implements IInputPanel which is basically an interface with an InputPanel getter. Nevertheless ctake's answer was really insightful and introduced me to XMTA.


Solution

  • It's because the desktop doesn't have a SIP (inputpanel) and therefore the designer can't show it. You need to set the DesktopCompatible attribute in the XMTA to false.

    EDIT: I suppose I should extend this answer. Setting the DesktopCompatible attribute will prevent the designer from querying the property directly, but if you have any code in the control that may call it (so if any code that will run in the designer might execute CE-specific code) then you must also add code to prevent that. Checking the current Platform via Environment.OSVersion.Platform works fairly well, though there are other, more convoluted, mechanisms to determine if you're in the designer as well.