Click here to Skip to main content
15,217,212 members
Rate this:
Please Sign up or sign in to vote.
See more:
Hello Friend,

I'm facing a problem when creating a new c# WPF project in Microsoft Visual Studio 2010.
The following is my coding is xaml,
<Window x:Class="OfflineCartHMI.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="MainWindow" Height="350" Width="525">
    <Grid>
        
    </Grid>
</Window>

The following is the C# code in MainWindow.xaml.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace OfflineCartHMI
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
        }
    }
}


Everything looks fine but it show the following error:
The type 'Window' was not found. Verify that you are not missing an assembly reference and that all referenced assemblies have been built.

The type 'Grid' was not found. Verify that you are not missing an assembly reference and that all referenced assemblies have been built.	

Anyone has any ideas to solve this problem?
Posted
Updated 23-Jul-15 15:37pm
v2
Comments
Sergey Alexandrovich Kryukov 23-Jul-15 22:02pm
   
Well, something is screwed up, but you did not provide the information to see what. But maybe this is not really needed. If you create a brand-new project of any of the predefined project templates, it should build immediately. But a template or something else could be broken. It does not matter what it is exactly, you need to have a consistent product. But even if this is the case, you can always make the project build manually, through understanding how it works. Believe me, minimal WPF project is not so hard to understand and fix.
—SA
ChongMing 24-Jul-15 1:05am
   
Yes, this is a brand new WPF project, just click File -> New -> Project, select WPF templates under C#. Click OK button, then this error immediately show up and design faced loading problem.

May be my project templates are broken or what. I create another VB WPF project, i saw the same error...
   
Then something in Visual Studio or even .NET is broken. You need to start reinstalling it.
—SA
Wendelius 24-Jul-15 0:18am
   
In the references do you have a reference to PresentationFramework?
ChongMing 24-Jul-15 0:56am
   
Yes, here is PresentationFramework in my references.
Wendelius 24-Jul-15 1:14am
   
And if you double click on the error where does it take you?
ChongMing 24-Jul-15 2:10am
   
It bring me to MainWindow.xaml and the window keyword in

window x:class="OfflineCartHMI.MainWindow" <="" prev=""

is highlighed.
Wendelius 24-Jul-15 2:12am
   
In your question you don't have a <prev> tag but I take it that by prev you mean the original post.

If that's the case, I'd try to run re-install...
ChongMing 24-Jul-15 2:18am
   
I believe it is the same issue with this:

https://social.msdn.microsoft.com/Forums/expression/en-US/7b160f43-faa2-42e7-af46-27baf3768cfb/missing-assembly-references-for-window

1 solution

Rate this:
Please Sign up or sign in to vote.

Solution 1

Please see my comment to the question.

You can always fix the errors you reported if you simply make sure you added the following assemblies to references: System (System.Code also recommended), PresentationCore, PresentationFramework and WindowBase. The referenced are added from GAC (the tab ".NET" of the "Add Reference" window). That's it. Isn't that simple?

If your VS installation or some of the templates are broken, try to reinstall everything. If you accidentally lost some references or inherited some inconsistent project, fix it or build from scratch and add you source files. And so on…

—SA
   
Comments
ChongMing 24-Jul-15 1:00am
   
Thanks SA, I have all the references that you mentioned:System (System.Code also recommended), PresentationCore, PresentationFramework and WindowBase.

I had tried to create another VB WPF project, i faced the same error, may be I'm needed to re-install my visual studio.
   
Say, "Window" is from "PresentationFramework"; and its type System.Windows.Window. You cannot have it and get this error. Anyway, I don't have your environment and all code. Something is broken.
—SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100