Monday, July 30, 2007 

Silverlight createFromXaml Bug

Odd Silverlight bug when calling 'createFromXaml' - here's the error for the search engines:

Firefox: Error calling method on NPObject! Internet Explorer: Error: AG_E_RUNTIME_METHOD : CreateFromXAML

The error occurred when I was trying pull apart the Video Library Sample for my own project.

The cause of the bug comes down to this:

  • Using the replaceAll prototype to get a string which is passed to createFromXaml:
  • works fine when it finds the placeholder and replaces it
  • crashes when it doesn't find the placeholder in the string.

Have a look at an example: Silverlight createFromXaml bug. I'm writing out the string I'm using with createFromXaml in the textarea. The first button uses the untouched template, the second replaces the $2 placeholder, and the third attempts to replace a non-existent $3 placeholder.

Stripping all the functionality out of replaceAll causes the error to happen everytime - suggesting Silverlight has a problem dealing with an untouched 'this' coming from a prototype method on a string.

String.prototype.replaceAll = function(strTarget, strSubString) {
    var strText = this;
    return( strText );
}

I've created a post about it in the Silverlight forums: BUG: createFromXaml and prototypes.

Labels:

Sunday, July 22, 2007 

C# command line parser?

Sat down to start a little command-line app on the weekend - anyone know of a good library to parse command line arguments? Expecting something with a simple api to set up a list of arguments, specific mandatory ones, and enforce some validation (types and ranges?).

Quick Google search came up with:

Expect an update (and the finished project) soon! :)