﻿<?xml version="1.0" encoding="utf-8"?><rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:media="http://search.yahoo.com/mrss/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0"><channel><title>Intersoft Community - ClientUI - Load external xap on-demand.  How?</title><link>http://www.intersoftsolutions.com/Community/ClientUI/Load-external-xap-on-demand-How/</link><description /><generator>http://www.intersoftsolutions.com</generator><language>en</language><copyright>Copyright 2002 - 2015 Intersoft Solutions Corp. All rights reserved.</copyright><ttl>60</ttl><item><title>Load external xap on-demand.  How?</title><link>http://www.intersoftsolutions.com/Community/ClientUI/Load-external-xap-on-demand-How/</link><pubDate>Tue, 17 May 2011 08:50:36 GMT</pubDate><dc:creator>jimmyps</dc:creator><description>Hello,&lt;br /&gt;&lt;br /&gt;Make sure that the UseGlobalShell property of the UXFrame is set to true. This will ensure that all applications are managed only by the same shell instance. When this is properly configured, the loaded applications won't be downloaded anymore (even if AutoInstallOnDownload is disabled).&lt;br /&gt;&lt;br /&gt;Let me know if this works in your end.&lt;br /&gt;&lt;br /&gt;Hope this helps,&lt;br /&gt;Jimmy&lt;br /&gt;</description></item><item><title>Load external xap on-demand.  How?</title><link>http://www.intersoftsolutions.com/Community/ClientUI/Load-external-xap-on-demand-How/</link><pubDate>Fri, 13 May 2011 20:16:50 GMT</pubDate><dc:creator>bap3</dc:creator><description>&lt;p&gt;More composite app questions:&lt;/p&gt;
&lt;p&gt;I've got a composite app (ClientUIOutlookNavApp1) with 2 external apps (App1 &amp; App2).  In fiddler, the external apps always download each time i run ClientUIOutlookNavApp1 even when they have not changed.  Why doesn't UXShell load App1 and App2 from local storage?  &lt;/p&gt;
&lt;p&gt; &lt;/p&gt;
&lt;p&gt;here's the startup code in ClientUIOutlookNavApp1.  any suggestions much appreciated!&lt;/p&gt;&lt;pre&gt;public partial class App : Application
    {&lt;/pre&gt;&lt;pre&gt;        // define the ApplicationID used to reference this application from UXShell or other containers
        public static string ApplicationID = "ClientUIOutlookNavApp1";
        public static string DataFolder = "/ClientUIOutlookNavApp1;component/Assets/Data/";
        public static string ImagesFolder = "/ClientUIOutlookNavApp1;component/Assets/Images/";

        public App()
        {
            this.Startup &amp;#43;= this.Application_Startup;
            this.Exit &amp;#43;= this.Application_Exit;
            this.UnhandledException &amp;#43;= this.Application_UnhandledException;

            InitializeComponent();
            InitializeShell();
        }

        private void InitializeShell()
        {        
            UXShell shell = new UXShell();
            shell.RootApplication = UXShell.CreateApplicationFromType(typeof(App), ApplicationID, ApplicationID);
            shell.CheckForUpdates = true;  
            shell.AutoInstallOnDownload = true;
            shell.AutoInstallUpdates = true;
            //shell.InstallStorageScope = StorageScope.Site;          
            this.ApplicationLifetimeObjects.Add(shell);      
        }

        private void Application_Startup(object sender, StartupEventArgs e)
        {
           
            // create a new ApplicationPackage that represents App1

            ApplicationPackage app1 = new ApplicationPackage()
            {
                ID = "App1",
                Name = "App1",
                Source = new Uri("App1.xap", UriKind.RelativeOrAbsolute),
                EnableMetadataDiscovery = true,
                MainType = "App1.MainPage",
                VirtualPathIdentity = "/App1",
                Size = -1 // auto detect the file size at runtime
            };
            

            // add the application to the UXShell
            UXShell.Current.Applications.Add(app1);

            ApplicationPackage app2 = new ApplicationPackage()
            {
                ID = "App2",
                Name = "App2",
                Source = new Uri("App2.xap", UriKind.RelativeOrAbsolute),
                EnableMetadataDiscovery = true,
                Size = -1 // auto detect the file size at runtime
            };
            
            // add the application to the UXShell
            UXShell.Current.Applications.Add(app2);
          
            this.RootVisual = new MainPage();        
        }

        private void Application_Exit(object sender, EventArgs e)
        {

        }

        private void Application_UnhandledException(object sender, ApplicationUnhandledExceptionEventArgs e)
        {
            // If the app is running outside of the debugger then report the exception using
            // the browser's exception mechanism. On IE this will display it a yellow alert 
            // icon in the status bar and Firefox will display a script error.
            if (!System.Diagnostics.Debugger.IsAttached)
            {
                e.Handled = true;

                // Displays a user-friendly error page to the primary navigation (UXFrame) of the application
                Deployment.Current.Dispatcher.BeginInvoke(delegate { DisplayErrorToNavigationFrame(e); });
            }
        }

        private void DisplayErrorToNavigationFrame(ApplicationUnhandledExceptionEventArgs e)
        {
            UXFrame frame = UXFrame.GetPrimaryNavigator(this.RootVisual);

            if (frame != null)
            {
                frame.Navigate(new Uri("/Error", UriKind.Relative), e);
            }
            else
            {
                ReportErrorToDOM(e);
            }
        }

        private void ReportErrorToDOM(ApplicationUnhandledExceptionEventArgs e)
        {
            try
            {
                string errorMsg = e.ExceptionObject.Message &amp;#43; e.ExceptionObject.StackTrace;
                errorMsg = errorMsg.Replace('"', '\'').Replace("\r\n", @"\n");

                System.Windows.Browser.HtmlPage.Window.Eval("throw new Error(\"Unhandled Error in Silverlight Application " &amp;#43; errorMsg &amp;#43; "\");");
            }
            catch (Exception)
            {
            }
        }
    }&lt;/pre&gt;
</description></item><item><title>Load external xap on-demand.  How?</title><link>http://www.intersoftsolutions.com/Community/ClientUI/Load-external-xap-on-demand-How/</link><pubDate>Thu, 12 May 2011 08:37:36 GMT</pubDate><dc:creator>bap3</dc:creator><description>&lt;p&gt;I think i figured it out.  I just had to remove the download statement in the application_startup:&lt;/p&gt;
&lt;p&gt;app.Download(false);&lt;/p&gt;
&lt;p&gt;When i navigate to the external xap, UXShell automatically downloads and initializes the xap.  pretty cool.&lt;br /&gt;&lt;/p&gt;
</description></item><item><title>Load external xap on-demand.  How?</title><link>http://www.intersoftsolutions.com/Community/ClientUI/Load-external-xap-on-demand-How/</link><pubDate>Wed, 11 May 2011 23:40:17 GMT</pubDate><dc:creator>bap3</dc:creator><description>&lt;p&gt;I would like to load a xap to external application when user clicks on navigation link.  your docs only show how to load external apps on startup (sample code below)....but your marketing material states you can load on demand.  how is this done?&lt;/p&gt;
&lt;p&gt;Please note: my defintion of "on-demand" is when a user clicks on a navigation link that references the external xap.&lt;/p&gt;&lt;pre&gt; private void Application_Startup(object sender, StartupEventArgs e)
        {
            shellManager.RootPage = new MainPage();
            this.RootVisual = shellManager.RootPage;

            //this.RootVisual = new MainPage();

            // create a new ApplicationPackage that represents App1
            ApplicationPackage app = new ApplicationPackage()
            {
                ID = "App1",
                Name = "App1",
                Source = new Uri("App1.xap", UriKind.RelativeOrAbsolute),
                EnableMetadataDiscovery = true,
                Size = -1 // auto detect the file size at runtime
            };

            // add the application to the UXShell
            UXShell.Current.Applications.Add(app);

            // download the application
            app.Download(false);
        }
&lt;/pre&gt;
</description></item></channel></rss>