“clr 命名空间” URI 引用未包含在程序集中的命名空间
我试图在我的 XAML 中包含一些转换值的类。但是,当我编译时,我收到以下错误:
未定义的 CLR 命名空间。 “clr-namespace”URI 引用未包含在程序集中的命名空间“View.Summary.Converters”。(View\View)
以及它出错的 XAML:
xmlns:c="clr-namespace:View.Summary.Converters"
此外,这里是我的转换类/命名空间的概述:
namespace View.Summary.Converters
{
class CollapsedIfNegative : IValueConverter { }
class VisibleIfNegative : IValueConverter { }
class ErrorCodeToString : IValueConverter { }
}
我必须删除代码的核心内容,因为我正在从事的项目是高度机密的。
I'm trying to include in my XAML some classes which convert values. However, I'm getting the following error when I compile:
Undefined CLR namespace. The 'clr-namespace' URI refers to a namespace 'View.Summary.Converters' that is not included in the assembly.(View\View)
And the XAML it's erroring on:
xmlns:c="clr-namespace:View.Summary.Converters"
Also, here is the outline of my conversion classes/namespace:
namespace View.Summary.Converters
{
class CollapsedIfNegative : IValueConverter { }
class VisibleIfNegative : IValueConverter { }
class ErrorCodeToString : IValueConverter { }
}
I had to remove the guts of the code because the project I am working on is highly confidential.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(10)
重建解决方案,错误就会消失。
rebuild the solution and the error will go away.
我刚刚通过将目标从 x64 更改为 x86 解决了这个问题。
显然 Visual Studio 是 32 位进程,它无法加载 64 位程序集,如果您的程序集面向 x64 平台并且您添加一些自定义控件,则 Visual Studio 无法加载它并抛出此消息。
I just solved this by changing the target from x64 to x86.
Apparently Visual Studio is 32bit process and it's unable to load 64bit assemblies, and if your assembly is targeting x64 platform and you adding some custom control visual studio is unable to load it and throws this message.
如果引用外部项目,则必须指定项目引用中显示的程序集:
If you reference to an external project, you must specify the assembly as it appears in your project's references:
我知道出了什么问题了。尽管 Visual Studio 将其显示为第一个错误,但我的编码确实存在其他错误,导致转换器无法组装。因此,当 VS 去找该程序集时,它不在那里。
I figured out what was wrong. Although visual studio showed this as the first error, there were indeed other errors with my coding which prevented the converters from being assembled. Thus, when VS went to find the assembly, it was not there.
vs2008设计器的一些问题
这样做:
现在不会有任何错误。
some problem with vs2008 designer
do this:
now there wont be any errors.
我能够重现您的问题:
我在 .NET Framework 4.0 中创建了一个简单的 WF。重命名了 xaml 文件。作为重命名 xaml 文件的一部分,您必须在调用 WorkflowInvoker 对象上的 Invoke 时手动重命名工作流运行时名称。我构建该项目。我收到错误“‘clr-namespace’ URI 引用了未包含在程序集中的命名空间‘System’。”
我是如何修复它的:
我打开项目属性页面。由于某种原因,目标框架从.NET Framework 4.0切换到4.0客户端版本。因此,我选择了.NET 4.0并重建了项目。错误不再存在。
I was able to reproduce your issue:
I created a simple WF in .NET Framework 4.0. Renamed the xaml file. As part of renaming the xaml file you have to manually rename the workflow runtime name when calling the Invoke on the WorkflowInvoker object. I build the project. I got the error "The 'clr-namespace' URI refers to a namespace 'System' that is not included in the assembly."
How I fixed it:
I open the project property page. For some reason, the target framework was switch from .NET framework 4.0 to 4.0 client version. So, I selected .NET 4.0 and rebuilt the project. The error is not there anymore.
检查您的构建配置是否已在当前(活动)构建配置中选择用于构建的项目。
我在摆弄构建架构(从 x86 到 x64)之后遇到了这个问题,并且主要的 wpf 项目已被取消选择。
Check that your build configuration has the Project selected for build in your current (Active) build configuration.
I just had this problem after fiddling with the Build architecture (from x86 to x64) and the main wpf project had been de-selected.
我在 C# WPF 项目中遇到了这个问题。
它似乎是在您最后一次尝试关闭项目时生成的,在项目期间出现任何类型的错误,甚至在 XAML 中出现问题的相关命名空间中也没有。
解决方案是修复所有 .CS 文件(或排除有问题的 XAML/CS 文件)以获得正在运行的版本重新构建并运行。
我花了近 3 个小时才发现设计器运行的调试版本肯定有问题。这就是为什么在许多情况下人们通过重建项目解决了这个问题,但如果项目中存在代码错误,则问题将无法自行解决,因为重建无法完成并且不会替换设计器支持的版本。
希望这有帮助!
I have ran into this issue on a C# WPF project.
It seems to be generated when you closed the project with last attempt with Errors of any kind during your project not even in the relevant Namespace in issue in XAML.
The solution to this is to fix all .CS files (Or exclude the problematic XAML/CS files) to get a running version Rebuild and run.
It took me close to 3 hours to figure that the Debug version that the designer seems to be running on must be faulty. This is why in many cases people resolved this with Rebuild project, but in cases that you have existing code errors in project the issue will not resolve it self since the Rebuild fails to complete and does not replace the designer supported version.
hoped this helps!
Visual Studio 不断恢复到奇怪的程序集文件路径。只需删除它所引用的实际参考文件,然后将其添加到项目中即可
Visual Studio keeps reverting back to the odd assembly file paths. Just delete the actual reference file it's referring to and then add it to the project
我有同样的错误。但显然,这只是因为我试图构建的解决方案的路径。
我的路径/目录/文件夹名称包含一些空格。
I had the same error. But apparently, it was just because of the path of the solution that I was trying to build.
My path/directory/folder name contains some spaces.