ORM Updates

Generally speaking, the OpenNETCF ORM library gets worked on offline.  We use it extensively in our Solution Engine product and so the “working” copy of the code resides on a separate source tree.  The good part of this is that it’s always getting tested, extended and fixed.  The down side is that I have to manually merge those changes back to the public source tree so it doesn’t happen probably as often as it should.

At any rate, I did a large merge this morning and there are some cool new features that have been added, along with a long list of bug fixes.

The general bug fixes and enhancements are largely SQL Server related, since we did a large SQL Server push for a customer this year, and the ORM benefitted from that.

The new features are twofold:

1. I added some rudimentary Connection Pool support.  The ORM itself can now keep a pool of connections to your target data store and it will re-use them in a round-robin fashion.  It’s nothing overly complex, but if you’ve got a few different threads doing different work on the database, it improves performance.

2. I added what I call a “Recovery Service” because I couldn’t come up with a better name.  This doesn’t restore data, but instead it attempt to recover from failures when it can. It’s really useful for remotely connected data stores.  For example, if you are using a SQL Server or DreamFactory DSP and the server or network goes down, your data actions are going to fail and you have to add in a load of handling logic for that.  The Recovery Service is designed to help you out here.  It will look for those types of failure and cache your operations until the store comes back online, at which time it will then apply the changes.  Sort of a “store-and-forward” type of capability, but at the command level and in RAM.

The new release is over on CodePlex in source and binary format.

OpenNETCF Scanner Compatibility Library

Some days I think I have too much code “lying around”.  As you would expect from many years as a developer, I have utility libraries for all sorts of tasks.  Generally when I think something is likely to be useful for others I like to make it publicly available for anyone to use – just take a look at the list of Codeplex projects I admin.

This morning I saw a question on StackOverflow about intelligently detecting a platform and loading the proper binaries for it.  In this case it was specific to doing so with Windows Mobile barcode scanners.  I immediately thought, “hey, I have a library for that” and went to answer and give a link.  Except the link didn’t exist.  I never created the open source project for it, so the code has just been sitting here doing nothing.

Yes, this code is probably 5 years or more past it’s prime useful period due to the decline in use of Windows Mobile, but hey, I just used it on a project last week, so it’s got some life left in it.

So, here’s yet another open source library from my archive – the OpenNETCF Barcode Scanner Compatibility Library.

MJPEG (and other camera work)

Back in 2009 I was doing a fair bit of work for some customers in the security field.  I ended up doing some proof-of-concept stuff and ended up with some code that, while not groundbreaking, is at least might be useful to others.  It’s really too small to bother starting a Codeplex project for it, unless I get some pull requests, in which case I’ll turnn it into a full project.  In the meantime feel free to Download the source.

Developing Compact Framework App in Visual Studio 2013

A friend, colleague and fellow MVP, Pete Vickers, brought an interesting product to my attention this weekend.  iFactr has a Compact Framework plug-in for Studio 2013.  I’ve not tried the plug-in, so this isn’t an endorsement just a bit of information.  I also don’t know how they’re pulling it off.  It looks like they have WinMo 6.5 and emulator support, and it requires an MSDN subscription.  I suspect that it requires you to install Studio 2008 so you get the compilers, emulators and all of that goodness on your development system, and it then hooks into those pieces from Studio 2013.

It most certainly is not adding any new language features – you’re still going to be targeting CF 3.5 in all its glory – but the ability to use a newer toolset is a welcome addition.  If they somehow are pulling it off without requiring Visual Studio 2008 that will be really nice.  If you’ve tried the plug-in, let me know how it went in the comments.

Windows CE on Arduino?

If you do much “maker” stuff, you’re probably aware of the Netduino, an Arduino-compatible board that runs the .NET Micro Framework.  Cool stuff and it allows you to run C# code on a low-cost device that could replace a lot of microcontroller solutions out there.

It just came to my attention today that there’s a new game in town – 86duino, an Arduino-compatible x86 board.  Say what?!  Basically we have an Arduino-size, and Arduino-cost ($39 quantity-1 retail price, hell0!) device that can run any OS that runs on x86.  Let’s see, an OS that runs on x86, does well in a headless environment, runs managed code, can be real-time, has a small footprint and low resource utilization?  How about Windows CE?  There’s no BSP for it yet that I see, but it’s x86, so the CEPC BSP is probably most of what you need for bring-up.

I’ll be looking to build up a managed code library to access all of the I/O on this and some popular shields.  Any requests/thoughts on “must-have” shield support?

Getting Mouse Events in a Compact Framework TextBox

Yesterday I got a support request for the Smart Device Framework.  The user was after a seemingly simple behavior – they wanted to get a Click or MouseDown event for a TextBox is their Compact Framework application so they could select the full contents of the TextBox when a user tapped on it.

Of course on the desktop this is pretty simple, you’d just add a handler to the Click event and party on. Well, of course the Compact Framework can’t be that simple. The TextBox has no Click, MouseUp or MouseDown events. Thanks CF team. There are some published workarounds – one on CodeProject and one on MSDN – but they involve subclassing the underlying native control to get the WM_LBUTTONDOWN and WM_LBUTTONUP messages, and honestly that’s just not all that fun. Nothing like making your code look like C++ to kill readability.

For whatever reason (I can’t give a good one offhand) the TextBox2 in the Smart Device Framework also doesn’t give any of the mouse events, *but* it does offer a real easy way to add them since it does allow simply overriding of the WndProc. Basically you just have to create a new derived control like this:

    public class ClickableTextBox : TextBox2
    {
        public event EventHandler MouseDown;

        protected override void WndProc(ref Microsoft.WindowsCE.Forms.Message m)
        {
            base.WndProc(ref m);

            switch ((WM)m.Msg)
            {
                // do this *after* the base so it can do the focus, etc. for us
                case WM.LBUTTONDOWN:
                    var handler = MouseDown;
                    if (handler != null) handler(this, EventArgs.Empty);
                    break;
            }
        }
    }

And then using it becomes as simple as this:

    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();

            textBox2.Text = "lorem ipsum";
            textBox2.MouseDown += new EventHandler(textBox2_MouseDown);
        }

        void textBox2_MouseDown(object sender, EventArgs e)
        {
            textBox2.SelectAll();
        }
    }

Being an MVP

I’ve been a Microsoft “Most Valued Professional,” or MVP, for a long time now.  So long that I had to actually go look up when I was first got the award (2002).  Over those years, the program has changed, the technology for which I am an MVP has changed, and I’m certain that I’ve changed.

When I first got my MVP status, it was not long after I co-authored a book on embedded Visual Basic with a friend, Tim Bassett and at the time I was being pretty prolific in that extremely niche segment of the development community, publishing articles on DevBuzz and answering question in the now-defunct Usenet groups from embedded development (as a side note Microsoft has tried many incarnations to replace those groups, and have never found one that was as easy to use or navigate).

I remember that I felt a bit out of place at my first MVP Summit – the annual meeting of all MVPs in Redmond – because I was seeing and meeting all sorts of people that I had been using for information since I had started developing.

It wasn’t long, and my focus changed from eVB to the .NET Compact Framework – largely because Microsoft killed eVB as a product.  I embraced the CF and continued writing articles for MSDN and answering loads of questions and even doing the speaking circuit at what was then called Embedded DevCon.  I helped “start” OpenNETCF, which at the time was really just a collection of Compact Framework MVPs trying to answer questions, cover the stuff Microsoft was missing, and not duplicate effort.

In those early days of the CF, being an MVP was fantastic – it really was.  A few times a year the MVPs and the product teams would actually get together in the same room.  They would tell us what they were planning.  They would ask for feedback.  They’d listen to our ideas and our criticisms.  You could count on seeing direct results from those meetings in future releases of products coming out of Redmond, and so the MVPs continued to pour effort into keeping the community vibrant and well-informed.

Back in those days I knew both PMs and developers from most of the teams involved in the products I used.  I knew people on the CF team.  The test team.  The CE kernel and drivers teams.  The CE tools team.  The Visual Studio for Devices team.  And when I say I “knew” them, I don’t mean that at a conference, I could point them out, I mean that at the conference we went to the bars together.  I had their phone numbers and email addresses, and they would respond if I needed to get a hold of them.

Those I now know were the golden days of the program, at least from the embedded perspective. It could well be that C# MVPs or some other group still sees that kind of interaction, but the embedded side doesn’t see much of that any longer.  In fact, I know very few people on any of the teams, and I guess that most of those people probably wouldn’t answer my emails.

What’s changed, then?  Well, Microsoft is a business, of course.  A large one at that.  As such, they have constant internal churn.  Most of the people I one knew are still at Microsoft – they’ve just moved on to other things, other groups and other positions and the people that came in to replace them didn’t necessarily have the mechanism (or maybe the desire) to get to know the community of experts in the field.  The teams also shifted a lot – Embedded got moved from one group to another and to another inside of Microsoft, and the business unit got less and less priority for quite some time – especially when it and the group shipping quantity (Windows Mobile) were separated.  The Embedded DevCon became the Mobile and Embedded DevCon, then it went away.  Budgets shrank.  Community interaction receded.

I can’t say I fault Microsoft for this.  After all, they are a business, and they make decisions based on what provides shareholder value.  I may disagree with some, or even many of their decisions on the embedded side, but I don’t work at Microsoft, and I’m definitely not in their management team, so my opinions simply do not matter.

So why do I bother mentioning all of this, if not to complain?  Because I want you, as a reader, to understand where I come from in some of the articles I’ll be posting over the coming weeks.  I no longer have any inside information about the future of Windows CE or the Compact Framework.  I don’t know what Microsoft intends to do or not do.  I find out things about the technologies at the same time as the rest of the world.

This means that if you see me write something about the future of Windows CE, now called Windows Embedded Compact (and yes, expect to see something on that soon), it’s all based on my personal opinion and thoughts based on history *not* on any insider information.  If what I predict happens, it’s only because my guesses were educated and/or lucky.  If it doesn’t, it’s not because I was trying to be misleading, it’s because I simply got it wrong.  Basically, as with anything you read, I expect you to use your own critical thinking skills, and I fully encourage discussion and debate.