C# 名称'';命名空间中不存在'';

C# 名称'';命名空间中不存在'';,c#,wpf,xaml,mvvm,C#,Wpf,Xaml,Mvvm,MVVM新手,我遇到了令人沮丧的错误: 名称空间中不存在名称“MainWindowViewModel” “clr命名空间:数据\版本\ 3.ViewModels.MainWindowViewModel” 但是这个项目建成了,并且运行了,我只是看不到窗口,无法对设计进行修改,因为它建议存在错误 最突出的XAML是: <Window x:Class="Data_version_3.MainWindow" WindowStartupLocation="CenterScreen

MVVM新手,我遇到了令人沮丧的错误:

名称空间中不存在名称“MainWindowViewModel” “clr命名空间:数据\版本\ 3.ViewModels.MainWindowViewModel”

但是这个项目建成了,并且运行了,我只是看不到窗口,无法对设计进行修改,因为它建议存在错误

最突出的XAML是:

<Window x:Class="Data_version_3.MainWindow"  
        WindowStartupLocation="CenterScreen"     
        xmlns:dx="http://schemas.devexpress.com/winfx/2008/xaml/core" 
        dx:ThemeManager.Theme="Office2010Black" 
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"       
        xmlns:vm="clr-namespace:Data_version_3.ViewModels.MainWindowViewModel"
        mc:Ignorable="d"       
        Title="GG Data import tool" 
        WindowState ="Maximized"
        Icon="./Images/GG.ico"
        KeyDown="OnButtonKeyDown">
    <Window.DataContext>
        <vm:MainWindowViewModel/>
    </Window.DataContext>
我看过很多关于这方面的帖子,包括:

但不幸的是,这并没有奏效。我尝试过清洁和重建,关闭和打开等所有它喜欢的,但没有任何效果,所以我猜这是我错过的东西。谢谢你的帮助


编辑-为了以防万一,我使用的是VS 2015

在我的案例中,这个问题是项目和解决方案中有空格,而代码中的名称空间有下划线。重新命名项目和解决方案,使其与代码匹配,经过清理和构建后,解决了问题。

Hm。。。可能是名称空间中的下划线造成的。试着不用。这只是猜测。这两个类都在同一个程序集/项目中吗?@Lennart MainWindow类和MainWindowViewModel?是的,主窗口在代码隐藏中,但是,这会导致问题吗?所以这是WPF设计器窗口中的IntelliSense错误?不幸的是,这种情况有时会发生。实际上有一个名为
XDesProc.exe
的后台进程,它不断编译您的项目并将数据反馈回VisualStudio。您有几个选项:1)忽略它,2)全部重建,3)重新启动Visual Studio(或杀死
XDesProc.exe
)。如果最后一个选项不起作用,则必须返回1)。为什么视图模型继承自命令?您也尝试过在不引用您的VM的情况下构建它。然后在构建之后添加它?
namespace Data_version_3.ViewModels.MainWindowViewModel
{
    public class MainWindowViewModel:RelayCommand
    {
        Web w = null;
        public Excel ex = null;
        public Report rp = null;
        public Helpers he = null;
        SQLThings.Data da = null;
        public Logging lg = new Logging();

        public MainWindowViewModel()
        {
            he = new Helpers(this);
            w = new Web(this);
            ex = new Excel(this);
            da = new SQLThings.Data(this);
            rp = new Report(this);
        }