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

2

6

I'm create my WPF project in VS 2010. After I finished my work with functional GUI, I wanted to edit template of my controls in Blend 4. But when I open project in Blend, in DesignMode, he tell me


Invalid XAML


In Result window he wrote:


[ControlName] is not supported in a Windows Presentation Foundation (WPF) project


Where [ControlName] is list of default controls, which I have used in my project (such as Window, DockPanel, etc.)

What to do to avoid this issues and be able to edit WPF forms at DesignMode of Expression-Blend4?

EDIT:

Possible workaround.

After some comparasion of empty projects (*.csproj file), which was created by Blend and by Studio, I have find out that VisualStudio create it with next line:

<PropertyGroup>
  <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
  <Platform Condition=" '$(Platform)' == '' ">x86</Platform>
 ...

while Blend uses the following lines:

<PropertyGroup>
    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>

So, if you change x86 to AnyCPU, Blend will open project as expected.

Hanan answered 21/7, 2011 at 12:2 Comment(0)
K
11

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,

Koppel answered 18/8, 2011 at 22:19 Comment(3)
hm, very interesting. I look on the reference which I have already, there are exist PresentationCore, PresentationFramework, and WindowsBase, and other .NET assms., BUT there placement is [ProjectName]\AssemblyName, instead of C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\AssemblyName (they have ! sign in yellow triangle.) After I changed them, its all works fine.Hanan
Really strange behavior: in MS VS assemblies have the right path, when opens the same project in Blend - all .net references are rewritten.Hanan
All of my references are screwed up. :( Is there any easy to update the path without removing them all and re-adding them? Also does this happen every time you open your project in blend or do you only have to fix it once?Tepee
N
1

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.

Neutrophil answered 26/4, 2012 at 15:28 Comment(1)
wow, i've had this page open for a day and didn't realize that stukselbax had already edited and found the same solution a few hours ago....Neutrophil

© 2022 - 2024 — McMap. All rights reserved.