开发wpf时我们经常遇到一个xaml文件在设计时显示解析错误(比如在:VS或者Blend)而编译正常运行正常。
原因是:xaml的在Debug版本下必须为anyCPU。
解决办法:
1.打开工程文件xxx.csproj,
2.找到含有 <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>的PropertyGroup节点
3.将此PropertyGroup节点中的<Platform Condition=" '$(Platform)' == '' ">改为anyCPU。
示例:
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">anyCPU</Platform>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">anyCPU</Platform>