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

winformswpf

I am using WPF in a Windows Forms Application with C#.

Follow up of the question.
Adding a collection of solid,dashed lines pen to a combo box

Error:

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

Please suggest

Best Answer

It's an old question, but for the purpose of keeping this resource a valid one: it is true that you can add references likes this, as Ross and Reed suggest, but I do not believe that this is the actual solution, you're just fixing the effect of an issue, not the cause.

Exactly like @dumbledad says, I got the exact same error message when I included files in my project that got marked as a 'Page' in the .csproj file, resulting in Visual Studio wanting to compile this resource. However, this being an uncompilable resource (in my case it was a XAML file, could be an image as well) Visual Studio asks for extra assemblies. In this case, do not just add them, but go into your .csproj file and make the following adjustment:

Search for the opening node '<Page' and verify that each instance of it actually is a page that needs to treated with the corresponding action. In my case, as you can see, a resource is marked as a Page, which VS tries to Compile:

<ItemGroup>
  <Page Include="sitecore\shell\ClientBin\EmptySplashScreen.xaml">
    <Generator>MSBuild:Compile</Generator>
  </Page>
</ItemGroup>

Just remove this section (or Page-node) and put the file back into the .csproj file as a regular content include. You have to do this manually, as including the file from within VS regenerates the same faulty Page-node. So I've put it back into the project file like this:

<Content Include="sitecore\shell\ClientBin\EmptySplashScreen.xaml" />

Et voila, your project will build again and the error message disappears without having to add those extra assembly references.

Related Topic