How to seperate the XAP file and dll files in silverlight?

6 posts, 0 answers
  1. Edward Pauley
    Edward Pauley avatar
    49 posts
    Member since:
    May 2010

    Posted 23 Mar 2011 Link to this post

    Hi

    1.

    Is there anyway to seperate the XAP and assembly dll files? 
    The reason i ask this is because 
    I don't want the user to redownload the dlls files everytime they reload the silverlight application.

    2.
    Is there anyway to let the user download the dlls files one time only and when they reload the application on browser, they don't need to download the dlls again?

    3.

    Is there a way to catching the silverlight app on the browser?? so when the user reopen the website which contains the xap silverlight file then they don't need to redownload it


    thanks

  2. Yavor Georgiev
    Admin
    Yavor Georgiev avatar
    982 posts

    Posted 23 Mar 2011 Link to this post

    Hello Edward,

     You can use Application Library Caching to achieve your first two goals. However, it's up to you to configure your web server to return the correct cache lifetime headers when serving Silverlight applications so that browsers will cache the XAPs and the DLLs.

    Regards,
    Yavor Georgiev
    the Telerik team
  3. Edward Pauley
    Edward Pauley avatar
    49 posts
    Member since:
    May 2010

    Posted 30 Mar 2011 Link to this post

    Hi Yavor,

    I have just checked the link which you give me
    However, i think my situation  is a little different from what has been stated on msdn:

    Application library caching affects only assemblies that your application requires at startup. If your application loads some assemblies on demand, it always retrieves them from the server, and never from the browser cache.


    currently, my project is using the Silverlight Business Template which has App.XAML, Main.XAML, Home.XAML, and my custom screens(such as Customer.XAML, Order.XAML,.....)

    Let me explain a little bit about the project:
    as by DEFAULT(i don't modify the template), the App.xaml will run which will open the the Main.Xaml
    and from the Main.Xaml , i navigate to the Home.Xaml as a default page.
    on my Home.Xaml i have a Telerik Menu control . When you click on different menu items, it will pop up my custom screens(customer.xaml, order.xaml, ....) correspondingly. And my custom screens use a lot of your Telerik controls which need Telerik dll reference

    Ok, from what i understand , the Application Library Caching is only work at the STARTUP page(i think it will be the App.xaml in my case. And in this file , there is no reference necessary to Telerik dll because this page doesn't have any controls. Just like the one in Business Template)
    . Because of that , i don't think it will work for my custom screen which needs the dll from Telerik

    do i understand it correctly?
    can you point me to the solution where i can seperate my Telerik dll from the XAP file ? so the user only need to download the dll ONE Time. 
    ===> if i make any change to the project, the user just need to download the new XAP file but not the Telerik dll which remains unchanged

    thanks
  4. Yavor Georgiev
    Admin
    Yavor Georgiev avatar
    982 posts

    Posted 30 Mar 2011 Link to this post

    Hi Edward,

     The MSDN description is a bit vague, so I'm afraid you didn't get a feeling of how it really works. In essence, every assembly that your Silverlight application refers to in the project's references tab is a candidate for Application Library Caching as long as that assembly is accompanied by an '.extmap.xml' file of the same name, which instructs Visual Studio what Assembly and Deployment Parts to generate for the project's output. Telerik's RadControls for Silverlight installation package includes extmaps for all our assemblies. So even if no page in your application contains a Telerik control, but your project references any number of Telerik assemblies, those assemblies will be split from the application payload and loaded via Application Library Caching. All that's needed for ALC to kick in is an assembly reference from the Silverlight Application project.

     You can just turn on the Application Library Caching option for your project (it's available as a checkbox in the Silverlight tab of your SL app's properties page) and Visual Studio should automatically split the compatible assemblies from your XAP. Check the ClientBin folder of the ASP.NET project hosting your Silverlight application and you should see the XAP, now a lot smaller in size, as well as any assemblies that qualify for Application Library Caching packaged as ZIP files.

     After your application is built and ready for deployment, you'll need to make sure to configure your web server to emit the proper cache lifetime headers for all the assembly ZIPs so as to let the browser know that they should be cached locally.

    Kind regards,
    Yavor Georgiev
    the Telerik team
  5. Edward Pauley
    Edward Pauley avatar
    49 posts
    Member since:
    May 2010

    Posted 01 Apr 2011 Link to this post

    Hi Yavor,

    what did you mean in your last statement? i tried to search online to know how to do your last statement but couldn't find anything.

    After your application is built and ready for deployment, you'll need to make sure to configure your web server to emit the proper cache lifetime headers for all the assembly ZIPs so as to let the browser know that they should be cached locally.

    Right now, after following your instruction, i saw the Telerik dlls have been extract from the XAP file

    1.My attempt to follow your last statement:
    I tried to modify (the name of the zip file) one of your extmap.xaml such as Telerik.Window.Data.extmap.xaml with the hope that after Building the solution , it will produce different name of zip file (so in case i upgrade the assembly dll. Then the browser will recognize the different name of zip file and it will redownload the external dll zip file again. I think this is what your statement means)
    for example:
    (original)
    <extension downloadUri="Telerik.Windows.Data.zip" />
    (modified to)
    <extension downloadUri="Telerik.Windows.DataTesting.zip" />

    However, it doesn't work. After building solution, i still get the name of the zip file as Telerik.Windows.Data.zip

    2.
    One note thing is that basing from what i read on the msdn "the extmap.xaml file should be in the same location of the assembly dlls files". In my project solution, i have an extra folder called Assembly which will contain all of the needed Telerik dlls . I just notice one thing that, i don't even need to include the files extmap.xaml in my Assembly folder to be with your Telerik dll and the Process of extracting dll out of XAP still works. So i guess in your dll assembly, you must have set some internal default mapping already (no need for extmap.xaml in the same location with the dll)


    In summary, can you instruct me how to do your last statement (sample code is nice)
    this is
    the code which will produce different XAP file name everytime i deploy a new version of the project (but not for the external assembly dll, only for the XAP). No idea how to do for the assembly dll
    the code is in Default.aspx

    <div id="silverlightControlHost">
           <object data="data:application/x-silverlight-2," type="application/x-silverlight-2" 
               width="100%" height="100%">
                
                 
               <%
                   string orgSourceValue = @"ClientBin/SilverFinancials.xap";
                   string param;
                   if (System.Diagnostics.Debugger.IsAttached)
                       param = "<param name=\"source\" value=\"" + orgSourceValue + "\" />";
                   else
                   {
                       string xappath = HttpContext.Current.Server.MapPath(@"") + @"\" + orgSourceValue;
                       DateTime xapCreationDate = System.IO.File.GetLastWriteTime(xappath);
                       param = "<param name=\"source\" value=\"" + orgSourceValue + "?ignore="
                       + xapCreationDate.ToString() + "\" />";
                   }
                   Response.Write(param);
               %>
               <param name="onError" value="onSilverlightError" />
               

  6. Yavor Georgiev
    Admin
    Yavor Georgiev avatar
    982 posts

    Posted 01 Apr 2011 Link to this post

    Hello Edward,

     I'm not sure where Visual Studio gets the extmaps for the assemblies in this case. I don't think there is a way to specify a "default mapping" in the assembly itself. Perhaps you have the same assemblies in GAC?

     In the last paragraph of my response I suggested to configure the IIS cache policy for the assembly ZIPs (detailed here), because this gives you greater control over the default settings. Even if you don't perform this step, the browser will still cache the resources using its default cache-control settings. Using the cache policy setting in IIS, you can control when the cache of your content should expire and you don't have to tweak the GET request with nonsensical parameters as you currently do for your XAP.

    Greetings,
    Yavor Georgiev
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Back to Top