Difference between Type.GetType() in Silverlight and .NET

I am currently working on a little thing in Silverlight and came across an interesting “feature”. The thing I am working on requires me to dynamically create types based on strings in a configuration file, and for this purpose, I created a simple TypeConverter called TypeTypeConverter. It is a very simple converter that takes a string and converts it to a Type. So I created a very simple implementation that looks like this

public class TypeTypeConverter : TypeConverter
{
public override bool CanConvertFrom(ITypeDescriptorContext context, System.Type sourceType)
{
if (sourceType == typeof(string))
{
return true;
}
return base.CanConvertFrom(context, sourceType);
}

public override object ConvertFrom(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value)
{
if (value is string)
{
return Type.GetType((string)value, true);
}
return base.ConvertFrom(context, culture, value);
}
}

As you can see, it is probably a little TOO simple as it doesn’t handle errors at all. But to be honest, in my case it is actually a bit by design.

So why does this simple little thing end up on my blog? Well, because it failed… Not the code as such, but the thing I was trying to do…

More...

Multithreading my way

Ok, so Silverlight is a very cool technology, and Microsoft has done a whole lot of things to make sure that it performs the way it should. They have done things like forcing you to run long running tasks, such as webservice calls, in an asynchronous fashion. But if you start doing long running tasks on your own, you need to make sure to handle the multithreading yourself. Why? Well, if you don’t, you will perform all of that stuff on the UI thread.

And why is performing heavy things on the UI thread a bad thing? Well…it just is!

More...

Removing Design Time references at compile time

As you might have noticed on my blog, I like working with Silverlight, and I like using the MVVM pattern when I do so. As a part of this, I generally create design time ViewModels to get the best help from the tools (VS and Blend). VMs

The annoying thing about this, is that project containing the design time information need to be referenced by the application for the whole thing to work. But when the app is built and released, I really don’t want the extra ViewModels to be included in the xap file. I guess, in most cases, they are fairly simple and small, making the xap bloat minimal. But it still feels wrong. And it feels even worse when your design time VMs become large due to embedded resources such as images and data…

More...

Sessions for MIX11

Earlier today I got word that some of my sessions, that I had sent in as a part of the Open Call for MIX11, had gone past the initial round and are on the MIX11 website for voting. And the sessions that get the most votes gets to be presented at MIX11.

So this obviously means that I need a LOT of votes. And that means that I need you to vote on any of my sessions  that you find interesting. Or all of them if you just want to help me to get the possibility to present at MIX11…

The sessions are available here: http://live.visitmix.com/OpenCall/.

And what are my sessions? Well, I am glad you asked. They are…

Silverlight and Windows Azure - Tips from the Trenches
Join Chris Klug as he share his expertise in combining Windows Azure and Silverlight. This session will provide practical insights on using Silverlight with Windows Azure. It will include guidance on using Silverlight applications with Azure Web and Worker roles as well as approaches for using Windows Azure storage directly from your Silverlight app. This session will also cover the use of Windows Azure as a delivery mechanism for Windows Phone 7 push notifications and as a delivery mechanism for streaming media. Vote

From Phone Zero to Phone Hero in 60 minutes
Join Chris Klug & Chris Auld from Intergen as they build a real Windows Phone 7 app from scratch in 60 minutes. This is a hard core, dual data projector, coding marathon. Chris and Chris will build a Windows Phone 7 series application including Windows Azure hosted push notifications, a rich Silverlight UI and partner integration. You'll see how to take an idea from concept to the Windows Phone Marketplace in just an hour. In other words, not your general 'Hello World' application. Vote

MVVM - The Naked Truth
Model-View-ViewModel is the pattern of choice when writing Silverlight, WPF and Windows Phone 7 applications. It offers the developer a structured way to implement UI functionality and logic. It especially well with the mentioned technologies, as it uses built in features to enable a clean separation between form and function. During this session you will join Chris Klug, a Silverlight Solution Specialist from New Zealand, as he tells all about how you get started with MVVM. The goal is to get an understanding of why it is useful and how it can make your life simpler. And it will be presented in a naked form, no frameworks or helpers, enabling you to focus on the basic ins and outs of the pattern. Vote

Building Composite Silverlight Applications
Silverlight is a great platform for rich internet applications, but a lot of developers seem to forget that we can use many of our advanced desktop app approaches too. By adding a plug-in architecture we can make our apps easily extensible for future requirements. This session provides an introduction to plug-in approaches in Silverlight. It explores both PRISM and MEF as tools for implementing this pattern. You'll leave with the practical knowledge you need to add a plugin mechanism to your new and existing applications. Vote

The Phone Zero to Phone Hero will probably not be presented together with Christ Auld though as he probably won’t be able to go to MIX this year. But I will try and find a worthy replacement if that session were to get picked. And I really hope it is, cause it is a very entertaining session that is very far from your normal session. And also because it seems to polarize the crowd a lot. We have got feedback that ranges from more or less “the worst session ever attended” to “the best session ever attended”. Luckily, the good feedback seems to come from people who go to a lot of conferences and have a bit of experience, which is sort of required to grasp the information at the speed that it is presented…

That’s it for now. More coming soon… I hope… I have a little too much to do at the moment…

My view on HTML 5…and Silverlight

I continuously get questions regarding HTML5 and Silverlight. Especially after Microsoft’s somewhat brilliant comments at PDC. How is Silverlight going to survive now that HTML5 is coming? Why would you chose Silverlight over HTML5? Are you going to lose your job now that Silverlight is dying?

Well, I have finally decided to state my opinion  on my blog. It is obviously a biased opinion as I believe Silverlight to be a better choice in a lot of situations. So this is obviously a risky engagement, but I guess I will just have to endure the flaming I am going to get from a lot of people. Even a lot of people close to me.

But before I go too far, I do want to mention that we are living/working in an ever changing world. My opinions regarding the different technologies will probably change over time as the world changes. But this is my current view of the situation…

So…here we go…let the rant begin!

More...

Finding and mitigating memory leaks in managed code using ANTS

A week or so ago, I got a call from a client who had some issues with an application that I had built. The application is a WPF 4 “media player” that is supposed to runs 24/7. The issue they were facing was that it only ran for about 12 hours before crashing. And at startup it used less than 100Mb of memory, and at the end (before crashing) it used about 1500Mb. So it clearly had a memory leak. And I needed to find it…fast!

And since this is the first time I have had to do this, I decided to share my experiences. Hopefully it will help someone…

More...

Another user group meeting

Next Wednesday, October 20th, I will be presenting at the .NET user group here in Wellington again. This time the talk is all about smooth streaming (same talk as I presented at TechEd NZ). It covers everything from encoding your media, to publishing it on your server and of course also how to consume it from Silverlight. It will also be covering how to get your first live smooth streaming event going.

The talk does, as you can see, cover a wide array of things that has to do with smooth streaming. And to make it even broader, I will show off the Rough Cut Editor (an open source rough video editing tool built in Silverlight). And it would of course not be complete with out touching the cloud. So to finish it off, I will show you how you can deliver smooth streaming media out of Azure blob storage. A very cost effective and good way to share your media.

So if you are in Wellington, or close by, feel free to drop by if it sounds interesting. More information is available here: http://www.dot.net.nz/UserGroupPages/WellingtonNET.aspx

The power of MVVM…

Everyone, and by that I mean anyone that has been coding for more than a year, talks about decoupling and layers. It’s all about building an n-tier architecture, and about decoupling the layer so that they can be changed later on.

And however much I understand this, and like it, and use it, I still argue that it is sometimes overkill. And even though I definitely can argue both sides of this topic, I am not even going to get started doing so. Maybe I will in a later post, when I feel like getting flamed… :)

This post is about how decoupling your view from your view logic using MVVM can really be helpful. And I am not going to talk about how unit testing will help or anything like that. I am going to explain why MVVM is more important than just testing by showing an example…

More...

Using Windows Phone 7 Push Notifications

Windows Phone 7 is still not released, and the APIs, SDK, emulator and so on is till far from complete. Having said that, people are still getting revved up about the platform and have already started to develop on it. I think this is cool, and makes me believe that there will be some really good apps on the market place already on the launch day. Unfortunately, I have been too busy to get too down a dirty with it. I definitely hope to change this, and have decided to build a game. Hopefully it will be complete by launch and I can sell 2 or 3 copies.

But, to be honest, I still feel that the SDK and APIs are changing a bit too much for me to get REALLY excited about it. I really hope that there is a new refresh on the way soon. Cause at the present, I find that there are just too many unknown things that make the development hard. You never know if the issue you are experiencing is due to you doing something wrong or due to a bug in the OS. And if it is a bug in the OS, you don’t really know when or how it will be fixed. And I really don’t want to spend my time working around things now, just to end up with weird an unnecessary workarounds in the code when the final version is released. Having said that, it still doesn’t stop you from playing around with the platform. I can still build most of my game logic and even test it in the browser based version of Silverlight while I wait for the next refresh. One feature that I wanted to try out straight away however is the push notification. Why? Well…let’s just say that I have my reasons…

More...

I got to leave my mark on TechEd US

As you probably know, TechEd US has just passed. I didn’t get to go (like always), but I did get to make my mark on the conference. I got to build one of the apps that Microsoft demoed on stage. I have actually built a bunch of demo apps for Microsoft and their conferences the last year. At some point, I will actually try to find them at some point a post some videos of them here. But they involve a CRM demo with a phone company, a SharePoint demo with a racing team and some other bits and pieces. Anyhow…this year my demo was a Word add-in, and my personal opinion about this project, before it got started, was that it sucked. I I’m not very fond of building Word add-ins as you might have guessed.

More...