You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

WPF添加Material Design资源字典出现XDG0010加载错误求助

WPF集成Material Design时XDG0010错误解决方法

已安装MaterialDesignThemes和MaterialDesignColors NuGet包,在App.xaml中添加以下资源字典代码后,4行均报XDG0010错误,提示无法找到对应的程序集:

<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
    <ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Light.xaml" />
    <ResourceDictionary Source="pack://application:,,,/MaterialDesignThemes.Wpf;component/Themes/MaterialDesignTheme.Defaults.xaml" />
    <ResourceDictionary Source="pack://application:,,,/MaterialDesignColors;component/Themes/Recommended/Primary/MaterialDesignColor.DeepPurple.xaml" />
    <ResourceDictionary Source="pack://application:,,,/MaterialDesignColors;component/Themes/Recommended/Accent/MaterialDesignColor.Lime.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>

典型错误提示:

Error XDG0010 Could not load file or assembly 'MaterialDesignThemes.Wpf, Culture=neutral' or one of its dependencies. The system cannot find the file specified.

以下是针对性的解决步骤:

  • 确认NuGet包安装到目标项目
    右键报错项目 → 管理NuGet程序包,检查MaterialDesignThemes和MaterialDesignColors是否在“已安装”列表中。多项目解决方案里,别把包装到了其他项目而非当前报错的项目。

  • 清理重建项目

    1. 顶部菜单选「项目」→「清理解决方案」
    2. 手动删除项目目录下的bin和obj文件夹
    3. 重新生成解决方案,等待依赖项重新编译
  • 检查程序集引用
    右键项目 →「引用」,查看是否存在MaterialDesignThemes.Wpf和MaterialDesignColors的引用。如果没有,先卸载这两个NuGet包,再重新安装,安装过程会自动添加正确的引用。

  • 验证pack URI路径
    核对资源字典的Source路径拼写,特别是程序集名称和XAML文件位置。不同版本的Material Design包可能调整了文件结构,可右键NuGet包→「打开文件夹」,导航到Themes目录确认实际路径。

  • 匹配目标框架版本
    确认项目的目标.NET框架版本与Material Design包兼容。比如新版包可能要求.NET 6及以上,若项目用的是.NET Framework 4.7.2,需安装对应兼容的旧版本包。

  • 重置VS组件缓存
    若以上方法无效,关闭Visual Studio,删除%LocalAppData%\Microsoft\VisualStudio\<你的VS版本号>\ComponentModelCache目录下的文件,重新打开VS加载项目试试。

内容的提问来源于stack exchange,提问作者Man In Black

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.25 12:15:22