1

As the titel say i have the problem that Xaml don´t now my clr namespace, I read the other posts and tried their solution without any success, I rebuild, Start as Admin tried the build conviguration etc.

My Project looks so:

enter image description here

My XAML:

<Controls:MetroWindow  x:Class="AdminControlCenter.View.MainView"
    xmlns:Controls="clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:resx="clr-namespace:AdminControlCenter.Properties;assembly=AdminControlCenter"
    xmlns:local="clr-namespace:AdminControlCenter;assembly=AdminControlCenter"
    xmlns:vm="clr-namespace:AdminControlCenter.ViewModel;assembly=AdminControlCenter"
    Title="MainWindow" Height="400" Width="600">


<Grid  VerticalAlignment="Stretch" HorizontalAlignment="Stretch" Background="White">
    <Grid.DataContext>
        <vm:ImageViewModel x:Name="imageViewModel"/>
    </Grid.DataContext>

And the Error:

enter image description here

And the ImageViedModel:

namespace AdminControlCenter.ViewModel
{
public class ImageViewModel : ViewModel
{
    public ImageViewModel()
    {

    }
.....

The classes are public and show up at the autoformat, when I type for example "vm:" It also go to the Definition of the Class by using F12.

When I use some MVVM tutorial tests, they are working. But when I try in my Project all ViewModels are not found.

Why doesen´t found the XAMl my ViewModels ?

Edit: I tried every variation of the assemblies with and without, I also try to delete the suo and try every build configuration, and I restart VS as Admin etc. I also make a new Project with another name and rewrite all classes (Not Copied them) also without any success

FoldFence
  • 2,674
  • 4
  • 33
  • 57

1 Answers1

1

I get this error too sometimes, but I can build/deploy anyway.. I think it's a Visual Studio bug.. Are you able to deploy your solution? Maybe you can try to copy Model and ViewModel's content somewhere else , delete from the project these two files and recreate the files again.. Or.. Do you know how to use the ViewModelLocator class? Since I started use it I never seen that issue again

See here for details about ViewModelLocator: link

Community
  • 1
  • 1
Mirko Bellabarba
  • 562
  • 2
  • 13
  • The Programm compiles sometimes the othertimes I get this error for some reasons idk... http://stackoverflow.com/questions/20563691/c-sharp-debug-cannot-start-debugging-because-the-debug-target-is-missing i tried to delete the classes and move them but with no success and the error was gone for at least 30minutes but then it comes this error http://stackoverflow.com/questions/3087390/the-source-file-is-different-from-when-the-module-was-built and after a restart I get status quoe again – FoldFence Mar 04 '16 at 12:56
  • Try with ViewModelLocator, work like a charm for me! – Mirko Bellabarba Mar 05 '16 at 14:31