名字<...>命名空间中不存在 clr-namespace <...> [英] the name <...> does not exist in the namespace clr-namespace <...>

查看:23
本文介绍了名字<...>命名空间中不存在 clr-namespace <...>的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个小型 WPF 应用程序,它过去编译得很好,但现在不行了.我真的不能说它在什么时候停止了构建.前一天还好好的,第二天就不行了.

I have a small WPF application which used to compile just fine but is not anymore. I can't really say at which point it stopped building. It just worked fine one day, and the next it's not.

这是项目结构:

除了标准的 .net dll 之外,没有其他项目或外部参考.

There is no other projects or external references other than standard .net dlls.

这是问题所在的用户控件:

Here's the user control where the problem originated:

<UserControl x:Class="TimeRecorder.HistoryUserControl"
         xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
         xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
         xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
         xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
         xmlns:local="clr-namespace:TimeRecorder.ViewModel"
         xmlns:framework="clr-namespace:TimeRecorder.Framework"
         mc:Ignorable="d" Height="Auto" Width="Auto" Padding="5">
<UserControl.Resources>
    <local:HistoryViewModel x:Key="ViewModel"/>
    <framework:BoolToColorConverter x:Key="ColorConverter"/>
</UserControl.Resources>
<StackPanel DataContext="{StaticResource ViewModel}">

这是我得到的错误:

请注意,这不仅仅是屏幕截图中的一个文件,而是我在此项目的所有用户控件/窗口文件中以类似方式在 xaml 中添加的所有引用.

所以文件在那里,文件中的命名空间是正确的,xaml 文件中的命名空间/类名(据我所知)是正确的.当我输入 xaml 时,我得到了智能感知,所以它发现文件正常,但在编译时却没有.

So the file is there, the namespace in the file is correct, the namespace/class name in the xaml file is (to my understanding) correct. I get intellisense when I type in the xaml so it finds the files ok then but not when it compiles.

其他帖子中最常见的解决方案是 .net 框架版本.我的主项目和测试项目目前都设置为 .Net Framework 4.完整版不是客户资料.

The most common solution for this in other posts has been the .net framework version. It is currently set to .Net Framework 4 for both my main and test project. The full version not the client profile.

我认为我搞砸了:在配置管理器中,两个项目的平台都设置为任意 CPU,但在尝试解决此问题时,我注意到主项目设置为 x86,而测试项目设置为任意 CPU.所以我在配置管理器中为主项目手动添加了Any CPU.但是,老实说,我不知道我是否正确地这样做了,或者即使我应该这样做.所以作为一个额外的问题,有没有办法可以将配置管理器重置为其默认状态?这对主要问题有什么要说的吗?我不知道主项目是否总是设置为 x86,或者我是否以某种方式将其更改为 x86,然后它就坏了.如前所述,这个项目在一段时间内编译得很好.

Here's what I think I messed up: In the configuration manager, both projects have their Platform set to Any CPU, but at one point when trying to solve this I noticed that the main project was set to x86 and the test project was set to Any CPU. So I added Any CPU manually for the main project in the configuration manager. However I honestly don't know if I did this correctly or even if I should do it. So as an additional question, is there a way I can reset the configuration manager to its default state? Will this have anything to say for the main problem? I don't know if the main project was always set to x86 or not or if I somehow changed it to x86 and then it broke. As mentioned this project was compiling just fine for a while.

推荐答案

每次遇到这种情况我都只是重新启动了 Visual Studio,重新构建了解决方案,它工作得很好.. 说不出为什么

Every time it happend to me i just restarted visual studio, re-built the solution and it worked just fine.. can't say why

这篇关于名字&lt;...&gt;命名空间中不存在 clr-namespace &lt;...&gt;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆