RSS
 

Posts Tagged ‘Silverlight’

There’s a maximum of 255 local messaging channels in Silverlight 4

31 Jan

Don’t ask me how I got into this situation, but I found this out the hard way.

A quick search will tell you that with Silverlight Local Messaging each message has to be under forty thousand characters, but I haven’t found anything on the internet yet that tells you that you can have a maximum of 255 channels open at a time. So I’m taking responsibility and putting it out there.

Going over the limit will give you a cryptic COM exception, and channels can be “leaked” if one browser process crashes while another is open (for example iexplore.exe and chrome.exe, or just two instances of chrome.exe). Often closing all browsers will clean up the phantom channels, but not always.

Remember that other Silverlight applications might be using some of these channels too, so you should always design your application such that it uses a minimum number of channels.

 
 

How to fix a dzproj file when DeepZoom Composer has mangled your CompositionNode’s Ids

08 Oct

Warning: if you’re not into building deepzoom systems, stop reading. This post will BORE YOU. Was the title not a good enough indication?

Ok good, they’re gone!

The current release of the deep zoom composer has a little bug. Ok – it has a few bugs, but I hate this one the most. You close your DeepZoom project(*.dzproj), you open your project, and viola – your images have rearranged themselves (or just disappeared). The first thing to worry about is: have you moved your files? Deepzoom projects store file references as absolute paths, which is ridiculous, but not the problem I was having.

Tori talks about this problem on the “known issues page” for the composer.

I don’t know what causes it (language settings were mentioned on that thread – I’m using en-NZ), but if you look inside the dzproj file itself, the Ids of all the composition nodes are all wrong.

More like “Deep Zoom Confounder”!

Im sure theres a fix coming, but if you’re as desperate as me, then what you’ve got to do is this:

1) put :<filename> on the end of each image’s tag

2) run the following code across your dzproj file:

using System;
using System.IO;
using System.Linq;
using System.Xml.Linq;

class Program
{
    static void Main(string[] args)
    {
        var file = string.Join(" ", args);

        XDocument d = XDocument.Load(file);

        var images = from i in d.Descendants("Image")
                     select Path.GetFileName(i.Element("File").Value);

        var imageList = images.ToList();

        var map = from e in d.Descendants("CompositionNode")
                  let tag = e.Attribute("Tag")
                  where tag != null
                  let fileName = tag.Value.Split(':').Last()
                  where images.Contains(fileName)
                  select new
                  {
                      Node = e,
                      NewId = imageList.IndexOf(fileName)
                  };

        foreach (var v in map)
        {
            v.Node.SetAttributeValue("Id", v.NewId);
        }

        d.Save(file);
        Console.Out.WriteLine("Press any key to continue");
        Console.ReadKey();
    }
}

This code will read in the xml, build a list of all the correct image ids, then update the ids of all your composition. Its not easy, but it’s a workaround!

 
1 Comment

Posted in How To

 

Slides & Source from my Silverlight talk

08 Aug

My thanks to everyone who came to my talk… I promised I’d put my slides up on the interwebs. Here are the slides and here is the source code

If you do want to run the system, the first thing to do is browse to default.aspx, and then .net will create the membership database (10 megs) for you. I deleted this just before i uploaded the code. You can log in anonymously as well.

If anyone’s thought of some more questions, please post a comment right here or email me (rob@robfe.com).

To the software engineering student who wanted to embed her own silverlight app onto any old web page, I had a brainwave after I answered your question. You can probably use a bookmarklet (like firebug lite do) to insert your own content (div + silverlight loader) into whatever page the user is looking at. It’d definitely be easier than writing a plugin. If you don’t want the user to have to click the bookmarklet for every page they want your widget on, GreaseMonkey is a firefox plugin that you can configure to automatically run javascript on any web page. Feel free to email me for more details

 
7 Comments

Posted in .Net

 

All about me

11 Jul

Hello, world!

My name is Robert Fonseca-Ensor. I’m a software developer at Datacom Systems Limited, in Auckland, New Zealand. I’m planning to use this blog to post technical tips & tricks as I come across them.

I love learning about the neat & new ways you can get software to do stuff. I like to see elegant code, and I like to see clever hacks. My own approach to building good code is that the less lines you have to read, the easier it will be to pick up what’s going on. I can think of a few exceptions to this rule, but I try to stay away from the really gnarly one liners (when I can help it).

Technology wise, I do most of my work with Microsoft .NET. I’ve traditionally spent a lot of time building simple aspx websites and winforms clients, but now I’m really interesting in WPF, Silverlight and REST.

Time for some interesting links:

Martin Fowler talks about how to make http caching work for you in the case where you have a page with a little bit of dynamic content. I’m surprised at how many websites simply can’t be cached – people could save a lot of money, not to mention making their websites faster! Speaking of faster websites, it’s interesting to hear what Rowan Simpson has to say: “In other words, people would use Trade Me more if it was faster still.”

When I was playing with Deep Zoom and Ben’s iPhone, it really hit me that I enjoyed the user interfaces because of how reactive they were. I thought the couple who run the sparkling client podcast were a bit nuts when they talked about how our caveman instincts demand instant animations from user interfaces – but maybe they’ve got a point. Hence my interest in all things RIA!

If you want a deep dive on WPF, I recommend looking at Scott’s BabySmash. It’s an app that started out pretty naive, and lots of WPF gods have improved it, with comments & reasons all over the internet.

 
2 Comments

Posted in Me