Download xap file on demand

I have a Silverlight application called MyApp. At startup, MyApp loads the 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. In MyApp.Main, I would like to upload another xap file MyApp.Billing.xap, so I wrote the same way 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 stating that the file was not found. The MyApp.Billing.xap file is located inside the ClientBin folder, and I can download it directly through the absolute path in the browser. If I try to download MyApp.Billing.xap from inside MyApp.Main, but from inside MyApp (instead of MyAPp.Main.xap) it also works fine. What could be the problem?

+3
source share
1 answer

, , Application.Current.Host.Source, () uri, , ( , ?).

0

Source: https://habr.com/ru/post/1744283/


All Articles