Reputation: 1413
I'm new to Xamarin development, and while developing my first app, I hit the error "The name 'InitializeComponent' does not exist in the current context".
Searching the web gave a bunch of results suggesting rolling back the Xamarin.Forms package, rebuilding packages, closing and re-opening VS, cleaning and re-building. None of them helped.
How can I determine the cause of the error?
Upvotes: 1
Views: 492
Reputation: 1413
After a while I understood, that InitializeComponent is defined in the auto-generated C# file MyPage.xaml.g.cs. If the method is not there, it means code generation failed. I guess there may be a thousand reasons, in my case it was a mistaken type name in the .xaml file:
<ContentPage
xmlns="http://xamarin.com/schemas/2014/forms"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="Waiter.Xmrn.Views.MyPage666"
...
The actual class name was ...MyPage.
Unfortunately, I had no other messages - hopefully in the fuure there's going to be something more specific.
Upvotes: 1