LA.NET [EN]

May 18

well, almost, that is. And what a ride it was, letting me get some important info on several aspects related with C# coding and Javascript interop.

First, I”d like to thank Bruce Williams for providing the answer for the issue related with running Silverlight on my 64 bits machine: the problem is that you can”t load the Silverlight gadget on the 64x sidebar.exe. So, if you want to run it, you”ll have to kill the default sidebar process and go to the program files(x86) folder and launch the 32 bits version. Sucks, but at least it works.

There are some quirks related with the way the current bits work. In my case, I tried using one of those cool round rectangles for the background but it simply didn”t work out. While trying this, I ended up getting a white rectangle for the area of the Silverlight activex control (ie, the clipping I set up on  my canvas was filled with white). I”ve also tried setting the gadget to windowless (which really is needed, as we”ll see next) and set the background attribute of the object passed to the createSilverlight object to the same  color as the top canvas background. It didn”t work either. I really didn”t had any time left to re-read the docs,so maybe i”m doing something wrong here.

Another important thing: if you”re silverlight canvas occupies all the available space of the html page used by the gadget,you ”ll want to set its isWindowless property of the anonymous js object passed to the createSilverlight method to true. Not doing this will result in not getting the traditional right side menu that lets you close the gadget, get its settings or drag it around the page.

Another quirk i”ve found is related with flyouts. In my simple example, I have a flyout that shows a traditional HTML page. This page has a close button which, when clicked, should close the flyout. It seems like the siverlight control “eats”the focus and clicking on that button doesn”t do anything. In fact, in order for the button to get the click, I need to press the TAB key. After doing this, the flyout looses its grayed appearance (btw, I”ve only noticed that is as little grayed out after pressing the TAB key) and after that, it responds correctly to clicks and key presses. I need to investigate this a little more to see what”s really going on there.

The WORST problem i”ve faced is related with  cross-domain calls and the BrowserHttpWebRequest class. I know I”ve mentioned it here, but i must really do it again. You cannot make cross-domain calls with this object. By now, some of you must be thinking: “you”re really stupid. cross-domain calls are disabled and since the class is a light wrapper around the XMLHttpRequest object (well, i didn”t had the time to check this, but if you look at my previous post, you”ll see that there”s a link that seems to confirm this), you really shouldn”t get away with it”. Most of this is true (though there are some things you can do to make cross-domain calls possible in some scenarios).

However, it”s a completly different story when you”re building gadgets. In those cases, cross-domain calls are indeed allowed (in fact, most sidebar gadgets use these kind of calls!). Unfortunately, the public constructor of the BrowserHttpWebRequest class always sets the value of the enableCrossDomainCalls of the internal constructor – responsible for creating the object – to false. This ends up generating an exception.

What does this really mean in my case? It basically means that  I had to add a public Scriptable method to my canvas class in order to get the XML from my remote service. And yes, i”m using javascript and XMLHttpRequest object to make the cross-domain call and then calling the scriptable method and passing it the XML I”ve received. ironic, right? I mean, this shouldn”t really be needed and I”m hoping that future versions remove this ridiculous restriction.

And i think this sums up my experiences…

1 comment so far

  1. Deza
    6:29 am - 9-19-2007

    Could you extend your solution? Mainly the public scriptable method in your canvas. That would be great for me.
    TIA
    Deza