title: Silverlight 4, WCF RIA Services generated incomplete code
body: <ul>
  <li>I started with the Silverlight Business Application Template
  
  <ul>
  <li>I will call this MyApp and MyApp.Web</li>
  </ul></li>
  <li>I added a new SL application project.</li>
  <li>and added a ria link to the existing web project. 
  
  <ul>
  <li>I will call this Loader</li>
  </ul></li>
  </ul>
  
  <p>This new SL app is the entry point of my solution, and basically loads the mainpage from the other xap file. Checks for updates, etc.</p>
  
  <ul>
  <li>I removed the App.xaml and App.xs files from MyApp</li>
  <li>Because Loader is now the Application
  
  <ul>
  <li>I copied the relevant code from MyApp - App.cs to Loader - App.cs</li>
  <li>I added the relevant code from MyApp - App.xaml to Loader - App.xaml</li>
  <li>Mostly this is the WebContext stuff.</li>
  </ul></li>
  </ul>
  
  <p>The problem is that the RIA Services <em>generated</em> code for <strong>Loader</strong> is not the same code as the code for <strong>MyApp</strong> </p>
  
  <p>The generated code for MyApp contains the following namespaces:</p>
  
  <ul>
  <li>MyApp</li>
  <li>MyApp.Web</li>
  <li>MyApp.Web.Models</li>
  <li>MyApp.Web.Services</li>
  </ul>
  
  <p>The generated code for Loader contains the namespace:</p>
  
  <ul>
  <li>Loader</li>
  </ul>
  
  <p>The following line of code in Loader - App.cs throws <strong>InvalidOperationException</strong>.</p>
  
  <pre><code>WebContext.Current.Authentication.LoadUser(this.Application_UserLoaded, null);
  </code></pre>
  
  <p>The error msg for the exception is:</p>
  
  <blockquote>
    <p>The DomainContextType is null or invalid and there are no contexts generated from <code>AuthenticationBase&lt;T&gt;</code></p>
  </blockquote>