Patch for Chrome 38 lookup error in Dynamics CRM 2013

With huge thanks to Guido Preite’s blog post on the problem, I have developed a patch for this problem, and I thought I would share.

The crux of the problem is that the code is trying to access an element of an array, and Chrome 38’s JavaScript implementation provides this element already as a feature of the base language. The fix is to simply use the ‘hasOwnProperty’ method to check to see if the array element we are checking actually belongs the object, or is inherited from the prototype.

Here is the fixed function:

function pushCommandParameter(oParameter) {
    if (aParameters.hasOwnProperty(oParameter.Name) && !IsNull(aParameters[oParameter.Name]))
        aParameters[aParameters[oParameter.Name]] = oParameter;
    else {
        aParameters[oParameter.Name] = aParameters.length;
        aParameters.push(oParameter)
    }
}

Unfortunately this is a private method within another function, so we have to redefine the whole thing. I’ve wrapped this up into a simple JavaScript file which you can include on any forth that is affected. If and when Microsoft eventually patch the bug, you can simply remove this file from your form.

You can download the patch script here.

Can’t browse media via the web interface when running TwonkyServer on port 80

You can’t browse media via the web interface if the Twonky Server, which usually runs on port 9000, is instead mapped to port 80. The view comes up empty, because the request fails due to some processing happening in the client JavaScript code.

In browse.js, around lines 1212-1215 at the start of the httpGet function, there is a statement:

    var i = urlin.indexOf(":", 5),
     url = '';
    if (i < 1) {

This is looking for the port number section of the URL. Unfortunately when running on port 80, this is implied and therefore missing. It happens to work fine up until the point where the path part of the URL contains a colon, which it does later in the process of querying your server’s contents.

The URL it fails on is something like:

http://myserver/nmc/rss/server/RBuuid:55076f6e-6b79-4d65-6497-60a44c3e1361,0?start=0&fmt=json

I’ve fixed it by simply checking if the colon we found is beyond the first forward slash (/) after the “http://” part. As we are looking for the port number, if it exists it will only be before that slash.

To make the patch, open up “resources\webbrowse\browse.js” under the location you installed the server to, which on Windows is by default:

C:\Program Files (x86)\Twonky\TwonkyServer\resources\webbrowse\browse.js

Replace:

    if (i < 1) {

…with this:

    var j = urlin.indexOf("/", 7);
    if (i < 1 || i > j) {

I’ve tested it and it solves my problem. Hopefully it will work for others too!

Running uTorrent as a service on Windows

So I have recently set up my own Windows Server 2012 box to replace my old NAS. There was nothing wrong with the old box particularly, I just wanted a bit more control over it all, and I wanted to be able to run Plex, which the old box just wasn’t powerful enough to handle. One of the features of the NAS box was that it has a BitTorrent client, accessible via a web browser, and I was keen to replicate this functionality on my new set up.

The popular µTorrent client seemed like a good solution, as it includes a web-based user interface out of the box. Unfortunately, there is no built-in way to get it to run without being actually logged into the server at the time. The usual trick of setting up a scheduled task to run at start up unfortunately didn’t seem to work, and all of the guidance I could find on the internet suggested that I use the Windows Server 2003 Resource Kit to create a service, which unfortunately seems to be incompatible with Windows Server 2012!

So, in the end I gave in and came up with my own solution, and I thought I would write about it here in case it is of any use to anyone else trying to achieve the same thing.

Read the rest of this entry »