title: ServiceLocationProvider must be set
body: <p>I am using MVVM Light. When I add more value converters in my resources my app crashes with exception:</p>
  <blockquote>
  <p>An exception of type 'System.InvalidOperationException' occurred in Microsoft.Practices.ServiceLocation.DLL but was not handled in user code</p>
  <p>Additional information: ServiceLocationProvider must be set.</p>
  </blockquote>
  <p>In the <code>App.xaml.cs</code> OnLaunched event I have this line</p>
  <pre><code>ServiceLocator.Current.GetInstance&lt;MyViewModel&gt;();
  </code></pre>
  <p>It crashes there..
  In this ServiceLocator I can see there is a SetLocatorProvider method which takes as an argument ServiceLocatorProvider. I couldnt find anything in the Web and Microsofts MSDN page is dated:</p>
  <pre><code>protected override async void OnLaunched(LaunchActivatedEventArgs e)
      {
          Frame rootFrame = Window.Current.Content as Frame;
  
          if (rootFrame == null)
          {
              ...
          }
  
          if (rootFrame.Content == null)
          {
              ...
          }
  
          Window.Current.Activate();
  
          DispatcherHelper.Initialize();
  
          ServiceLocator.SetLocatorProvider(() =&gt; SimpleIoc.Default);
  
          ServiceLocator.Current.GetInstance&lt;MyViewModel&gt;();
      }
  </code></pre>
  <p>EDIT: Here is the full OnLaunched event.
  After putting</p>
  <pre><code>ServiceLocator.SetLocatorProvider(() =&gt; SimpleIoc.Default);
  </code></pre>
  <p>an exception occures:</p>
  <blockquote>
  <p>An exception of type Microsoft.Practices.ServiceLocation.ActivationException' occurred in GalaSoft.MvvmLight.Extras.DLL but was not handled in user code</p>
  </blockquote>
  <p>Additional information: Type not found in cache: cMC.ViewModel.MyViewModel.</p>
  <p>This is the code of ViewModelLocator</p>
  <pre><code>public class ViewModelLocator
  {
      public ViewModelLocator()
      {
          ServiceLocator.SetLocatorProvider(() =&gt; SimpleIoc.Default);
  
          SimpleIoc.Default.Register&lt;MyViewModel&gt;();
      }
  
      public MyViewModel MyVM
      {
          get
          {
              return ServiceLocator.Current.GetInstance&lt;MyViewModel&gt;();
          }
      }
  
      public static void Cleanup() {}
  }
  </code></pre>