11

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

3
  • 1
    @H.B. Why -1? He is looking for a solution to his problem, not for an error explanation. May 30, 2012 at 16:25
  • 1
    thanks for all ur suggestions.
    – user575219
    May 30, 2012 at 16:28
  • 5
    I got the same error message in an ASPX project and it turned out to be because I had copied over an image into the project in Visual Studio which had set its build action as 'Page' while it should have been 'Resource'. Swapping it to 'Resource' fixed the error. This is not the same as user575219's stated problem but a search for that error message brings you to this question so I wanted to include this solution just-in-case.
    – dumbledad
    Aug 28, 2012 at 14:06

4 Answers 4

29

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.

1
  • Alternatively, you can change the Build Action of the file from 'Page' to 'None'. The compiler in this case will not look to compile/build the file. Reference : stackoverflow.com/questions/145752/…
    – Divakar
    Jan 27, 2023 at 10:50
10

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.

0
0

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.

0

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.