Welcome to Pete Brown's 10rem.net

First time here? If you are a developer or are interested in Microsoft tools and technology, please consider subscribing to the latest posts.

You may also be interested in my blog archives, the articles section, or some of my lab projects such as the C64 emulator written in Silverlight.

(hide this)

More on How Assemblies are Downloaded in Silverlight 1.1

Pete Brown - 18 November 2007

Assem in this thread on Silverlight.net pointed out that the downloader object isn't required to get assemblies down to the local machine in Silveright 1.1 (September alpha).

I didn't believe that, so I did a test. Guess what? He's absolutely right. Calling Assembly.Load(name) is sufficient to cause the assembly to be downloaded to your workstation. Thinking about it in retrospect, that makes perfect sense, as that is likely how the initial assemblies listed in the xaml file are brought down. However, I'd need to test myself to be sure of that :)

So, in the case of something like the assembly preloader I wrote about, the downloader object providers finer-grained control over the downloading of assmblies, but it isn't strictly required. If you want to load a single plugin, or a couple plugins, and they aren't overly large, you can just call Assembly.Load. If they are larger, which would probably necessitate the use of a preloader, you can use the Downloader object to get them for you, and then call Assembly.Load().

   
posted by Pete Brown on Sunday, November 18, 2007
filed under:    

5 comments for “More on How Assemblies are Downloaded in Silverlight 1.1”

  1. Mike Wolfsays:
    yah, your solution gives the added benefit of giving the flexibility of responding w/ download progress and all the goodness that comes w/ the downloader.

    For example, I did some experimentation w/ skining and found that, just be adding the reference in the project, I was able to gain a handler on an assembly just by instantiating an object w/ in it, and then you could retrieve assets out of it.

    so for example

    TwitterGadget.Skins.Loader loader = new TwitterGadget.Skins.Loader();
    System.IO.Stream s = loader.GetType().Assembly.GetManifestResourceStream(xaml);

    where loader is an empty class, accomplishes the same as Assembly.Load();


  2. Curt Williamssays:
    Can these techniques for downloading assemblies be used to load assemblies that operate outside the Silverlight sandbox? i.e. Can I download an assembly that targets the regular .NET framework and not the limited Silverlight version of the framework?

    I really want to break out of the sandbox and interact with local system. Can I sign my assembly and have the user prompted if they want to trust the signer or not? Is there a main-stream/supported/secure way to have a Silverlight application interact with the local system after the user accepts some security prompts?

    Thanks
  3. Pete Brownsays:
    Hi Curt

    You won't be able to reference any other assemblies to break out of the sandbox, or else it wouldn't be a very secure sandbox :)

    If you want to make your application Windows-only, you can get similar functionality by using WPF XBAPs or by putting a custom-written activeX control on your page to do the dirty work for you.

    In addition, full-CLR assemblies are not compatible with Silverlight at a binary level as they target different runtimes. THe only way to share code between the platforms is to do it at a source level.

    Pete
  4. Curt Williamssays:
    Thanks for the response Pete. In ASP/AJAX web development we see controls like those used to compress & upload photographs which are trusted, and which have access the local file system. Shouldn't there be some kind of parallel in the Silverlight world so that these types of features can be built using Silverlight? Would you anticipate that some type of security/trust features would be added to Silverlight in the future? Of course you don't want applications getting out of the sandbox without user consent, but it seems like there are cases when it is needed. What do you think?

Comment on this Post

Remember me

3 trackbacks for “More on How Assemblies are Downloaded in Silverlight 1.1”

  1. Christopher Steensays:
    Announcements Krypton 2.6.5 CTP Released [Via: Phil Wright ] ASP.NET MS MVC and the MVC Team [Via:...
  2. WynApsesays:
    Silverlight Cream for November 19, 2007 -- #128
  3. Community Blogssays:
    Catching up on items I've located -- looks like I waited too long: Jesse Liberty explains the Expression