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.

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.

For a while now we’ve had an unwanted behavior in our Solution Engine product. The larger the on-device database got, the longer the app took to load. To the point that some devices in the field were taking nearly 5 minutes to boot (up from roughly 1 minute under normal circumstances). This morning we decided to go figure out what was causing it.

First, we pulled a database file from a device that is slow to boot. It turns out that the database was largely empty except to about 50k rows in a log table where we record general boot/run information on the device for diagnostics.

At startup the logging service pulls the last hour of log information and outputs it to the console, which has proven to be very helpful in diagnosing bad behaviors and crashes. Looking at the code that gets that last hour of data, we saw the following:

Now let’s look at this call in the context of having 50k rows in the table. What it effectively says is “Retrieve every row from the SFTraceEntry Table, hydrate a SFTraceEntry class for each row, then walk through that entire list checking the TimeStamp field. If the TimeStamp is less that an hour old, then copy that item to a new list and when you’re done, return the filtered list.” Ouch. This falls into the category of “using a tool wrong”. The ORM supports FilterConditions that, depending on the backing store, will attempt to decipher into a SQL statement, index walk or something more efficient than “return all rows”. In this case, the change was as simple as this:

Since a large amount of the work I tend to do is for embedded devices, and since I don’t like to have to visit deployed devices to restart an app whenever it may crash, a pretty common pattern I use is to create a watchdog application that periodically checks to see if the actual application is running and start it if it’s not. It a bit more complex than that because I typically have support for intentional shutdowns and I like to log all restarts for diagnostics, but the general premise is pretty simple. The app should always be running. If it’s not, start it again.

In Mono (under Linux anyway) that task turns out to be a bit of a challenge. Process.GetProcesses doesn’t work because rather than giving the actuall Application name like the .NET Framework does under Windows, Mono simply returns a Process with a ProcessName of “mono-sgen” for all of the Mono apps running. I can’t differentiate between the Watchdog app, the target app and any other app that may or may not be running.

I ended up creating a new class I called LinuxProcess (for lack of a better name). Ideally it would be a Process derivative, or even rolled back into the Mono source, but for now it’s stand-alone and feature-limited to what I needed for a Watchdog. Full source is below (sorry about the length, but I prefer this over a zip, and it’s searchable and indexable).

We’ve been busy lately. Very, very busy with lots of IoT work. A significant amount of that work has been using the Dream Factory DSP for cloud storage, and as such we’ve done a lot of work to make the Dream Factory implementation of the OpenNETCF ORM more solid and reliable (as well as a pretty robust, stand-along .NET SDK for the Dream Factory DSP as a byproduct) . It also shook out a few more bugs and added a few more features to the ORM core itself.

I’ve pushed a set of code updates (though not an official release yet) up to the ORM Codeplex project that includes these changes, plus an older Azure Table Service implementation I had been working on a while back in case anyone is interested and wanted to play with it, use it or extend it. The interesting thing about the Azure implementation is that it includes an Azure Table Service SDK that is Compact Framework-compatible.

Diskprep.exe is a useful tool for making a bootable USB Disk with an OS but recently it seems to have disappeared from Microsoft’s downloads. I can’t say if it’s another one of those subtle hints on the future of Windows CE, an oversight due to the lack of resources dedicated to Windows CE, or just a simple mistake that will get corrected shortly. Regardless of the cause, there are people who still find the tool useful, so I’m providing a download mirror of the tool here.