TemperNTC Class Library - Update
Just to let you know, I updated the TemperNTC Class Library article and the class library with a fix to the issue with the external sensor's sometimes unreliable initialization. Now it works splendid everytime you access the device.
![]() | Source code and tester application in C# for .Net Framework 2.0 |
WP7 AppResLib DLL Generator
Nice title, I know... Chances are you won't be interested in this, but someone dropping by from Google or Bing will be grateful for what I offer here. As it happens, I couldn't let my shiny new gadget feel alienated, so I paid off the Microsoft Tax and registered as an official Windows Phone developer, which allowed me to unlock my phone for building applications for it and even do live debugging. I already finished my first app and I have some general best practices to share with you about localization.
My application supports English and Hungarian languages, there is a localization solution in the framework but I didn't use it, I went with a WP7 version of my own that I use in ASP.NET applications. It works from an XML file where each string has a name like ModuleTitle and an arbitrary number of child nodes with language code names (en, da, hu etc) and localized content strings. It doesn't matter here, you solve it any way you want. However, there is only one way to localize the Application Title (in the application list) and Tile Title (when you pin it to the home screen) and it's not exactly easy.
In short, you need a resource-only DLL file for each language you want to localize your application for, with two Title strings in each. Generating these resource-only DLL files is quite annoying, especially that you have to do all this typing and renaming all the time whenever you need to make changes, so I made a little tool that does it for you. It works from a project configuration XML file you create with the supported languages and localized strings, which will be inserted into a DLL template file I made without any debug information and 32 characters long placeholders for both Title strings. Just check out the downloaded tool's files, it has a readme, a sample project xml file you can edit and a list of Microsoft assigned Locale IDs you need to use.
After generating the DLL files, copy them into the root directory of your project and add them. The normal AppResLib.dll is the language neutral version, the MUI files are the localized versions. Make sure you open Properties on each of these and set the Build Action as Content so it will be included in your project properly. They will be copied into the XAP file on build, but you need to refer to these resources to actually use them. Open the project properties and see below how you need to set it up:

As you can see, you have to set the Application Title as @AppResLib.dll,-100 and the Tile Title as @AppResLib.dll,-200 where the numbers are strictly set resource IDs. Sure you can enter these into your WMAppManifest.xml file which you will need to edit anyway before you would release your app.
What you also must set is the Neutral Language of your application. Normally this will be English so you have to set it as plain English, not 'English (United States)' or what have you. If you don't follow this to the letter, you won't see any problem while testing your app, but you will get this error message when the App Hub processes your app's XAP file while uploading it to the Marketplace:
The [NeutralResourceLanguage] attribute is missing on the entry assembly. (2003)
With all these done, your app will work like a charm with the locales you support. If you don't support eg. Italian, you don't have to include the DLL for that language with English titles, in my app I included only the Neutral, US-English and Hungarian files and it's all fine that way. As I see the phone will use the US-English version as a fallback setting if you select a locale you don't support, the Neutral goes unused. Enjoy the generator, I hope it will make your professional life a bit easier.
Update: I had a little oversight in localization. I went for my own string translation solution which is fine, but if you want your application appear in the Marketplace with localized metadata for the supported languages, you must go with the standard localizaton method as well, otherwise you can enter the metadata (description, keywords, images, screenshots) only on the app's neutral language. In my case all I needed was creating a new Resource file for the main project, naming it AppResources.resx (neutral language), then another one named AppResources.hu-HU.resx. I put a test string in each, closed the project, opened the project's .csproj file and entered hu-HU into the SupportedCultures XML node. After this, when I uploaded an updated binary to the Marketplace, it allowed me to enter metadata for both supported languages. It's possible that this last entry on its own controls the supported languages in the Marketplace, but it's not something I want to experiment with.
![]() | Resource DLL generator for Windows Phone application title localization. Requires .Net Framework 4.0 |
TemperNTC Class Library
A few days ago I got a package from Hong Kong – my order from USB Fever, a TemperNTC USB thermometer with a remote sensor. I must say they have a very friendly customer service. My postal address in Hungary contains an á character in the street name which caused an encoding problem in their order confirmation email, so I wrote them about it to make sure it gets printed on the package label properly, or at least they could change it to an a. It was by night here and by the time I woke up, I got a reassuring reply with a photo of the package label, proving it's all fine on their end.

I want to use it for temperature logging and I'm glad I originally planned making my own device handler and logger software because the provided HidTemperNTC software is... quite Chinese, so I'm not terribly disappointed. It's okay for playing around, but absolutely unusable for what it was made for: logging. I won't go into details here, I don't want to bash the developers too much but attention to details and dogfooding should be part of their development process for sure.
It was a bit of a surprise that it has two thermometer sensors, an internal one in the USB device and the remote one at the end of the cable. The product description was a bit misleading I guess and I had a bit of a trouble reading the remote sensor, but at the end I managed it. Just like most of those who tried to do something with it, I use the HidFTDll.dll file's exported functions for the general device handling. While the function reading the internal sensor returns a temperature value in Celsius degrees, the remote sensor is not so easy: it requires a current voltage reading from the remote sensor called NTC and involves some mathematical witchcraft with an NTC lookup table. You don't want to know, just call my GetOuterTemperature() function and remember, ignorance is bliss.
The class library doesn't use more than .Net Framework 2.0 functionality and runs perfectly on
Basically this is all you have to do if you want to make this device work:
TemperNtc temper = new TemperNtc(true);
double inner = temper.GetInnerTemperature();
double outer = temper.GetOuterTemperature();
Update: The issue with the false outer temperature reading has been fixed, now it works reliably everytime you access the device. However, this still stands: if any of the sensors return an invalid value, it will return 1000 Celsius degrees, so you just have to ignore that reading.
Now that it's done, I can work on my temperature logger application that probably I will make available for anybody, when it's ready. Have fun with the class library!
![]() | Source code and tester application in C# for .Net Framework 2.0 |
Speech Recognition
I just watched a series of video tutorials about how to use the Kinect SDK, thinking about what I could use it for in a hobby project. In the audio section the guy plays with the Speech Platform API to get certain spoken words recognized with the microphone array and I thought it could be fun to play with this API, but I never even tried the built in speech recognition functions. I activated it on the microphone built into the webcam, opened Word and tried to make it type something for me... Like the word type. This is what I ended up dictating, getting more and more frustrated:
Type.. type.. type.. type.. type.. type.. tyyype.. screw you, type!
And this is what it put into the document:
High tying tie to high heat to high tide has to have the basic five tie issue is who you die.
For a non-native English speaker it's not a real confidence booster, is it? Or perhaps my computer just tries to tell me something... At least I didn't test with Cthulhu. :-)
Extended Weather Gadget
Yesterday I had yet another round with the Calendar Gadget bug after installing the latest IE 9 updates, but I managed to make it work again. Microsoft really should do something about it, because judging by the number of hits on my article from Google it's hardly a localized problem. Meanwhile I thought I could share something with you, a little extension I made for the standard weather gadget last year and it has proven useful since. I assume most Europeans are totally lost when someone tells the current temperature in Fahrenheit degrees, I know I am, so I wanted to have at least an idea what the normal temperature values look like, to get used to it and be familiar with at least 10 degree ranges. My little extension doesn't do more than displaying the current temperature with the user selected temperature scale, then with the secondary scale. As I use Celsius primarily, it's Celsius / Fahrenheit display for me, like you see on the examples below.

The forecast is displayed only by using the primary scale due to lack of screen estate. Maybe I will upload it to the official gadget gallery too, but for now it is fine to be hosted here. If you'd like to host your own gadgets, all you need to do is registering the .gadget MIME type as application/x-windows-gadget in your web server (fairly easy in IIS) and you're in business, Internet Explorer will offer installing it on opening the file.
![]() | Sidebar gadget for Windows Vista or later |
Update: I uploaded it to the Windows Live Gallery where Microsoft authenticated it, so you can download it from there too. Lots of people already did and counting, it's amazing. :)










