0

MainWindow.xaml:

<Window x:Class="View.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="Nothing" Height="600" Width="800" MinHeight="450" MinWidth="400"/>

Mainwindow.xaml.cs:

using System.Windows;
    namespace View
    {
        public partial class MainWindow : Window
        {
            public MainWindow()
            {
                InitializeComponent();
            }
        }
    }

It throws an error. The namespaces are correct, i tried rebuilding the solution, cleaning the solution, the xaml build action is set to Page. The same code worked before, then i changed the View namespace to View2 in both files, it started throwing errors, so i changed it back, but the same error appears. Is there anybody who solved this bug somehow (without creating a new solution and copying the files, which would obviously solve the problem)?

Esad
  • 107
  • 1
  • 8
  • Which filed do you mean by "both files"? Did you change the designer-generated file as well or just the two files you put in your question? – D Stanley Mar 23 '17 at 16:06
  • I changed it in MainWindow.xaml and in MainWindow.xaml.cs. Where else should i change it? – Esad Mar 23 '17 at 16:08
  • Are you saying that it throws an exception, or that you're getting a compiler error? – 15ee8f99-57ff-4f92-890c-b56153 Mar 23 '17 at 16:10
  • Build error: The name InitializeComponent does not exist in the current context – Esad Mar 23 '17 at 16:12
  • @Esad Have you tried closing and reopening Visual Studio? – I.B Mar 23 '17 at 16:13
  • @CNuts Yes, many times. I'm stuck with this build error for 3 hours now. I guess I'll have to make a new solution and copy the code each time I change a namespace. – Esad Mar 23 '17 at 16:19
  • 1
    You may try to copy the contents of the MainWindow.xaml* files, remove them from the project, create a new window with the same name and paste in your code. – mm8 Mar 23 '17 at 16:40
  • I created a new window, and it immediately gave the "InitializeComponent does not exist in the current context build" error. – Esad Mar 23 '17 at 18:07
  • http://stackoverflow.com/questions/6925584/the-name-initializecomponent-does-not-exist-in-the-current-context – l33t Mar 24 '17 at 11:27
  • Thank you CNuts. Closing and reopening did it for me. I tried so many other things. Wasted an hour on this. Little issues like this keep cropping up. since I switched to VS 2015 – Grayson Oct 11 '17 at 16:20

0 Answers0