The tag 'ViewModelLocator' does not exist in the XML namespace namespace: XXX

I have tried many other solutions without any success. I have a class called ViewModelLocator which is in my portable class library. It has a property in it called ViewModels , which is of type Dictionay<K, V>

Then I have a Windows Phone 8 project that references a portable class library. I added the following to the WP8 app.xaml:

 <Application x:Class="Kaizen.WP8.Test.App" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone" xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone" xmlns:test="clr-namespace:Foo.Core.Portable.ViewModel;assembly=Foo.Core.Portable"> <Application.Resources> <test:ViewModelLocator x:Key="ViewModelLocator"> <test:ViewModelLocator.ViewModels> <test:SampleViewModel x:Key="sampleVM"/> </test:ViewModelLocator.ViewModels> </test:ViewModelLocator> </Application.Resources> </Application> 

When I click F12 on tags, it goes to the correct class and / or property in my pcl. Which indicates that VS knows about objects, but when I try to build, I get the following error:

The tag 'ViewModelLocator' does not exist in the XML namespace. 'CLR names: Foo.Core.Portable.ViewModel; assembly = Foo.Core.Portable '

The tag 'SampleViewModel' does not exist in the XML namespace. 'CLR names: Foo.Core.Portable.ViewModel; assembly = Foo.Core.Portable '

Can someone provide some help?

[Update] I am referring to the pcl version of mvvm light in my pcl project. This is what the ViewModelLocator class looks like:

 public class ViewModelLocator { public dynamic this[string viewModelName] { get { if (this.ViewModels.ContainsKey(viewModelName)) { return this.ViewModels[viewModelName]; } else { return null; } } } public Dictionary<string, ViewModelBase> ViewModels { get; set; } public ViewModelLocator() { this.ViewModels = new Dictionary<string, ViewModelBase>(); } } 

My WP8 project also uses mvvm light pcl builds. I noticed that if I use the ViewModelBase class as a dictionary value, this is when I get errors. Is this like a problem using mvvm light pcl between two projects ?! [Update]

Thank you very much in advance! Yours faithfully,

+4
source share
3 answers

Well, thatโ€™s why Iโ€™m not quite sure what I did wrong on my first attempt, but I recreated the solution and performed more or less the same steps, and again I didnโ€™t get the error! o_o

+2
source

I had this problem with a .Net 4.5 project. The solution for me was to switch to .Net 4.0, ignore warnings, and return to .Net 4.5. Then the problem disappeared.

I don't know if this is possible for others, but it worked for me.

Sincerely.

+4
source

I know this is a little late, but I had the same problem with the WPF Desktop app and the control library. The main default platform for the library was .Net 4, but the Desktop application immediately after creation in Visual Studio was created by default with the .Net 4 client profile. I changed the "Desktop Application" with the .Net 4 client profile to .Net 4 and it worked.

0
source

Source: https://habr.com/ru/post/1497283/


All Articles