Project file must include the .NET Framework assembly ‘WindowsBase, PresentationCore, PresentationFramework’ in the reference list

Posted: 6th September 2010 in Visual Studio, XAML

Problem: After including some XAML files from a Visio document in a Visual Studio solution you’re unable to build the solution and receive the error:

Project file must include the .NET Framework assembly ‘WindowsBase, PresentationCore, PresentationFramework’ in the reference list 

Cause: When you include XAML files in a solution it assumes you want to compile the XAML resources and subsequently throws the above exception because it can’t find the required WPF assemblies.

In this case, I was only wanting the add the files as content to the solution to keep them under source control.

Solution: To solve this, firstly, unload the project from the solution by right clicking the project and choosing unload project. This can be seen in figure 1Figure 1.

Then, right click the project and choose edit project. This will open the XML for the project file. Now, find the XAML entries.

  1. <Content Include="Processes\Flowcharts\Change\xaml_2.xaml">
  2.       <Generator>MSBuild:Compile</Generator>
  3.       <SubType>Designer</SubType>
  4.     </Content>

Change this to read.

  1. <Content Include="Processes\Flowcharts\Change\xaml_2.xaml"/>

The project should now build.

Advertisements
Comments
  1. Thanks for posting this solution. I had a similar issue after I pasted some images from a WPF project into another ASP.NET MVC web and it carried across the WPF/Silverlight ‘page’ build action across, switching this back to ‘content’ removed the reference error.

  2. mumu says:

    Even easier than this is to select the XAML file in the Solution Explorer, and then in the Properties panel set BuildAction to ‘None’ and Custom Tool to an empty string.

    No need to unload the project and manually edit the file.

  3. JJ says:

    didn’t solve anything for me, there was no ”
    MSBuild:Compile
    Designer
    ” to begin wih

  4. Jeremy says:

    Thank you! You are a life saver! I added mediaelement.js to my project to play with some audio/video stuff and didn’t realize it came packaged with a xaml in the src directory. Took me a long time to figure this one out.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s