Migrating Legacy UUID of MongoDB to standard UUID

MongoDB has a legacy format for UUID which causes problem where the UUID is interpreted differently on different platforms, and the standard UUID solves that exact problem.
However, the C# driver defaults to use legacy format and requires switching to standard format explicitly.

Moreover, after switching to standard format, you might get Exception due to existing UUID. You can fix that Exception by using the Python script below to migrate legacy UUID to standard UUID while maintaining the same C# GUID translation:

After running the script, you can then replace ‘my_collection’ by ‘my_collection_new’.
Based on your actual need, you may also replace CSHARP_LEGACY with JAVA_LEGACY or PYTHON_LEGACY or other legacy format (http://api.mongodb.org/python/current/api/bson/binary.html).

Hope this help!

“Access is denied” when using Microsoft Speech Platform with IIS

When you are using Microsoft Speech Platform in your web service to perform speech recognition, you might find a strange situation when the web app works perfectly in Visual Studio, but keep having “Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))” when you try to instantiate SpeechRecognitionEngine.

After some searches on the Internet, I found 2 suggestions in this article http://stackoverflow.com/questions/3385382/run-microsoft-speech-over-iis:

  • Use procmon in SysInternals to find ACCESS DENIED result and add permission there
  • Grant read permission for the IIS apppool account to folder

I tried the second suggestion first as it is more straight forward, but it didn’t work out for me. I then tried the first suggestion.

Turned out the path is a bit different on my PC, probably due to x64-x86 compatibility.
Access Denied problem

I added read permission for

to the folder above (and some of its parents), and the speech platform works perfectly in IIS now.

I hope this article would help you if you have to same issue. Please also leave a comment if you have a better solution.

How to prepare a HTML email for your web application

As many of my other posts in this blog, this will be a note-to-self, collecting all the tidbits that I have learned in preparing a HTML email that would show properly (or as expected) in major email clients during the development of my latest application.

Below is a short list of my suggestions.

  • Use <table> and nested <table> instead of <div> for your layout
  • Don’t create table cells with the height of 1px
  • Don’t use <tr> to create top/bottom padding
  • Don’t use <p>
  • Use a <tr> for each paragraph
  • Don’t rely on page level CSS
  • Don’t try to put fancy styles in <a>
  • Be careful when putting URLs in the email content
  • Test as much as possible


There any many excellent articles on the same topic. I will try to collect them here in the future when I have more free time. In the mean time, if you know any good article, or have better solutions than what I have suggested, please feel free to comment below.
Read More

Posting raw JSON string with jQuery

If you are using jQuery’s ajax function to post raw JSON string to your APIs, you might get some problem when your API does not receive the correct content, or in the case of ASP.NET Web API and parameter binding, you may get null input parameters in your controller.

The JavaScript can be as simple as this.

And the post action of the Test API controller be something like below.

The post action will not get “inputparameter” as the value of variable input; instead we get a null value.
Read More

“An error occurred while creating the WebJob schedule”

Azure WebJob has been very helpful to help me running small automated tasks without the hassle of creating VMs or worker roles. Moreover, if you are using a recent version of Visual Studio (from Update 3, I think), you will also get some tooling support for publishing WebJob to Azure Website directly from inside the IDE. It is much more convenient than the old way: building, zipping, going to the portal, deleting the old build and uploading the new one.

However, I then got a strange problem while publishing the WebJob of one project. The error message simply said: “an error occurred while creating the WebJob schedule,” which is not useful for finding a solution at all. I have tried to search around the Internet for a solution, but cannot find any. Even stranger, I can publish that project normally to my staging websites, but not to the production one.

Eventually I found out that I have not set up any deployment credentials for my production Azure Website, and setting one solve the problem completely. I guess the tooling need that credentials to upload the WebJob’s binaries to the website.

I cost me days and days, and I found the solution accidentally after I had tried to connect to the Website using FTP, which requires deployment credentials. I hope this blog post will save you sometime should you got the same problem. I also hope that the tooling will show better error messages next time.