title: Unity: Problem with resolving RIA DomainContext
body: <p>I am using PRISM 4 and got my head around almost all features, however as soon as I would like to inject my DomainContext class (RIA) into my view model, the hell breaks loose. :)  It would be great if an experienced Unity/Prism developer could give me an advice how to proceed.</p>
  
  <p>Within my bootstrapper, I am registering the required class in Unity Container like this:</p>
  
  <pre><code>protected override void ConfigureContainer()
          {
              base.ConfigureContainer();
              Container.RegisterType&lt;SCMDomainContext&gt;();
          }
  </code></pre>
  
  <p>Within the NavigationModule, I have the following in the ctor to register the NavigationView with a particular region. </p>
  
  <pre><code>public NavigationModule(IUnityContainer container, IRegionManager regionManager)
          {
              _container = container;
              _regionManager = regionManager;
  
              _regionManager.RegisterViewWithRegion(Constants.NavRegion, () =&gt; _container.Resolve&lt;NavigationView&gt;());
  
          }
  </code></pre>
  
  <p>The View takes the View Model as dependency:</p>
  
  <pre><code> public NavigationView(NavigationViewModel viewModel)
          {
              InitializeComponent();
  
              Loaded += (s, e) =&gt;
                            {
                                DataContext = viewModel;
                            };            
          }
  </code></pre>
  
  <p>The ViewModel has the following:</p>
  
  <pre><code>public NavigationViewModel(SCMDomainContext context)
          {
              _context = context;
              ConstructCommon();
          }
  </code></pre>
  
  <p>As soon as I comment this ctor out and put a en empty ctor, it is all fine, for some reason I can't resolve the SCMDomainContext class. Which is the one you add to have the Domain Context created for you provided by Ria Services.</p>
  
  <p>Since I am using Silverlight, I can't see the stack trace to follow the exception, all I get is this message on a page. What am I missing please? </p>
  
  <pre><code>Microsoft JScript runtime error: Unhandled Error in Silverlight Application An exception occurred while initializing module 'NavigationModule'. 
      - The exception message was: Activation error occured while trying to get instance of type NavigationModule, key ''
      Check the InnerException property of the exception for more information. If the exception occurred 
      while creating an object in a DI container, you can exception.GetRootException() to help locate the 
      root cause of the problem.    at Microsoft.Practices.Prism.Modularity.ModuleInitializer.HandleModuleInitializationError(ModuleInfo moduleInfo, String assemblyName, Exception exception)
     at Microsoft.Practices.Prism.Modularity.ModuleInitializer.Initialize(ModuleInfo moduleInfo)
     at Microsoft.Practices.Prism.Modularity.ModuleManager.LoadModulesThatAreReadyForLoad()
     at Microsoft.Practices.Prism.Modularity.ModuleManager.IModuleTypeLoader_LoadModuleCompleted(Object sender, LoadModuleCompletedEventArgs e)
     at Microsoft.Practices.Prism.Modularity.XapModuleTypeLoader.RaiseLoadModuleCompleted(LoadModuleCompletedEventArgs e)
     at Microsoft.Practices.Prism.Modularity.XapModuleTypeLoader.HandleModuleDownloaded(DownloadCompletedEventArgs e)
     at Microsoft.Practices.Prism.Modularity.XapModuleTypeLoader.IFileDownloader_DownloadCompleted(Object sender, DownloadCompletedEventArgs e)
     at Microsoft.Practices.Prism.Modularity.FileDownloader.WebClient_OpenReadCompleted(Object sender, OpenReadCompletedEventArgs e)
     at System.Net.WebClient.OnOpenReadCompleted(OpenReadCompletedEventArgs e)
     at System.Net.WebClient.OpenReadOperationCompleted(Object arg)
  </code></pre>
  
  <p>Your help on this is highly appreciated,
  Kave</p>