Home » WPFRSS

The name 'InitializeComponent' does not exist in the current context

I am attempting to build a UserControl class for a WPF MVVM application.  Even before I write a single line of code, I get the "The name 'InitializeComponent' does not exist in the current context" error.  The Build Action on the XAML file is set to "Page", Custom Tool is set to "MSBuild:Compile".

XAML:

<UserControl x:Class="ContractorModule.Views.ContractorView"

   xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

   xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

   Height="300"

   Width="300">

   <Grid>

   </Grid>

</UserControl>

Code Behind:

using System;

using System.Collections.Generic;

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 ContractorModule.Views

{

   ///<summary>

   /// Interaction logic for ContractorView.xaml

   ///</summary>

   publicpartialclassContractorView : UserControl

   {

       public ContractorView()

       {

          InitializeComponent();

       }

   }

}

 

 

5 Answers Found

 

Answer 1

Sounds strange. It definetly doesn't associate ContractorView in your XAML with same one in the code. Could you upload your solution somewhere so I can look on it?
God bless you!
 

Answer 2

The solution is rather large, consisting of 8 projects.  The ContractorModule is one of those projects.  Zipped, the solution is 4.5MB.  It also references third-party controls and attaches to a remote MSSQL Server, so you would not be able to compile the solution successfully without recreating my environment.  However, if you still think that having the entire solution will help resolve this problem, I will try to upload the Zipped solution.  Do you know of some place where I can upload a 4.5MB Zip file that would give you access?

 

Answer 3

Upload only ContractorModule project
 

Answer 4

Gladly.  It is only 616KB zipped.  Where/How do I upload the file for you to access?

FYI:  The ContractorView.g.cs source file is not being created.

 

Answer 5

Hi AlaskanGlitch,

Thanks for posting.

I am wondering whether this only happen to one particular usercontrol? Have you tried creating a new UserControl in the same project? Does the same thing happen again? If so, what if you create a UserControl in a brand new WPF project?

Could you let us know your visual studio version and OS version?

If there isn't any confidential/sensitive information in your code, you can upload it to SkyDrive and post the link here.

 
 
 

<< Previous      Next >>


Microsoft   |   Windows   |   Visual Studio   |   Follow us on Twitter