large silverlight site (hundreds of pages) - silverlight

When you surf a silverlight site, I believe it downloads the site to the client.
Excluding practicality, lets say your going to develop a large full silverlight site with nearly a thousand pages of static content.
Is there any way you can set the compiler to divide the silverlight app in small parts that will only download as a user attempts to access different areas of the huge site?

You need to use Managed Extensibility Framework (MEF) of Silverlight.
With it you can create small silverlight projects and load them when you need.
Here are some links:
3 Steps to MEF - Export, Import, Compose from silverlight.tv
When and Where to use MEF from silverlight.tv
Using MEF with Silverlight 4 for Extensibility from silverlight.net

To be more specific it downloads the XAP file to the client, which is the end product for your silverlight project.
(Input) Silverlight project -> (Output) one XAP File (containing the main assembly and its dependencies) compressed in a normal ZIP file, but ironically renamed to take XAP extension.
Yes, this is doable, see my answer HERE, you need the same methodology depending on the control (portion) you need upon a specified condition.

Related

Using custom icon assets with DesktopAppConverter UWP

I'm using DesktopAppConverter to convert my WPF application into a windows store compatible app. Right now I'm able to get the AppX built but the problem is to do with my application assets.
At the moment, DesktopAppConverter is taking my existing Icon (which looks great in WPF) and using it to somehow create all the different Assets at different resolutions for the UWP app. The icons it creates are coming out looking terrible, really blocky and clearly upscaled.
The way I'm looking at it is that there's 2 options.
1 - I specify a really large Icon file in my WPF app that might somehow end up being scaled better inside DesktopAppConverter. The problem here is that with a large resolution Ico file, I end up with a crazy large file (Ico's don't compress very well from what I understand).
2 - I specify a folder of correctly scaled assets (created using UWP Tile Generator) when building through DesktopAppConverter. This is what I'd like to do. I don't really want to be tweaking my Assets every time.
The 3rd choice is the one I'm heading towards, but don't really want to do. It involves building with AppX, then replacing the assets, then using MakeAppX, then re-signing with the SignTool. All of that seems really unnecessary, so I'm hoping someone from MSFT can let me know I'm missing something fundamental.
Thanks.
The easiest way to handle the visual assets for your app package is to use the package manifest editor in Visual Studio 2017.
To use it for your converted app, create an empty UWP project and add the output of the conversion (incl. your appx manifest) in this project. Now you can use the editor to manage the visual assets, build your packages for store submission and much more.
Here is a document that describes the process:
https://learn.microsoft.com/en-us/windows/uwp/porting/desktop-to-uwp-packaging-dot-net
Thanks,
Stefan Wick - Windows Developer Platform

Building assembly and adding embedded resource at run-time - Scenario included

EDIT: To better clarify the issue, I've included a scenario:
Scenario: There is an education institution that produces video tutorials. We were asked to provide a solution on how to protect the video files so as not to give access to the real video files to the users. The videos are published "offline" using DVD ROM.
Solution: We decided to embed the video files into the silverlight assembly and write a Silverlight OOB application that takes advantage of MediaElement control to play video content. This control accepts video resource of type Stream which makes it possible to use Application.GetResourceStream method to read the embedded resource as an stream and pass it to MediaElement.
Design: We need to write two applications:
One that accepts one or more video files from education institute operator and creates an assembly and embeds the video files into the assembly.
Another application that reads the contents of the newly-created assemblies and plays the video content using MediaElement control.
Problem:
How to generate a silverlight assembly and embed video resources to it "programmatically" using a C# windows app or Silverlight app? I wanted to use AssemblyBuilder class, but it does not contain Save method in silverlight.
Any help would be greatly appreciated.
Assuming you feel you need to embed your video in the way you described, rather than stream it, then you do not need to run the creation of modules on the Silverlight client.
Have the Silverlight app upload the Video to the matching Silverlight host
Now you have full access to the .Net stack and can create pretty much anything you need (including compiling projects or assemblies on the fly and using AssemblyBuilder).
If this does not cover your situation, please clarify the question further.

Silverlight on-demand compilation/Build

Is it possible to build silverlight application in on-demand manner. I have lot of silverlight applications to be shipped. I would like to ship the project files alone. Based on some user interaction, I would like to generate the XAP.
You thought about using a NANT script to compile your project and grab the output xap file?

How does silverlight work in web browser?

How does Silverlight application work in browser?
E.g When I access a page having Silverlight control, how does Silverlight runtime extract data/ dlls from 'XAP' package? does it load all dlls in one go or support lazy loading of dlls?
If you're interested in some of the inner working of how the silverlight plugin and how it reads the XAP visit http://stuff.seans.com/2009/03/23/hello-silverlight-world-part-3-the-lifecycle-of-a-silverlight-control/#comment-826
He sums it up very well.
The Silverlight Runtime will extract and load all the DLLs from the Xap file before executing the entry point. Other files within the Xap will be extracted in an on demand fashion.
If you have significant "data" files in your Silverlight project and they need to be in the Xap add them as "Content" rather than as "Resource".
For larger Silverlight apps there are technologies such as MEF which allow you to divide up your app into multiple XAPs and support the dynamic loading of dlls.
Silverlight xap file is just a zip file that contains all required dll s, and files for executing. browser downloads, than extracts files and start executing using Silverlight player, which is light version of .NET engine. Of course there are technologies for lazy loading dll's too, I guess, if you need it.

Dynamically loading Silverlight XAPs

I have four Silverlight 4 apps, each in their own Visual Studio project, for which I want to write a "shell" to host them so they appear to the user as a single application. To minimize download times, I will download the XAPs and supporting DLLs dynamically. So I will end up with 5 apps - the shell and the four sub-apps. Now my problem:
My apps all reference the Telerik suite, and this is a fairly significant download. When I build my apps, the Telerik DLLs get zipped into each XAP (as expected). So even if I dynamically load the XAPs, the Telerik DLLs will be downloaded multiple times, once for each XAP.
So how do I make it so the Telerik DLLs are downloaded only once (say, by the Shell), and shared by all the sub-applications?
If you go into the Properties window of your various Silverlight projects, and select the "Silverlight" tab, you'll see an option to "Reduce XAP size by using application library caching". If you select that, the support libraries (Telerik, in this case) will get packaged into separate .zip files that can be downloaded separately. See here for more details, including instructions on how to configure your own assemblies for this sort of behavior. (I presume, though I haven't checked, that Telerik has done this with their controls.)

Resources