<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom"><title type="text">Blog posts by Chris Klug</title><link href="http://world.optimizely.com" /><updated>2011-08-25T10:02:00.0000000Z</updated><id>https://world.optimizely.com/blogs/Chris-Klug/</id> <generator uri="http://world.optimizely.com" version="2.0">Optimizely World</generator> <entry><title>Using ildasm and ilasm to fix the EPiServer Mobile Pack</title><link href="http://chris.59north.com/post.aspx?id=7fc4947e-3419-465f-9fee-00e1b0c5fc1d" /><id>&lt;p&gt;Ok, so a couple of days ago (or something) EPiServer released a module called Mobile Pack. It is built to make it easy for companies to get their website up and running for mobile browsers, which is pretty cool.&lt;/p&gt;  &lt;p&gt;It uses “Visitor Groups” and a browser criterion to redirect mobile users to a mobile version of the website. A solution which is actually quite simple, but it works well, and simple well working things are great. At least it works in theory. Unfortunately, in the real world the code doesn’t work…&lt;/p&gt;  &lt;p&gt;The problem? Well, it doesn’t redirect properly for iFruit devices. I found this out by installing the module on a site, and modifying my FireFox browsers user-agent to that of an iPhone, which looks like this&lt;/p&gt;  &lt;blockquote&gt;   &lt;p&gt;&lt;em&gt;5.0 (iPhone; U; CPU iPhone OS 3_0 like Mac OS X; en-us) AppleWebKit/528.18 (KHTML, like Gecko) Version/4.0 Mobile/7A341 Safari/528.16&lt;/em&gt;&lt;/p&gt; &lt;/blockquote&gt;  &lt;p&gt;Or at least similar to it… But browsing to the site did not redirect me, which annoyed the crap out of me. And after going through every single configuration I could think of, I still couldn’t get it to work. So I assumed I had missed something, and decided to look at the code in .NET Reflector to see what was actually happening in the code. And to my surprise, it wasn’t actually me, it was the code.&lt;/p&gt;  &lt;p&gt;There is one line of code that checks the browser user-agent to figure out if it is a mobile browser. It looks like this&lt;/p&gt;  &lt;div style=&quot;border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px&quot; id=&quot;codeSnippetWrapper&quot;&gt;   &lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px&quot; id=&quot;codeSnippet&quot;&gt;&lt;span style=&quot;color: #0000ff&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;override&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;bool&lt;/span&gt; IsMatch(IPrincipal principal, HttpContextBase httpContext)&lt;br /&gt;{&lt;br /&gt;    &lt;span style=&quot;color: #0000ff&quot;&gt;return&lt;/span&gt; httpContext.Request.UserAgent.Contains(&lt;span style=&quot;color: #0000ff&quot;&gt;base&lt;/span&gt;.Model.Browser.ToString());&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;/pre&gt;

  &lt;br /&gt;&lt;/div&gt;

&lt;p&gt;This could sort of be fine, but it isn’t. First of all, comparing the user-agent to a compiled enumeration like this is a little bit too limiting for me. My WP7 device would for example not be considered a mobile device… I would have preferred a config setting in web.config or even better using the browser capabilities built in to .NET. But that isn’t the real problem… &lt;/p&gt;

&lt;p&gt;When comparing strings like this, I recommend doing a case-insensitive check. As Contains() doesn’t support passing in a StringComparison, doing a ToLower() would at least be sweet.&lt;/p&gt;

&lt;p&gt;In this case, this Contains() call is actually the cause of the redirect problem… As it compares the user-agent, it uses a enum that looks like this&lt;/p&gt;

&lt;div style=&quot;border-bottom: silver 1px solid; text-align: left; border-left: silver 1px solid; padding-bottom: 4px; line-height: 12pt; background-color: #f4f4f4; margin: 20px 0px 10px; padding-left: 4px; width: 97.5%; padding-right: 4px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; max-height: 200px; font-size: 8pt; overflow: auto; border-top: silver 1px solid; cursor: text; border-right: silver 1px solid; padding-top: 4px&quot; id=&quot;codeSnippetWrapper&quot;&gt;
  &lt;pre style=&quot;border-bottom-style: none; text-align: left; padding-bottom: 0px; line-height: 12pt; background-color: #f4f4f4; margin: 0em; border-left-style: none; padding-left: 0px; width: 100%; padding-right: 0px; font-family: &amp;#39;Courier New&amp;#39;, courier, monospace; direction: ltr; border-top-style: none; color: black; border-right-style: none; font-size: 8pt; overflow: visible; padding-top: 0px&quot; id=&quot;codeSnippet&quot;&gt;&lt;span style=&quot;color: #0000ff&quot;&gt;public&lt;/span&gt; &lt;span style=&quot;color: #0000ff&quot;&gt;enum&lt;/span&gt; BrowserType&lt;br /&gt;{&lt;br /&gt;    Android,&lt;br /&gt;    Apple,&lt;br /&gt;    IPhone,&lt;br /&gt;    IPod,&lt;br /&gt;    IPad,&lt;br /&gt;    BlackBerry,&lt;br /&gt;    MSIE,&lt;br /&gt;    Opera,&lt;br /&gt;    Firefox,&lt;br /&gt;    Safari,&lt;br /&gt;    Chrome,&lt;br /&gt;    Webkit&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt; &lt;br /&gt;&lt;/pre&gt;

  &lt;br /&gt;&lt;/div&gt;

&lt;p&gt;Caught the problem? Well, iFruits use lower-case I:s… So since the Contains() call is case-sensitive, it fails to identify i-devices as mobile devices, which is quite funny as those would be the first once I checked when building something like this…&lt;/p&gt;

&lt;p&gt;So, how do we fix it? Well, there are two ways. Either you go to &lt;a href=&quot;http://mobilepack.codeplex.com/&quot; target=&quot;_blank&quot;&gt;Codeplex&lt;/a&gt; and download the source, fix the bug, and recompile it, which is probably the easiest way. But being me, and already having the dll on disk from my NuGet “install”, I decided to fix the dll instead…&lt;/p&gt;

&lt;p&gt;The way to do this, is to disassemble the dll to il code, fix the problem and then recompile it…&lt;/p&gt;

&lt;p&gt;Let’s start by getting the IL code. This is done by opening ildasm.exe, which is easily done by opening the Visual Studio Command Prompt and typing ildasm followed by enter. This opens up ildasm. Then drag and drop the dll into the opened window and you get a view like this&lt;/p&gt;

&lt;p align=&quot;center&quot;&gt;&lt;a href=&quot;http://chris.59north.com/image.axd?picture=image_3.png&quot;&gt;&lt;img style=&quot;background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px&quot; title=&quot;image&quot; border=&quot;0&quot; alt=&quot;image&quot; src=&quot;http://chris.59north.com/image.axd?picture=image_thumb_3.png&quot; width=&quot;404&quot; height=&quot;604&quot; /&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Next, open the File menu and select Dump. In the resulting window, just press OK and select a place to save the resulting il code. This will also create a .res resource file with the same name.&lt;/p&gt;

&lt;p&gt;This code file can then easily be opened in Notepad. After doing so, press Ctrl+F and search for “iphone”. Now change all the rows that have the incorrect capital I to use the correct spelling, and save the file and close Notepad.&lt;/p&gt;

&lt;p&gt;Next we need to compile the il code back to a usable dll. This is done by using a tool called ilasm.exe. Unfortunately, if you just pull it up using the command prompt like we did with the ildasm, you might get into problems. The ilasm.exe application is runtime version dependent. Each version comes with its own ilasm. And starting it from the VS2010 command prompt might give you the wrong version depending on what version you are using for the EPiServer project.&lt;/p&gt;

&lt;p&gt;So instead, we use the full path, which is &lt;/p&gt;

&lt;blockquote&gt;
  &lt;pre&gt;&lt;font face=&quot;Tahoma&quot;&gt;%FrameworkDir%\v2.0.50727\ilasm&lt;/font&gt;&lt;/pre&gt;
&lt;/blockquote&gt;

&lt;p&gt;At least in my case, as my project is .NET 3.5, which means runtime version 2.0. &lt;/p&gt;

&lt;p&gt;But we also need to pass some parameters to ilasm. Let’s use&lt;/p&gt;

&lt;blockquote&gt;&lt;/blockquote&gt;

&lt;blockquote&gt;
  &lt;p&gt;%FrameworkDir%\v2.0.50727\ilasm MobilePakc.il /out=MobilePack.dll /res=MobilePack.res /dll&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;At least is you named the il file MobilePack.il…&lt;/p&gt;

&lt;p&gt;This will now give you a new dll file that you can drop into the bin folder of your project and you are done…&lt;/p&gt;

&lt;p&gt;This obviously works for other dll&#39;s than MobilePack, as long as they aren’t signed, as well as for other projects than EPiServer. But in this case it just happened to be an EPiServer problem…&lt;/p&gt;

&lt;p&gt;I also want to mention that I have notified Allan who built this code about the problem, so I assume it will be fixed relatively soon…&lt;/p&gt;

&lt;p&gt;Cheers!&lt;/p&gt;

&lt;p&gt;IMPORTANT! If you have used NuGet to install the mobile pack, remember to change the reference to the new bin instead of the one in the packages folder…&lt;/p&gt;</id><updated>2011-08-25T10:02:00.0000000Z</updated><summary type="html">Blog post</summary></entry> <entry><title>Event bubbling changes in Silverlight 2.0 Beta 2 controls</title><link href="http://chris.59north.com/post.aspx?id=aab55cd2-69ec-475e-9100-c06682bba41f" /><id>&lt;p&gt;I got another question about an issue in Silverlight 2.0 Beta 2. My collegue who is at the moment working on a video-player came to me and asked me why MouseLeftButtonDown- and Up didn&#39;t work on the slider and after 2 minutes of Googling we found out that he wasn&#39;t the only one faced with this problem. I started by Googling a bit more. Google is a developers best friend, but I couldn&#39;t find a solution. I found the reason for the problem, which I confirmed by checking the sliders code in Reflector. It is actually not a change in Silverlight as such, but in the controls that ship with Silverlight. For some reason Microsoft changed the implementation of their controls from Beta 1 to 2 and started letting each individual template part handle their on mouse events.So each part of the control encapsulates itsfunctionality nicely and sets the Handled-property of the EventArgs to true in their eventhandlers. This causes the event to stop bubbling and also renders the MouseLeftButtonDown, Up and so on the control more or less useless. &lt;/p&gt;  &lt;p&gt;The easy solution that some guys suggested, which was also my first solution, was to inherit the control and override the OnMouseLeftButtonDown method. This doesn&#39;t really work in my case though. In the case of Button, it might, but the slider doesn&#39;t offer that possibility since there are no protected methods to override. The Buttons base class, ButtonBase, implements a couple of protected virtual methods to override, but the slider makes these methods private. So I went through the template for the slider control to figure out how it worked and came up with a solution. I created a class that inherited from Slider. This gave me access to the protected method GetTemplateChild(), which gave me access to elements in the template. I then created a property of type Thumb. The reason for this choice was that I was only interested in mouse events for that specific part of the control, but it works with any part of the template. In that property I then called GetTemplateChild() passing in the name of the thumb, &amp;quot;HorizontalThumb&amp;quot;, and casting it to Thumb. Note that the name is for the template for the thumb used when the control is in horizontal mode. Changing to vertical will require that you change the name. This looked nice and might have worked if I hadn&#39;t tried to get hold of the Thumb as early as in the Load event. By that time, the ApplyTemplate() had apparently not executed and I got a null reference. So I added some logic to check for null and call ApplyTemplate in those cases. After that I could just add my control and handle the events from my Thumb. &lt;/p&gt;  &lt;p&gt;This method should be possible to use on basically all controls that might be causing your headaches. Finding the name of the template parts can be dont in several ways. One is disassembling the control in Reflector. Microsoft stores the names of the parts in constants, using relatively easily understood names. The names are also available among the attributes addorning the class. Another way is to disassemble System.Windows.g.resources resource in Reflector. All default templates XAML is available in generic.xaml. And the final one is to open the control in Blend 2.5 and edit the controls template and then take a look at the xaml that it creates. However you do it, it should help you out. It might be an ugly solution, but it&#39;s the only one I can see at the moment.&lt;/p&gt;  &lt;p&gt;Here is the full code for my custom slider. It&#39;s not a lot of code, and perhaps not very beautiful, but it will work as an example of what I&#39;m talking about.&lt;/p&gt;  &lt;blockquote&gt;   &lt;div class=&quot;code&quot;&gt;
[code:c#]      &lt;br /&gt;&lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; &lt;span class=&quot;kwrd&quot;&gt;class&lt;/span&gt; MySlider : Slider       &lt;br /&gt;{       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; Thumb _horizontalThumb = &lt;span class=&quot;kwrd&quot;&gt;null&lt;/span&gt;;     &lt;p&gt;&amp;#160;&amp;#160;&amp;#160; &lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; Thumb Thumb      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; {       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; get&amp;#160; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span class=&quot;kwrd&quot;&gt;if&lt;/span&gt; (_horizontalThumb != &lt;span class=&quot;kwrd&quot;&gt;null&lt;/span&gt;)       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span class=&quot;kwrd&quot;&gt;return&lt;/span&gt; _horizontalThumb; &lt;/p&gt;    &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; _horizontalThumb = &lt;span class=&quot;kwrd&quot;&gt;this&lt;/span&gt;.GetTemplateChild(&amp;quot;HorizontalThumb&amp;quot;) &lt;span class=&quot;kwrd&quot;&gt;as&lt;/span&gt; Thumb;      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span class=&quot;kwrd&quot;&gt;if&lt;/span&gt; (_horizontalThumb == &lt;span class=&quot;kwrd&quot;&gt;null&lt;/span&gt;)       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; {       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span class=&quot;kwrd&quot;&gt;this&lt;/span&gt;.ApplyTemplate();       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; _horizontalThumb = &lt;span class=&quot;kwrd&quot;&gt;this&lt;/span&gt;.GetTemplateChild(&amp;quot;HorizontalThumb&amp;quot;) &lt;span class=&quot;kwrd&quot;&gt;as&lt;/span&gt; Thumb;       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span class=&quot;kwrd&quot;&gt;return&lt;/span&gt; _horizontalThumb;&amp;#160; &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; }       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; }       &lt;br /&gt;}&lt;/p&gt;    &lt;p&gt;[/code]&lt;/p&gt;&lt;/div&gt;&lt;/blockquote&gt;</id><updated>2008-07-07T19:25:32.0000000Z</updated><summary type="html">Blog post</summary></entry> <entry><title>And the solution is AssemblyPart...</title><link href="http://chris.59north.com/post.aspx?id=d4f2fb33-81c6-46d3-86fc-1c376f71ddaf" /><id>&lt;p&gt;A couple of weeks ago I had a look at a &amp;quot;module&amp;quot; for EPiServer CMS 5. It&#39;s going to be a part of our new package called Create+, and is called InteractiveScene. It basically gives the editor the ability to add and configure Flash-based content using EPiServer. &lt;/p&gt;  &lt;p&gt;So, how does this end up being an entry on my blog? Well, it got me thinking. But first off I have is to say that I&#39;m not here to replace InteractiveScene in any way. Neither am I here to tell you to do it. My concept builds on top of InteractiveScene, using it, not replacing it. It would of course be possible to use my thoughts to use this outside of EPiServer, in which case you would have to build the parts that I use from InteractiveScene manually.&lt;/p&gt;  &lt;p&gt;So, back to the question, why am I blogging about a third party application for EPiServer? And why the @#!*% am I blogging about something that is using Flash? Everybody knows what I think about Flash... I love it, but don&#39;t know how to use it. The whole idea about how to use Flash is built around people who have minds that don&#39;t work in the same way as mine. So...thats actually the answer to the question. The &amp;quot;education&amp;quot; I got in &amp;quot;IS&amp;quot; was mostly based around the editors interface. All the cool development is actually made in Flash and just configured through EPiServer and thats no good for me. So I do of course have to find a way to tweak the system to use Silverlight instead of Flash.&lt;/p&gt;  &lt;p&gt;So, how does &amp;quot;IS&amp;quot; work? Well, it&#39;s a standard EPiServer solution. It uses pages in EPiServer to &amp;quot;tell&amp;quot; the Flash what to do and show. Basically it is a slideshow player, but it lets you use Flash-files (.swf) as slides giving you a lot of possibilities. The solution to &amp;quot;telling&amp;quot; the Flash what to do is to let the pages render as XML. Then the Flash makes a call to the page on the server, requesting it in XML-mode. It then parses the XML and does whatever processing is necessary using it. &lt;/p&gt;  &lt;p&gt;The actual slideshow builds around the concept of a playlist with slides. In EPiServer the playlist is actually an EPiServer page as well as each one of the slides. But my focus here isn&#39;t actually the EPiServer integration so I&#39;ll leave that area a bit untouched. The actual application is a Flash-application that works as a host. The host uses that playlist to get hold of the slides. Each of the slide pages contains a reference to an SWF-file that should be used as a slide. It then downloads that slide and adds it to the application. Then there is possibility to set the slideshow timers as well as transition effects between the slides. This is of course a very simplified version of &amp;quot;IS&amp;quot;, but it is the core of my thoughts. &lt;/p&gt;  &lt;p&gt;I immediately started asking myself questions about Silverlight. &amp;quot;How can I load external UserControls?&amp;quot; was my first one. The developers have to be able to create UserControls, dump them on the server, OUTSIDE of the XAP-file. The XAP can only contain the core application, the actual host. The rest of the controls must be downloaded dynamically. Can this be done? It has to...it&#39;s so simple. So what do a good developer do when he needs a solution to a problem. Well, I open Google, but I might not a good programmer. I Googled my question and found AssemblyPart...&lt;/p&gt;  &lt;p&gt;AssemblyPart is a class that is basically made for the scenario I&#39;m talking about. It can create an instance of the Assembly-class from a stream. From that assembly object you can then create instances af all classes inside the assembly. The only issue is that you can only create instances of controls using a parameterless constructor. But that will suffice. The actual constructor parts can be solved by creating an interface. So I created a Silverlight Classlibrary to hold my interfaces. The resulting assembly from this project will be in the XAP file and as such available to the dynamically created objects. So inside the library project I created a single interface to begin with and called it IInitializableControl. This interface declares a single method, void Initialize(XElement xml). This method will be called by the host after instantiation. Of course I will first have to check if the control implements the interface, since it would be possible to create a slide that didn&#39;t need initialization and therefore didn&#39;t implement it. The method takes an XElement object as parameter, making it possible to pass in the xml-configuration for that specific slide. The library project is referenced by both the host application project and the projects containing the slides.&lt;/p&gt;  &lt;p&gt;A basic example of downloading a UserControl and instantiating it could look as the following:&lt;/p&gt;  &lt;blockquote&gt;   &lt;div class=&quot;code&quot;&gt;
[code:c#]     &lt;br /&gt;&lt;span class=&quot;kwrd&quot;&gt;public&lt;/span&gt; HostControl()       &lt;br /&gt;{       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160; InitializeComponent();     &lt;p&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160; WebClient client = &lt;span class=&quot;kwrd&quot;&gt;new&lt;/span&gt; WebClient();      &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160; client.OpenReadCompleted += &lt;span class=&quot;kwrd&quot;&gt;new&lt;/span&gt; OpenReadCompletedEventHandler(AssemblyDownloaded);       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160; client.OpenReadAsync(&lt;em&gt;url to assembly&lt;/em&gt;, &lt;em&gt;name of assembly&lt;/em&gt;);       &lt;br /&gt;}&lt;/p&gt;    &lt;p&gt;&lt;span class=&quot;kwrd&quot;&gt;void&lt;/span&gt; AssemblyDownloaded(&lt;span class=&quot;kwrd&quot;&gt;object&lt;/span&gt; sender, OpenReadCompletedEventArgs e)      &lt;br /&gt;{       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span class=&quot;kwrd&quot;&gt;string&lt;/span&gt; assemblyName = (&lt;span class=&quot;kwrd&quot;&gt;string&lt;/span&gt;)e.UserState;       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160; _assembliesToDownload.Remove(assemblyName);       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160; AssemblyPart assPart = &lt;span class=&quot;kwrd&quot;&gt;new&lt;/span&gt; AssemblyPart();       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160; Assembly ass = assPart.Load(e.Result);&lt;/p&gt;    &lt;p&gt;&amp;#160;&amp;#160;&amp;#160; UserControl ctrl = (UserControl)ass.CreateInstance(&lt;em&gt;classname&lt;/em&gt;);       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; &lt;span class=&quot;kwrd&quot;&gt;if&lt;/span&gt; (ctrl != &lt;span class=&quot;kwrd&quot;&gt;null&lt;/span&gt;)       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; {       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; IInitializableControl initCtrl = ctrl &lt;span class=&quot;kwrd&quot;&gt;as&lt;/span&gt; IInitializableControl;       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; &lt;span class=&quot;kwrd&quot;&gt;if&lt;/span&gt; (initCtrl != &lt;span class=&quot;kwrd&quot;&gt;null&lt;/span&gt;)       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160;&amp;#160; initCtrl.Initialize(slide.ConfigXML);       &lt;br /&gt;&amp;#160;&amp;#160;&amp;#160; }       &lt;br /&gt;}      &lt;br /&gt;[/code]&lt;/p&gt;&lt;/div&gt; &lt;/blockquote&gt;  &lt;p&gt;This is the foundation to my slideshow. Hopefully I will finish it in the near future, and when I do I will publish the source code here. Unfortunately my slideshow started out as a simple little thing, but grew as I added features and all of the sudden my design didnt quite work and it got all messy. So I decided to rebuild it and make the design more flexible. Unfortunately that means that the publication of the source code is a bit delayed.&lt;/p&gt;</id><updated>2008-07-07T19:25:11.0000000Z</updated><summary type="html">Blog post</summary></entry> <entry><title>InitParams...a good way to start</title><link href="http://chris.59north.com/post.aspx?id=766efd54-dd83-4c66-bb4f-9ec46895549c" /><id>&lt;p&gt;A feature that is often missed in Silvelright is the possibility to give the application information at start up. Sort of like sending parameters to a constructor. This is done by passing values through the InitParams property. This feature has been available since Silverlight 1.0, but it has changed in 2.0. A 2.0 application is split in two parts, an Application class and a UserControl, and the InitParams is sent to the Application part. If you listen to the Application.Startup event, you will get hold of an StartupEventArgs object. This control contains a InitParams property containing the values sent to the control. The InitParams is a comma separated string when added in markup, but a IDictionary&amp;lt;string,string&amp;gt; when in code. How you pass it from the Application object to the UserControl is up to the developer. There are several ways of doing this. The simplest is to add a parameter to the contructor of the UserControl and pass in the Dictionary there. Another is to add a property on the Application class and &amp;quot;publish&amp;quot; the information there and let the UserControl fetch it.&lt;/p&gt;  &lt;p&gt;This parameter is available to us if we use the &amp;lt;asp:Silverlight /&amp;gt; control. This makes it a very simple way for us to pass a certain amount of data from serverside aspx code to our clientside Silverlight application without having to use Ajax or webservices. Or maybe we could use the InitParams to tell our application the Uri to the webservice...&lt;/p&gt;</id><updated>2008-07-07T19:24:32.0000000Z</updated><summary type="html">Blog post</summary></entry> <entry><title>Globalization Demo from Developer Summit &#39;08</title><link href="http://chris.59north.com/post.aspx?id=813ccd85-ee78-4e0c-b849-6f8d99ea73a6" /><id>&lt;p&gt;
At the EPiServer developer summit a couple of weeks ago I held a session about multilanguage support in EPiServer. For those of you who were there, you know why I&amp;#39;ve added this entry. I screwed up the demo completely and promised to upload the demo code to my blog. My, at that moment, not existing blog. So here it is. I&amp;#39;ve created a blog and added the code for download. 
&lt;/p&gt;
&lt;p&gt;
 
&lt;/p&gt;
&lt;p&gt;
It is a simple plug-in for EPiServer CMS 5. Just add the plug-in files in the admin folder in you project, and the xml-file in the lang folder and you are done. Almost, you must of course also compile the project to get the plug-in compiled and into your assembly... 
&lt;/p&gt;
&lt;p&gt;
Using this plug-in you can export the content of your pages to xml and also import it after it has been translated. Just go to the plug-in in admin mode and choose to export some pages. When exporting you have to choose a root page for the export as well as the language to export. Save the export to disk. Change the content in the xml file. Update the content language by setting the identifier for the new language in the root element. Then update the property values according to the new language. After this you can import the xml and the system will automatically add new pages or update existing pages in the new language. 
&lt;/p&gt;
&lt;p&gt;
I hope you understand what I&amp;#39;m writing. If not, check out the code. &lt;a rel=&quot;enclosure&quot; href=&quot;http://chris.59north.com/file.axd?file=Globalization+Demo.zip&quot;&gt;Globalization Demo.zip (4.83 kb)&lt;/a&gt;
&lt;/p&gt;
</id><updated>2008-06-09T23:26:00.0000000Z</updated><summary type="html">Blog post</summary></entry></feed>