Bug 57763 - Reproduceable: The name 'InitializeComponent' does not exist in the current context
Summary: Reproduceable: The name 'InitializeComponent' does not exist in the current c...
Status: RESOLVED ANSWERED
Alias: None
Product: Forms
Classification: Xamarin
Component: Forms ()
Version: unspecified
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2017-06-26 15:41 UTC by Ian
Modified: 2017-08-11 19:22 UTC (History)
6 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED ANSWERED

Description Ian 2017-06-26 15:41:57 UTC
VS 2017, newest XForms. XAML, Windows 10

How to get "The name 'InitializeComponent' does not exist in the current context " error

1. Create a new multi platform Forms app from the template in VS2017
2. Run it. All is fine
3. Edit XAML. All is fine.
4. Decide you don't like the default namespace and assembly name. Change it. Change all the namespaces too in the source code with CTRL+F and Replace
5. Delete all bin and obj folders to be sure it's clear. Recompile
6. Bang, the error appears.
7. Create a new XAML page. It's fine! The old ones, pre-namespace change, get the error.
Comment 1 Joaquin Jares 2017-06-26 17:26:30 UTC
When you change the namespace, you also need to change the namespace in existing classes (in the XAML). When we create new classes we use the new namespace but we don't proactively modify your old code. You are probably left with x:Class="[youroldnamespace].[yourclassname]" in App.xaml in your PCL or shared project. I would also check x:Class in your other existing XAML files. I'm marking this as Answered. Please do reopen if this is not the issue.
Comment 2 Ian 2017-06-26 18:18:45 UTC
I did update the XAML, and the problem remained. By copying the XAML from MyPage.xaml to MyPage2.xaml, MyPage2 worked.
Comment 3 Joaquin Jares 2017-06-26 18:48:51 UTC
Did you recompile after modifying? it sounds like you had a leftover generated file.
Comment 4 Ian 2017-06-26 18:51:39 UTC
Yes, I even deleted all bin / obj files.

An interesting trick is to rename a xaml file, then all the other xamls are fine and will work. 

Caching?
Comment 5 Joaquin Jares 2017-06-26 18:54:47 UTC
Maybe caching, but this was in forms and sent to us, so I think not. I'm moving again to forms for an answer to this question. It'll come back, I'm sure :). Forms guys, this is just for the answer.
Comment 6 Joaquin Jares 2017-06-26 18:55:17 UTC
Oh, misread. This was never in forms. Anyway.
Comment 7 Paul DiPietro [MSFT] 2017-08-11 19:22:17 UTC
It looks as if this was resolved per the above messages, so we should be able to close this.