Trouble when trying to open WPF project in Expression-Blend 4, which was created in Visual Studio 2010

吃可爱长大的小学妹 提交于 2019-12-04 06:51:37

I have only seen this error message once before. After comparing a new solution file with the one that wouldn't load I discovered that Blend requires the AnyCPU platform/configuration to be defined.

If that does not work, ensure that you have all the required assemblies referenced for a WPF project: PresentationCore, PresentationFramework, and WindowsBase.

HTH,

After a wasted day tracking this down I found this:

Open up the .proj file in a text editor and take a look at the very top of the file, there will be a list of PropertyGroup sections in the XML. Take a look at the first one, if it says x86 or anything other than AnyCPU, change it to say AnyCPU and save it.

<?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)' == '' ">x86</Platform>

should be:

<?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>

Why? I'm not 100% sure, but it appears that Visual Studio doesn't modify this part of the project file (if it does, I don't know when exactly), since you choose your build configuration in the UI and it uses that instead. However, since Expression Blend (using version 4) doesn't allow you to choose your build configuration it just picks the top one. The result is that you get "Invalid XAML" and all of your references have bangs (!) next to them.

In my opinion (and knowing my analysis could be flawed) this is a deficiency in Expression Blend. Not only should it be able to use any build configuration that studio can, you should also be able to select it.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!