大网数据广告活动
Web服务器与PHP

Error in the XAML or WPF designer view

· 52CE 我爱测

This article resolves an error (Cannot find resource named) when you open an XAML or WPF file in Design view in Visual Studio 2017.

This article helps you resolve an error (Cannot find resource) that occurs when you open an Extensible Application Markup Language (XAML) or Windows Presentation Foundation (WPF) file in Design view in Visual Studio 2017.

Original product version:   Visual Studio 2017
Original KB number:   4057582

Symptoms

When you open an XAML or WPF file in Design view in Microsoft Visual Studio 2017, you receive the following error message:

Cannot find resource named <Resource name>. Resource names are case sensitive.

Note:

  • The static resource keys of the UI components that display error messages in Design view can be found in the application resource dictionary.
  • This issue doesn't occur at run time.
  • This issue doesn't occur if project code is disabled.

Cause

This problem occurs because of the interaction between the WPF runtime and a designer performance optimization that was introduced in Visual Studio 2015.

If the performance optimization is enabled, the designer waits until resources are used before it instantiates the values of the resources instead of creating all resources during designer load. This can cause a small reduction in designer load time. However, this process doesn't work well if the referenced projects are unloaded.

Resolution

To fix this problem, follow these steps:

  1. Install the latest Visual Studio 2017 update (must be later than version 15.5).

  2. Set the VSXAML_DISABLE_ON_DEMAND_RESOURCE_VALUES environment variable to 1. To do this, run the following command at a command prompt:

    setx VSXAML_DISABLE_ON_DEMAND_RESOURCE_VALUES 1
    

Source: Microsoft Learn / IT Pro troubleshooting by Microsoft and contributors. Documentation licensed CC BY 4.0. Code samples are covered by the MIT License. Converted from Markdown, with links normalized and embedded media omitted.

资料来源与适用范围

资料来源
Microsoft Learn / IT Pro troubleshooting
适用范围
See source applicability · Source date 04/20/2020
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY 4.0 (documentation), MIT (code samples)

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。