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 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
In special cases on GitHub you might also want the comments:
GitHub Markdown with public comments
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.
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!
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.
Needed info given.
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 "18.104.22.168", 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?
Yes, the Nuget package version is 22.214.171.124 and VS is 2015 Update 3.
I'm getting this error with the latest Xamarin.Forms 126.96.36.199 (latest stable).
I tried the Xamarin.Forms 188.8.131.52-pre2 and the problem persisted.
I uninstalled Forms, installed Xamarin.Forms 184.108.40.206 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.
I had exactly the same problem with Microsoft Visual Studio Enterprise 2015
Version 14.0.25431.01 Update 3 and Xamarin.Forms Version 220.127.116.11
The full story:
I joined a team of developers that already started a new Xamarin.Forms app based on Version 18.104.22.168. 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 22.214.171.124 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 126.96.36.199 did not help.
What finally did help in my case was temporarily downgrade the Visual Studio Project (portable) to the Xamarin.Forms Version 188.8.131.52 and then rebuild the solution. After that the Intellisense problems were gone. I then could undo the downgrade and return to Xamarin.Forms Version 184.108.40.206. The problem did not appear again.