Bug 43835 - Visual Studio gives the error that properties don't exist
Summary: Visual Studio gives the error that properties don't exist
Alias: None
Product: Forms
Classification: Xamarin
Component: Forms ()
Version: 2.3.2
Hardware: PC Windows
: Normal normal
Target Milestone: ---
Assignee: Bugzilla
Depends on:
Reported: 2016-08-29 16:26 UTC by Hakan
Modified: 2016-10-24 14:21 UTC (History)
6 users (show)

Tags: ac
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 for Bug 43835 on Developer Community or GitHub if you have new information to add and do not yet see a matching new report.

If the latest results still closely match this report, you can use the original description:

  • Export the original title and description: Developer Community HTML or GitHub Markdown
  • Copy the title and description into the new report. Adjust them to be up-to-date if needed.
  • Add your new information.

In special cases on GitHub you might also want the comments: GitHub Markdown with public comments

Related Links:

Description Hakan 2016-08-29 16:26:37 UTC
I was trying the project explained on https://developer.xamarin.com/guides/xamarin-forms/getting-started/hello-xamarin-forms/quickstart/ but suddenly Visual Studio started to raise errors on MainPage.xaml.cs saying that the properties/methods do not exist even though it was fine a minute ago and I did not do any changes. After searching on StackOverflow, I encountered this thread: http://stackoverflow.com/questions/28818525/xamarin-forms-initializecomponent-dont-exists-when-creating-new-page. And opening MainPage.xaml and MainPage.xaml.cs together and saving them did the trick as explained in the thread. I think this is a bug that sporadically happens.
Comment 1 Brendan Zagaeski (Xamarin Team, assistant) 2016-08-31 00:53:02 UTC
Thanks for the report.

One possible way this issue can arise is Bug 40666.  To summarize, the issue can occur if the codebehind files are deleted or changed outside of Visual Studio.  As noted on that bug report, that issue appears be tightly related to the hooks Visual Studio itself provides for generating code behind files for any project type (not just Xamarin).  It might even an intentional optimization in the Visual Studio logic.

If in your opinion that bug does not match the particular scenario you have observed yourself, then to help the Xamarin team address this issue as efficiently as possible, please provide additional information, such as:

- If possible, briefly describe a set of steps you have followed that have led to you to see this problem a few different times (for example, after fixing the problem once by explicitly saving thee files, and then the problem later returns).

- When you are in the "bad" state, do the codebehind files exist in the `obj\` folder?  See for example the `dir` commands in Bug 40666, Comment 0 such as:

> dir /b obj\Debug\*.g.cs

- Include the full log context of the error messages you are seeing.  As reported, this sounds like an IntelliSense error, so in that case please copy and paste the full text of the error(s) from "View > Error List" (with the drop-down set to "IntelliSense Only").

- Describe the environment where the bug was encountered, including the operating system and versions of Xamarin, Xamarin.Forms, and any other dependencies.

See https://kb.xamarin.com/customer/en/portal/articles/1910343 for additional details about what to include and some strategies for minimizing test cases.  Thanks in advance!
Comment 2 Hakan 2016-09-15 01:55:38 UTC
The code behind files are not touched outside of Visual Studio.

It happens each time as I open the Visual Studio with MainPage.xaml and MainPage.xaml.cs initially open in the tabs. I save MainPage.xaml without making any additional changes and the errors get fixed. But it keeps happening sporadically as I work on MainPage.xaml.

When in "bad" state, Phoneword.MainPage.xaml.g.cs file exists in the debug folder.

Here are the errors shown in the error pane:

The name 'phoneNumberText' does not exist in the current context
The name 'InitializeComponent' does not exist in the current context
The name 'callButton' does not exist in the current context
The name 'callHistoryButton' does not exist in the current context

The environment is: Windows 10 Pro, VS 2015, and the up-to-date version of Xamarin.
Comment 3 Hakan 2016-09-16 09:58:53 UTC
Needed info given.
Comment 4 Brendan Zagaeski (Xamarin Team, assistant) 2016-09-16 23:10:58 UTC
Thanks!  I'll take a try at running through that quickstart guide too to see what happens on my end.

If you get a chance before I get back to testing that out, there are 2 little additional version info details I'm curious about:

(1) What versions of the Xamarin.Forms NuGet package are shown as being installed in the "Phoneword" PCL project for you?  It looks like the Xamarin.Forms package versions in that sample as of today are "", so I suspect you have the same, but it'll be good to have you double-check for thoroughness, if you get a chance.  (A little while back, in Xamarin.Forms 2.1.x and earlier, there was another bug that could cause these errors.)

(2) Again just to be thorough, you're probably using VS 2015 Update 3 in particular (rather than one of the earlier versions of VS 2015), correct?

Thanks again!
Comment 5 Hakan 2016-09-17 15:01:31 UTC
Yes, the Nuget package version is and VS is 2015 Update 3.
Comment 6 dpedrinha 2016-09-30 06:22:55 UTC
I'm getting this error with the latest Xamarin.Forms (latest stable).

I tried the Xamarin.Forms and the problem persisted.

I uninstalled Forms, installed Xamarin.Forms and now it compiles without throwing errors, but the initializeComponent and any other reference to the Xaml files are still underlined in red.

But hey Brendan, does it work there on your computer? It seems to me that all the info you need is right there in your computer. All you need is an updated VS 2015 with Xamarin and Forms. Any project will throw that error.

Comment 7 arippste 2016-10-24 14:21:00 UTC
I had exactly the same problem with Microsoft Visual Studio Enterprise 2015
Version 14.0.25431.01 Update 3 and Xamarin.Forms Version

The full story:

I joined a team of developers that already started a new Xamarin.Forms app based on Version The solution was already in Team Foundatio Server. To start developing I had to setup Microsoft Visual Studio Enterprise 2015 Update 3 and Xamarin.Forms Version on a PC that did not have Visual Studio installed before. I installed all features of VS Enterprise, then downloaded the solution from TFS. After compiling the solution the Visual Studio IntelliSense did show errors on *.xaml.cs code behind files. E.g. the function InitializeComponent(); was underlined in red color.

I spent many hours to find a solution since all tips from various forums did not help. The obj\..\*.xaml.g.cs were generated sucessfully. Upgrade to the latest stable Xamarin.Forms Version did not help.

What finally did help in my case was temporarily downgrade the Visual Studio Project (portable) to the Xamarin.Forms Version and then rebuild the solution. After that the Intellisense problems were gone. I then could undo the downgrade and return to Xamarin.Forms Version The problem did not appear again.