views:

341

answers:

1

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.

+2  A: 

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.

ctacke
Apparently DesktopCompatible was set to false for all the controls I made. So setting DesktopCompatible to false did not solve the problem.
xsl
Are you calling CE-specific code (like trying to show the SIP)anywhere in the control that the designer would be executing? Like Showing the SIP during Activation or the like? See my edit above.
ctacke
I'm also somewhat confused by your comment - you say "apparently" like you were surprised or didn't know. The XMTA file has to be manually created by you - Studio doesn't do it for you - so it's certainly something you would have to be setting.
ctacke
None of the controls I made were shown in the designer. After I set DesktopCompatible to true for these controls, all of them were shown, expect the control which caused the problem.
xsl
To answer your first question, no I'm not using the SIP in any code the designer would be executing. It's all commented out for test purposes.
xsl
Are you targeting a CF 2.0 or 3.5 application? This might be relevant: http://blog.opennetcf.com/ctacke/2008/11/26/Studio08sToolboxAndCompactFrameworkAssemblies.aspx - especially point #2.
ctacke
I use CF 3.5. It seems like the fixed this bug. All of my controls are shown in the toolbox. Once again, thanks for your help.
xsl