积极答复者
求助,项目生成时突然出现错误:XDG0008 命名空间“XXXXX”中不存在“XXXX”

问题
-
我写了一个自定义的ListBox类,代码如下:
public class ImageListBox : ListBox { public static readonly DependencyProperty ImageWidthProperty = DependencyProperty.Register("ImageWidth", typeof(double), typeof(ImageListBox), new PropertyMetadata(0.0, new PropertyChangedCallback(OnImageWidthChanged))); public double ImageWidth { get { return (double)GetValue(ImageWidthProperty); } set { SetValue(ImageWidthProperty, value); } } static void OnImageWidthChanged(object sender, DependencyPropertyChangedEventArgs args) { } public double ImageClipRadius { get { return ImageWidth / 2; } } public Point ImageClipCenter { get { return new Point(ImageWidth / 2, ImageWidth / 2); } } }
之前没有问题,生成项目的时候没有报错,程序也运行得很好。今天无缘无故发现编译的时候报这个错误:
但是虽然有报错,程序仍然能够生成成功以及能够运行。只不过XAML设计器里面窗体无法显示:
代码中出错的地方是:
正好就是那个ImageListBox。
这要怎么找原因和解决问题?
da jia hao!
答案
-
你好,
这个是编译器的问题,有时候在Debug 可能生成的DLL, 不被Xaml 识别, 问题解决后,你还可以改回Debug 模式就可以了。
Best regards,
Zhanglong
MSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.- 已标记为答案 liubin 2018年6月14日 8:22
全部回复
-
-
你好,
Build 的时候在output 窗口有错误吗?或者你的这个解决方案里面是不是有多个项目?
Best regards,
Zhanglong
MSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.- 已编辑 Zhanglong WuMicrosoft contingent staff 2018年6月12日 1:59
-
你好,
重建一个项目,然后把这段代码COPY到新的项目中,在看看有没有这个错误。
Best regards,
Zhanglong
MSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com. -
可能要检查一下代码,判断Design Mode
bool designTime = System.ComponentModel.DesignerProperties.GetIsInDesignMode( new DependencyObject());
https://www.codeproject.com/tips/61858/detect-design-time-mode-in-wpf
https://stackoverflow.com/questions/834283/is-there-a-way-to-check-if-wpf-is-currently-executing-in-design-mode-or-not
专注于.NET ERP/CRM开发框架,C/S架构,SQL Server + ORM(LLBL Gen Pro) + Infragistics WinForms
- 已编辑 Shuanghua Li 2018年6月14日 0:27
-
你好,
试试下面的方法:
1. 右击你的解决方案(Solution) -> 属性 -> Configuration Properties -> 从Debug 模式转到Release模式
2. Re-Build 你的解决方案。
Best regards,
Zhanglong
MSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com. -
你好,
这个是编译器的问题,有时候在Debug 可能生成的DLL, 不被Xaml 识别, 问题解决后,你还可以改回Debug 模式就可以了。
Best regards,
Zhanglong
MSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.- 已标记为答案 liubin 2018年6月14日 8:22