Loading xap file on demand

Posted by synergetic on Stack Overflow See other posts from Stack Overflow or by synergetic
Published on 2010-05-06T06:30:13Z Indexed on 2010/05/06 7:08 UTC
Read the original article Hit count: 612

I have Silverlight application called MyApp. During startup MyApp loads MyApp.Main.xap module using the following code:

WebClient wc = new WebClient();
wc.OpenReadCompleted += new OpenReadCompletedEventHandler(onMainModuleLoaded);
Uri uri = new Uri("MyApp.Main.xap", UriKind.Relative);
wc.OpenReadAsync(uri);

It works. Within MyApp.Main I would like to load another xap file MyApp.Billing.xap, so I wrote like the same as above

WebClient wc = new WebClient();
wc.OpenReadCompleted += new OpenReadCompletedEventHandler(onBillingModuleLoaded);
Uri uri = new Uri("MyApp.Billing.xap", UriKind.Relative);
wc.OpenReadAsync(uri);

but it throws an error saying the file not found. MyApp.Billing.xap file is inside ClientBin folder and I can download it directly via absolute path in a browser. If I try to download MyApp.Billing.xap not from inside MyApp.Main, but from inside MyApp (instead of MyAPp.Main.xap) it also works fine. What might be the problem?

© Stack Overflow or respective owner

Related posts about Silverlight

Related posts about dynamically-loaded-xap