Bug 36935 - The name 'InitializeComponent' does not exist in the current context error with XAML on UWP
Summary: The name 'InitializeComponent' does not exist in the current context error wi...
Status: RESOLVED DUPLICATE of bug 39827
Alias: None
Product: Forms
Classification: Xamarin
Component: Forms ()
Version: 2.0.0
Hardware: PC Windows
: --- normal
Target Milestone: UWP
Assignee: Bugzilla
Depends on:
Reported: 2015-12-12 03:28 UTC by nnishi
Modified: 2016-04-21 16:56 UTC (History)
15 users (show)

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

Project for reproducing this issue. (93.56 KB, application/x-zip-compressed)
2015-12-16 22:14 UTC, Gabor Nemeth

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:

Description nnishi 2015-12-12 03:28:47 UTC

Xamarin is used to build an app on UWP, when it occurs "The name 'InitializeComponent' does not exist in the current context" error with XAML page. 

It seems that the issue was fixed in v1.4 on Windows 8.1 though, is the fix also true for UWP? 
Since Xamarin.Forms for UWP is still preview. 

Thank you for your help.
Best Regards,
Comment 1 Gabor Nemeth 2015-12-16 22:14:06 UTC
Created attachment 14328 [details]
Project for reproducing this issue.

I have created a simple test project, that does not compile.
Problem is XAML page comes from a shared project.
Comment 2 sb 2016-01-14 12:28:26 UTC
I confirm the same issue, stuck to code only for now as XAML doesn't work.
Comment 3 Bob 2016-02-12 18:18:56 UTC
Just ran into the same issue myself, and stumbled here.  (using forms package
Comment 4 thomas 2016-02-26 10:27:21 UTC
Same problem here. Just wanted to prot my Android Project to UWP and cnnot compile it.
Comment 5 blitzillu 2016-03-02 10:46:23 UTC
Same problem here. Using Xamarin Forms and Visual Studio 2015 with a UWP project. I get this error when I try to deploy it. It has to be deployed before it can run in the simulator ...
Comment 6 David Karlaš 2016-03-10 10:17:36 UTC
Can someone right click .xaml file and execute "Run Custom Tool", I get "Error HRESULT E_FAIL has been returned from a call to a COM component.". I'm pretty sure it's related.
Comment 7 Matt Ward 2016-03-10 11:26:09 UTC
I see the same "The name 'InitializeComponent' does not exist in the current context" error with a Forms .xaml file in a shared project.
Comment 8 David Karlaš 2016-03-10 11:33:26 UTC
Reproduction steps that I use:
1) Create new "Blank App(Universal Windows) project in VS
2) Add Xamarin Forms NuGet to project
3) Add SharedProject to solution
4) Reference SharedProject from UWP project
5) Add new .xaml file to Shared Project, CrossPlatform->Forms Xaml Page
6) Run “Run Custom Tool" on file inside UWP project(App.xaml)

See exception I mentioned in Comment 6 and also 'InitializeComponent' missing error in Page1.xaml.cs file.
Comment 9 Joaquin Jares 2016-03-10 12:50:04 UTC
This is a duplicate of 33181. Please see here: https://bugzilla.xamarin.com/show_bug.cgi?id=33181#c30 for a workaround.

*** This bug has been marked as a duplicate of bug 33181 ***
Comment 10 Brendan Zagaeski (Xamarin Team, assistant) 2016-03-22 04:50:59 UTC
- I have now filed Bug 39827 to provide a clean starting point for further discussion of the "'InitializeComponent' does not exist" _build_ error for Shared Projects combined with UWP projects. I will accordingly mark this bug as a duplicate.

- I have also now filed Bug 39826 for the issue with "Run Custom Tool" mentioned in Comment 6 and Comment 8. Somewhat surprisingly, it seems that that error is unrelated to the primary problem with "InitializeComponent".

## Additional information

According to my tests, the "'InitializeComponent' does not exist" _build_ error from this bug is slightly different from the IntelliSense error in Bug 33181. The problem in this case (Bug 36935) is that no `.g.cs` files are being generated for the XAML pages in the Shared Project during build. As mentioned in Comment 0, a similar issue was indeed resolved for Windows 8.1 projects in Xamarin.Forms 1.4.4 (Bug 29501).

*** This bug has been marked as a duplicate of bug 39827 ***
Comment 11 Rui Marinho 2016-04-21 16:56:09 UTC
*** Bug 40405 has been marked as a duplicate of this bug. ***