Notice (2018-05-24): bugzilla.xamarin.com is now in
Please join us on
Visual Studio Developer Community and in the
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
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.
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.
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.
I did update the XAML, and the problem remained. By copying the XAML from MyPage.xaml to MyPage2.xaml, MyPage2 worked.
Did you recompile after modifying? it sounds like you had a leftover generated file.
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.
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.
Oh, misread. This was never in forms. Anyway.
It looks as if this was resolved per the above messages, so we should be able to close this.