Intellisense issues with XAML based views in PCL using any version Xamarin.Forms 1.4+

I created a Xamarin.Forms PCL project in Visual Studio 2015 Enterprise and added some views, viewmodels, etc and everything seemed to be fine. The project template seems to come with Xamarin.Forms nuget package 1.3. When I updated the Nuget package to the latest version of Xamarin.Forms, Visual Studio says there are intellisense issues saying InitializeComponent does not exist as well as any other named-controls defined in the xaml.

The project still builds successfully, however there are now tons of intellisense-errors.

I have found that if I update the nuget package of Xamarin.Forms to anything after 1.3.5.6335 (basically any version 1.4 or greater) this problem occurs.

After some Googling it appears there is some history regarding this issue, or something similar, but appears that those discussions had to do with iOS and/or shared projects, which does not seem to apply. Also, those discussions seem to be over a year old.

All xaml files are marked as an Embedded Resource and have a custom tool of MSBuild:UpdateDesignTimeXaml which I believe both are correct.

Does anyone know how to resolve this?

Answers

  • JeffWyzardJeffWyzard USUniversity

    Brett,

    I've been seeing this same issue since August so I too would like to know if anyone knows how to fix the errors. I read a lot of the same posts on Google about shared projects, etc. which is why I did a small simple new project below for testing which versions produce the error.

    I get the errors on version above 1.4.3.6376 and I tried most every version (I didn't try any -pre) including the stable last weekend so I went back to 1.4.3. I created a new project last weekend, added 1 new page to the PCL called "TestPage1" and it was working with version 1.4.3. Then when I upgrade the Xamarin.Forms in NuGet to any version including the stable versions 1.5.x then I receive the same errors as Brett when I had the TestPage1.xaml.cs file open on the "InitializeComponent" line. I never modified the TestPage1 file. It would compile and run but the intellisense errors were showing for InitializeComponent and other stuff. To fix the errors, I would use NuGet to downgrade Xamarin.Forms. When I would get to 1.4.3.6376, the errors would go away.

    I'm using Visual Studio 2015, I have not tried any of this with VS 2013.

    This morning, I tried a new Test project, added the TestPage1 to it and upgraded the framework to the new released 2.0.0.6482 and it immediately started giving an error Code "CS0103" and Description "The name 'InitializeComponent' does not exist in the current context".

  • I just tried this in VS2013 and seeing the same thing.

    To replicate:
    1. Create a new Xamarin Forms PCL solution (Blank Xamarin.Forms Portable).
    2. Add a new XAML page to the PCL project.
    3. Build the solution, everything builds fine, no intellisense complaints.
    4. Manage nuget packages for the PCL project, update Xamarin.Forms to the latest.
    5. Build the PCL project
    6. See the pretty red squigglies under InitializeComponent() as well as in the Error List window.

    So this seems to behave the same in both VS2013 as well as VS2015.

  • vs 2015 is a real nightmare with xamarin... mostly because of intellisense errors. Projects are building fine but it's so confusing having all these underlined code lines. I clearly don't understand why Xamarin isn't fixing this. I contacted support, but then they are asking me to send over the project.. As this is customer's private code, I cannot do this.
    Sometimes is helps the do a clean and rebuild, but opening one xaml file afterwards brings back all the intellisense errors. very frustrating indeed!
    I cannot go back to vs2013 because I'm using c# 6 features.

  • JasonMichasJasonMichas USMember ✭✭

    Yeah, another problem is if you have project references from your core project to other projects in your solution the MSBuild:UpdateDesignTimeXaml task breaks the references so on top of the xaml errors you get the "are you missing an assembly reference?" errors for types in the references projects.

    If you aren't using any project references a quick way to remove the xaml errors is to right click a xaml file and select run custom tool. But like all the solutions so far, as soon as you build or make a change they all break again.

    The funny part is, I fixed all my project refs, then clean rebuild and fixed my assembly ref errors, then I click run custom tool on xaml to fix those and it breaks all the assembly refs again. What a PITA. I wish I could go back to my happy VS2013 resharper 8 days, where I had no compiler warnings or intellisense errors.

  • I do not believe this is a VS2015 issue as I get the same problem with either VS2013 or VS2015 (using the steps I mentioned previously).

    What's frustrating is that it seems to work without any issues with Xamarin.Forms v1.3.5.6335 (in both VS2013 and VS2015), but any version after that I then get problems.

    This leads me to believe it has something to do Xamarin.Forms as the older nuget package works, yet later ones do not.

  • JulienRosenJulienRosen CAMember ✭✭✭✭

    One small workaround is to change the combobox in the errors pane to "build only", this will prevent you from seeing false intellisense errors.

  • AngelRAngelR USMember

    Same IntelliSense issues like you @BrettSheleski

    Same frustration and more. See my post about App crashing at startup without solution ...
    Blocked on my work for 5 days ... XO

  • I know you can select that drop down as @JulienRosen suggests, however this particular app is part of a larger solution of other projects. This becomes a very large pain when developing something for another part of the solution, which has nothing to do with any xamarin/mobile stuff at all, but I have to disable intellisense because the Xamarin project is throwing a fit.

  • Have been fighting with this issue yesterday. Have ~250 errors in my solution because of this.

    VS Pro 2015 Update 1 (14.0.24720.00); Xamarin.Forms.2.0.0.6490; PCL setup.

    As soon as a Forms XAML file is created (such ContentView) in the Forms PCL project, the project stops seeing other referenced PCL projects and reports "The name 'InitializeComponent' does not exist in the current context" for each XAML file. After removing all Forms XAML files, everything is back to normal.

    I am surprised Xamarin guys are not commenting here. I am considering creating a sample project and raising a support request.

  • JasonMichasJasonMichas USMember ✭✭

    @StanKolesnik Please do. This is getting ridiculous. We need them to get on this as it is a very annoying problem.
    I'm sure they will not see it as critical but I feel like it is, even if I can fumble through my work under the current constraints.

    The real part that hurts is I have a habit of removing the unnecessary using statements before I close a file. Since the proj references are broken it thinks the using statements are not needed and so they get removed, then you get compiler errors and there is no automated way to put the using statements back since the references are broken. It really is a huge pain.

  • @JasonMichas Done. The solution is published here: https://github.com/skolesni/Sample.XamarinIntellisenceIssue. I have produced a step by step readme.txt explaining the process.

    Now I need some help pushing this to Xamarin support. I am working under Business License allocated to me by my manager, so it is under his email account. The Business License means email support only, so on Monday I will ask my manager to send an email to "[email protected]" to get started, but not sure how ling it will take. However, if any of you have Enterprise License, or direct contacts with Xamarin, could you please forward the reference to this Repo and initiate a support request from yourself? This will mean 24 hour response time.

    So, guys with Enterprise Licenses, could you please take care of this?

  • JasonMichasJasonMichas USMember ✭✭

    @StanKolesnik Awesome! I too am a biz license user. Why don't we just file a bug in the bug tracker (https://bugzilla.xamarin.com)? This way we can all chime in on the bug report instead of the forum thread.

  • BrendanZagaeskiBrendanZagaeski USForum Administrator, Xamarin Team Xamurai
    edited April 2017

    Thanks StanKolesnik for adding a report in Bugzilla to help raise the visibility of this issue to the Xamarin team. I will now close this thread to consolidate any further discussion and updates onto the bugs for the 2 sub-problems described in that report (and in this forum thread): Bug 32988 and Bug 33181. Feel free to post any further findings about improved or more detailed workarounds on the appropriate bug report to make them visible to other users.


    (As always, I'm also happy to reopen the thread upon request within the next month or two. Just send a quick email to [email protected] with a link to this thread. For follow-up after the next couple of months, if the remaining related open bug reports or forum threads do not cover the desired scenario, please follow the recommendations to create a new bug report, forum thread, or Stack Overflow question. Thanks!)

This discussion has been closed.