Loading libraries run-time
I’m working on an application with the ability to upload and run Silverlight 1.1 gadgets. This means my program needs to be able to load assemblies in run-time.
After several tests and an e-mail exchange with an MS Evangelist it seams like it’s impossible.
UPDATE: Here is how I managed to do it. The trick is that the xaml downloads and loads its assembly automatically.
void DownloadXamlFile()
{
GadgetXamlDownloader.Completed += new EventHandler(GadgetXamlDownloader_Completed);
GadgetXamlDownloader.Open(“GET”, new Uri(“./Gadgets/TestGadget/Page.xaml”, UriKind.Relative));
GadgetXamlDownloader.Send();
}
void GadgetXamlDownloader_Completed(object sender, EventArgs e)
{
ObjectFromXamlString(GadgetXamlDownloader.ResponseText);
}
void ObjectFromXamlString(string XamlString)
{
DependencyObject Gadget = XamlReader.Load(XamlString,true); //Namescoping is turned on
Gadget.SetValue(Canvas.TopProperty,this.Height/2-(Gadget as Canvas).Height/2);
Gadget.SetValue(Canvas.LeftProperty, this.Width / 2 - (Gadget as Canvas).Width / 2);
this.Children.Add(Gadget as Visual);
}
My old failed tests after the jump, they might be useful.

