user575219
user575219

Reputation: 2440

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

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

Upvotes: 13

Views: 39972

Answers (4)

mw509
mw509

Reputation: 2093

I just got faced with this issue and in my case, none of these solutions seemed to have worked for me.

In my .csproj file I had manually modified it to ensure that I do not have unneeded items. and in that attempt I ignored the fact that I was using a shared project that contained WPF items. and since I was calling the shared project into my project, I am expected to for the lack of better words host everything that comes in the shared project files including the windowbase, presentationcore and presentationframework. After thism there was the need to add in the <PropertyGroup> tag this;

<NeutralLanguage>en</NeutralLanguage>
<UseWPF>true</UseWPF>

After this, it all seemed to work just fine.

So perhaps, checking and ensuring that if you are using a shared project as in my case, you are in the calling project using all the right references as well.

Hope this helps someone.

Upvotes: 0

Rob Habraken
Rob Habraken

Reputation: 499

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.

Upvotes: 30

Ross
Ross

Reputation: 4568

In Visual Studio, go to Project menu > Add Reference > .NET tab, select WindowsBase, PresentationCore and PresentationFramework in the list and press OK. Then try again.

Upvotes: 11

Reed Copsey
Reed Copsey

Reputation: 564413

If you're trying to use WPF, you need to add a reference to the listed assemblies in your project references.

Open your project, and choose "Project->Add Reference...". Add the listed assemblies as references in order to use the WPF types.

Upvotes: 0

Related Questions