Visual Inheritance With .NET Compact Framework

The idea

Recently I've been working on an MVC framework for the .Net compact framework, partly to aid the re-use of certain visual components, such as signature capture screens etc.

As visual inheritance has been supported for the compact framework from VS2005 this should make it very easy to provide a nice base implementation that can then be customised as required.

To this end I created a simple base frame to handle some common functionality and a number of input frames to handle different tasks.

The Problem

At this point the input frames had text overlaid on them in design mode:

Visual inheritance is currently disabled because the base class references a device-specific component or contains p/invoke

Annoying, as I wanted the design time support of being able to visually edit the frames as required.

The Solution

Initial research turned up an MSDN article that discussed this issue and mentioned a number of causes including P/Invokes and device specific code.

The article also states:

If you are sure that platform invoke will not be executed during design time, you can safely enable visual inheritance by putting a DesktopCompatible(true) attribute on the parent form or the parent user control.

This attribute can be applied in a DesignTimeAttributes.xmta file (added through the add file to solution dialog):



true

And...it still failed. 10 more minutes off hair pulling and I realised that fraLogin inherited from BaseFrame, so I added the attribute to that class too:


true

And now visual inhertance works!

Summary

So in short, if you want visual inheritance when developing with the compact framework, remember to add the DesktopCompatible attribute to any controls that will be derived from.

Windows Mobile Proxy Ports

I recently had the need to direct some traffic to a Windows Mobile device connected over Activesync, and my initial investigations turned up the fact that the device will get the ip 169.254.2.2 or 192.16.55.100 when docked.

However, if you try to communicate to these IP addresses directly, you will discover that no traffic gets through.

To work around this limitation, you need to make use of ProxyPorts, which forward ports to a mobile device connected over Activesync (or WMDC under Vista).

Setting this up, simply entails pointing your favorite registry editor at the key:
\HKLM\Software\Microsoft\Windows CE Services\ProxyPorts

Make a new DWORD entry with a descriptive name and the port number you wish to have forwarded to the device. You will then be able to communicate with your device on that port by directing some comms traffic at 127.0.0.1 on the destop PC.