Hi,
I am getting the error
The name "ViewModelLocator" does not exist in the namespace "using:MyApp.ViewModel"
in the app.xaml file of a universal application. I am using v5.020 of mvvm light.
Browsing the web I have read solutions such as:
-Cleaning and rebuilding the project
-Placing the
<vm:ViewModelLocator x:Key="Locator" xmlns:vm="using:MyApp.ViewModel"/>
line inside a resource dictionary
-Leaving only the above line in the Application.resources
-Uninstalling and re-installing mvvm
I have tried the above with no success.
I would also like to note that the error is not encountered in the WindowsPhone8.1(winrt) project and the app runs fine. Only in the Windows 8.1 project does the error show up.
If this error is not resolved I won't be able to reference any of my ViewModels which is obviously a huge problem.
Below are my App.xaml file and an abbreviated version of my ViewModelLocator
Thanks for any help concerning this matter. And thanks again for a great framework :)
App.xaml
```
<Application x:Class="MyApp.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:MyApp">
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/Resources/Colors.xaml" />
<ResourceDictionary Source="/Resources/Styles.xaml" />
</ResourceDictionary.MergedDictionaries>
<vm:ViewModelLocator x:Key="Locator" xmlns:vm="using:MyApp.ViewModel"/>
</ResourceDictionary>
</Application.Resources>
</Application>
```
ViewModelLocator.cs
```
namespace MyApp.ViewModel
{
/// <summary>
/// This class contains static references to all the view models in the
/// application and provides an entry point for the bindings.
/// </summary>
public class ViewModelLocator
{
/// <summary>
/// Initializes a new instance of the ViewModelLocator class.
/// </summary>
public ViewModelLocator()
{
ServiceLocator.SetLocatorProvider(() => SimpleIoc.Default);
////if (ViewModelBase.IsInDesignModeStatic)
////{
//// // Create design time view services and models
//// SimpleIoc.Default.Register<IDataService, DesignDataService>();
////}
////else
////{
//// // Create run time view services and models
//// SimpleIoc.Default.Register<IDataService, DataService>();
////}
var navigationService = this.CreateNavigationService();
SimpleIoc.Default.Register<LoginPageViewModel>();
SimpleIoc.Default.Register<LoginRegisterPageViewModel>();
........
........
SimpleIoc.Default.Register<StoresPageViewModel>();
SimpleIoc.Default.Register<INavigationService>(() => navigationService);
SimpleIoc.Default.Register<IEncryptService, EncryptService>();
SimpleIoc.Default.Register<ISettingsService, SettingsService>();
}
public MainViewModel Main
{
get
{
return ServiceLocator.Current.GetInstance<MainViewModel>();
}
}
public ConnectionsPageViewModel Connections
{
get
{
return ServiceLocator.Current.GetInstance<ConnectionsPageViewModel>();
}
}
public ConnectionDetailPageViewModel ConnectionDetails
{
get
{
return ServiceLocator.Current.GetInstance<ConnectionDetailPageViewModel>();
}
}
........
........
public StoresPageViewModel Stores
{
get
{
return ServiceLocator.Current.GetInstance<StoresPageViewModel>();
}
}
private INavigationService CreateNavigationService()
{
var navigationService = new NavigationService();
navigationService.Configure("ConnectionsPage", typeof(ConnectionsPage));
navigationService.Configure("ConnectionDetailsPage", typeof(ConnectionDetailsPage));
navigationService.Configure("BlockSimPage", typeof(BlockSimPage));
navigationService.Configure("MainPage", typeof(MainPage));
#if WINDOWS_PHONE_APP
navigationService.Configure("LoginRegisterPage", typeof(LoginRegisterPage));
navigationService.Configure("LoginPage", typeof(LoginPage));
navigationService.Configure("RegisterPage", typeof(RegisterPage));
navigationService.Configure("RegisterPage2", typeof(RegisterPage2));
navigationService.Configure("RegisterPage3", typeof(RegisterPage3));
navigationService.Configure("InvoiceLabelDetailsPage", typeof(InvoiceLabelDetailsPage));
navigationService.Configure("InvoiceChartPage", typeof(InvoicesChartPage));
navigationService.Configure("InvoiceDetails", typeof(InvoiceDetailsPage));
#endif
return navigationService;
}
public static void Cleanup()
{
// TODO Clear the ViewModels
}
}
}
```
EDIT1: After reading [this](https://mvvmlight.codeplex.com/discussions/547269) and changing the target platform the error goes away for x86 architecture. However I need to develop and test for ARM devices and the error still exists there.
I am getting the error
The name "ViewModelLocator" does not exist in the namespace "using:MyApp.ViewModel"
in the app.xaml file of a universal application. I am using v5.020 of mvvm light.
Browsing the web I have read solutions such as:
-Cleaning and rebuilding the project
-Placing the
<vm:ViewModelLocator x:Key="Locator" xmlns:vm="using:MyApp.ViewModel"/>
line inside a resource dictionary
-Leaving only the above line in the Application.resources
-Uninstalling and re-installing mvvm
I have tried the above with no success.
I would also like to note that the error is not encountered in the WindowsPhone8.1(winrt) project and the app runs fine. Only in the Windows 8.1 project does the error show up.
If this error is not resolved I won't be able to reference any of my ViewModels which is obviously a huge problem.
Below are my App.xaml file and an abbreviated version of my ViewModelLocator
Thanks for any help concerning this matter. And thanks again for a great framework :)
App.xaml
```
<Application x:Class="MyApp.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:MyApp">
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="/Resources/Colors.xaml" />
<ResourceDictionary Source="/Resources/Styles.xaml" />
</ResourceDictionary.MergedDictionaries>
<vm:ViewModelLocator x:Key="Locator" xmlns:vm="using:MyApp.ViewModel"/>
</ResourceDictionary>
</Application.Resources>
</Application>
```
ViewModelLocator.cs
```
namespace MyApp.ViewModel
{
/// <summary>
/// This class contains static references to all the view models in the
/// application and provides an entry point for the bindings.
/// </summary>
public class ViewModelLocator
{
/// <summary>
/// Initializes a new instance of the ViewModelLocator class.
/// </summary>
public ViewModelLocator()
{
ServiceLocator.SetLocatorProvider(() => SimpleIoc.Default);
////if (ViewModelBase.IsInDesignModeStatic)
////{
//// // Create design time view services and models
//// SimpleIoc.Default.Register<IDataService, DesignDataService>();
////}
////else
////{
//// // Create run time view services and models
//// SimpleIoc.Default.Register<IDataService, DataService>();
////}
var navigationService = this.CreateNavigationService();
SimpleIoc.Default.Register<LoginPageViewModel>();
SimpleIoc.Default.Register<LoginRegisterPageViewModel>();
........
........
SimpleIoc.Default.Register<StoresPageViewModel>();
SimpleIoc.Default.Register<INavigationService>(() => navigationService);
SimpleIoc.Default.Register<IEncryptService, EncryptService>();
SimpleIoc.Default.Register<ISettingsService, SettingsService>();
}
public MainViewModel Main
{
get
{
return ServiceLocator.Current.GetInstance<MainViewModel>();
}
}
public ConnectionsPageViewModel Connections
{
get
{
return ServiceLocator.Current.GetInstance<ConnectionsPageViewModel>();
}
}
public ConnectionDetailPageViewModel ConnectionDetails
{
get
{
return ServiceLocator.Current.GetInstance<ConnectionDetailPageViewModel>();
}
}
........
........
public StoresPageViewModel Stores
{
get
{
return ServiceLocator.Current.GetInstance<StoresPageViewModel>();
}
}
private INavigationService CreateNavigationService()
{
var navigationService = new NavigationService();
navigationService.Configure("ConnectionsPage", typeof(ConnectionsPage));
navigationService.Configure("ConnectionDetailsPage", typeof(ConnectionDetailsPage));
navigationService.Configure("BlockSimPage", typeof(BlockSimPage));
navigationService.Configure("MainPage", typeof(MainPage));
#if WINDOWS_PHONE_APP
navigationService.Configure("LoginRegisterPage", typeof(LoginRegisterPage));
navigationService.Configure("LoginPage", typeof(LoginPage));
navigationService.Configure("RegisterPage", typeof(RegisterPage));
navigationService.Configure("RegisterPage2", typeof(RegisterPage2));
navigationService.Configure("RegisterPage3", typeof(RegisterPage3));
navigationService.Configure("InvoiceLabelDetailsPage", typeof(InvoiceLabelDetailsPage));
navigationService.Configure("InvoiceChartPage", typeof(InvoicesChartPage));
navigationService.Configure("InvoiceDetails", typeof(InvoiceDetailsPage));
#endif
return navigationService;
}
public static void Cleanup()
{
// TODO Clear the ViewModels
}
}
}
```
EDIT1: After reading [this](https://mvvmlight.codeplex.com/discussions/547269) and changing the target platform the error goes away for x86 architecture. However I need to develop and test for ARM devices and the error still exists there.