title: Will Prism OnDemand module loading work in an OOB scenerio?
body: <p>Should the loading of OnDemand Prism modules work in an OOB scenerio? If so, I cannot seem to make it work. Everything is currently working in browser without any problems. Specifically I:
  register my modules in code:</p>
  
  <pre><code>    protected override IModuleCatalog GetModuleCatalog() {
          var catalog = new ModuleCatalog();
          Uri source;
  
          if( Application.Current.IsRunningOutOfBrowser ) {
              source = IsolatedStorageSettings.ApplicationSettings[SOURCEURI] as Uri;
          }
          else {
              var src = Application.Current.Host.Source.ToString();
              src = src.Substring( 0, src.LastIndexOf( '/' ) + 1 );
              source = new Uri( src );
              IsolatedStorageSettings.ApplicationSettings[SOURCEURI] = source;
              IsolatedStorageSettings.ApplicationSettings.Save();
          }
  
          if( source != null ) {
              var mod2 = new ModuleInfo { InitializationMode = InitializationMode.OnDemand,
                            ModuleName = ModuleNames.mod2,
                            ModuleType = "mod2.Module, mod2.Directory, '1.0.0.0', Culture=neutral, PublicKeyToken=null" ),
                            Ref = ( new Uri( source, "mod2.xap" )).AbsoluteUri };
  
              catalog.AddModule( mod2 );
          }
  
  // per Jeremy Likeness - did not help.
          Application.Current.RootVisual = new Grid();
  
          return ( catalog );
      }
  </code></pre>
  
  <p>later request for the module to be loaded is made:</p>
  
  <pre><code>mModuleManager.LoadModule( ModuleNames.mod2 );
  </code></pre>
  
  <p>and wait for a response to an event published during the initialization of that loaded module.</p>
  
  <p>The module appears to never be loaded, and when the application is running under the debugger there will be a message box that states that the web server returned a 'not found' error. I can take the requesting url for the module and enter it into Firefox and download the module with no problem.</p>
  
  <p>I have not been able to find any reference to this actually being workable, but it seems as though it should. The most I have found on the subject is a <a href="http://csharperimage.jeremylikness.com/2010/05/webclient-and-deploymentcatalog-gotchas.html" rel="nofollow noreferrer">blog entry by Jeremy Likeness</a>, which covers loading modules in MEF, but applying his knowledge here did not help.</p>
  
  <p>The server is localhost (I have heard it mentioned that this might cause problems). The server has a clientaccesspolicy.xml file - although I don't expect that is needed.
  I am using the client stack and register it during app construction:</p>
  
  <pre><code>WebRequest.RegisterPrefix( Current.Host.Source.GetComponents( UriComponents.SchemeAndServer, UriFormat.UriEscaped ), WebRequestCreator.ClientHttp );
  </code></pre>
  
  <p>Followup questions:</p>
  
  <p>Can all of the xaps be installed to the client desktop in some manner - or only the main application xap? specify them in appmanifest.xml somehow??</p>
  
  <p>Is it worth it make this work if only the application.xap is installed and the rest of the xaps must be downloaded anyway?</p>