我刚刚安装了 Visual Studio 2010 并将我的 Visual Studio 2008 WPF 项目之一转换为测试。虽然项目构建和运行正常,但 VS 设计器无法处理我给出的错误的自定义命名空间映射:
Assembly must be specified for XAML files that are not part of a project. Reopen this XAML file after adding it to a project, close this file and reopen it using the project it is associated with, or modify the clr-namespace to include the name of the assembly.
有问题的命名空间是项目的一部分。 Visual Studio 2008 的 XAML 没有问题。所以我创建了一个新的空白 WPF 项目,名为
Test1
命名空间为 Test1
.然后我编辑了生成的 MainWindow.xaml 来为 local
添加单个映射。 :<Window x:Class="Test1.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:Test1"
Title="MainWindow" Height="350" Width="525">
<Grid />
</Window>
这给出了相同的错误。而且,令人惊讶的是,Google 没有报告该错误的结果!我尝试了一些变体,例如附加
;assembly=
或 ;assembly=Test1
,但这没有帮助。谁能发现我做错了什么?如果没有,我将非常感谢有关为什么这可能会失败的建议。
编辑:根据评论,事实证明这仅在从网络共享打开项目时发生。如果在本地驱动器上打开项目,则不会发生这种情况。但是,我希望能够在网络共享上打开它,因此我将问题悬而未决。
最佳答案
尼尔艾伦是对的。将文件夹映射为驱动器,一切都会好起来的。
如何映射:
http://www.online-tech-tips.com/computer-tips/how-to-map-a-drive-in-windows/
关于wpf - 自定义 WPF 命名空间映射在 Visual Studio 2010 中失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2926378/