Forum Xamarin.Forms

InitializeComponent does not exist



  • Leon.5487Leon.5487 USMember

    Any progress on this issue? I have tried all of the above with no success.
    I can manually right click on the .xaml file in Visual Studio and select 'Run Custom Tool', but I have to do this each time I open the solution.
    There is another issue: Any portable class libraries referenced by the project gets lost once I use 'Run Custom Tool'

  • JasonMichasJasonMichas USMember ✭✭

    In the past I used this resharper plugin which allowed me to specify the obj/debug and obj/release directories as containing additional source code so that the inspection would no mark all the xaml stuff as broken. It worked great but after upgrading to VS2015 and resharper 10, the plugin is not supported.

    I would try and update the plugin code but I know nothing about resharper plugins and the documentation for v10 seems incomplete, so if any others out there use resharper and can update the plugin, I know this solution works. Well, I know it worked in VS2013 w/ Resharper 8.x I should say, but no reason it wouldn't work in the latest versions

  • MikeRowley403MikeRowley403 CAMember ✭✭✭
    edited November 2015

    I emailed support about the bugzilla bug ( and received the following response:

    Thanks for your patience! Here are the steps that I am taking to help get this resolved

    1. I have added you as impacted by this bug. This will help out team gauge the impact of a bug on our user base as a whole, and helps with prioritizing issues.
    2. I have used our internal escalation process to raise this as a major impact issue. This is an additional tool that directly raises this issue to our teams, and adds additional tracking to the issue.

    I hope that these steps will help resolve the issue quickly. Please feel free to contact me at any time to check on status, and I will see where we are both internally and also on the bugzilla itself.

    I would highly suggest everyone that is on this thread or that reads this thread because they are impacted by the bug, send support an email citing the bug link above and simply ask for an update to when it will be fixed, Xamarin seems to care more about a bug if people are complaining because they are impacted by it.

  • JohnWilson.4976JohnWilson.4976 AUMember ✭✭

    @MikeRowley403 added my 2 cents. Looks like nothing's been done since August. Not sure why I'm paying for a business license when all I can hear is crickets and tumbleweeds when it comes to stuff like this.

  • MikeRowley403MikeRowley403 CAMember ✭✭✭

    I hear you @JohnWilson.4976, it shouldn't stop you from compiling, its just painful looking through all those errors all day every day. Probably costs me 20-30 minutes cumulatively every day sifting through dozens and dozens of false errors to find the one intellisense typo that stops a compile.

  • JohnWilsonJohnWilson USMember

    @MikeRowley403 much this! ;-)

  • ravensorbravensorb USMember ✭✭

    Any updates to this issue? Its been 4 months since it was reported and there seems to be no fix at all. Why the delay???

  • AdrianSudburyAdrianSudbury GBMember, Beta, University

    I'm getting this issue now - anyone from Xamarin care to provide an update?

  • TonyCarterTonyCarter USMember

    I found the "Resource ID", in the build properties for the xaml file, was set to "Namespace.Views.Class.xaml". When I changed it to "Namespace.Class.xaml", the project compiled.

  • AlexanderPachaAlexanderPacha USMember
    edited January 2016

    I am affected by this bug too. None of the above solutions seems to fix it. And it is NOT just annoying, it actually prevents a successful build on a CI like Bitrise, although it seems to work locally in Visual Studio (with errors) and in Xamarin Studio on a Mac (without errors).

    This is the log of the CI:
    /Users/vagrant/git/Source/SightPlayer/SightPlayer.iOS/SightPlayer.iOS.csproj (Build) -> /Library/Frameworks/Mono.framework/Versions/4.2.1/lib/mono/4.5/Microsoft.CSharp.targets (CoreCompile target) -> /Users/vagrant/git/Source/SightPlayer.Core/Views/CameraPage.xaml.cs(7,13): error CS0103: The name 'InitializeComponent' does not exist in the current context 3 Warning(s) 3 Error(s) Time Elapsed 00:00:17.0441530 Build failed ERRO[06:59:44] Step (xamarin-builder) failed, error: (exit status 1)

  • AlexanderPachaAlexanderPacha USMember
    edited February 2016

    I found the reason, why the build failed: The nuget-package for Xamarin.Forms (packages\Xamarin.Forms. was incomplete (the folder build was missing) and therefore no .g.cs was generated. Deleting the folder and restoring the package fixed the build-error for me. Now there is only the annoying IntelliSense bug remaining: that still occurs in the latest version of Xamarin:

    Microsoft Visual Studio Professional 2015
    Xamarin (c7ebc0f)
    Xamarin.Android (e98e962)
    Xamarin.iOS (47eb74b)

  • toSilencetoSilence USMember
    edited February 2016

    I got finally rid of it.

    I use two separate Xamarin versions as nuget packages:

    • Xamarin.Forms.
    • Xamarin.Forms.

    In the references of my project I use only Xamarin.Forms. dlls.

    First modify the .csproj file of your Android application. (Unload --> Edit)
    At the bottom of your file you will find a similar section as in the applied attachment (All paths in the attachment point to Xamarin.Forms.

    Delete/Replace every entry of Xamarin.Forms. (which look like the rows in attachment) with the rows of the attachment.
    Don't delete your references or ANY hint of!

    Finally its working.
    Sometimes the error is shown again:
    --> restore nuget packages
    --> build only android project!
    --> check exception messages, the most times you have another additional exception --> solve it first

  • AlecTucker.2208AlecTucker.2208 AUInsider, University, Developer Group Leader mod

    I've also seen this when trying to build inside a Windows VM on a Mac, with the project loaded form a network share. If that's the case you can get rid of it by mapping a network drive and opening from that.

  • AlecTucker.2208AlecTucker.2208 AUInsider, University, Developer Group Leader mod

    To confirm - this caused another exception that made it look as though the InitializeComponent errors could not be ignored - which they could

  • JohnJHunterJohnJHunter USMember, University, Developer Group Leader

    I just encountered and resolved this error today. I'm posting in case this helps someone.

    I was working on the latest version of Xamarin Forms ( with the App project in a PCL.

    Turns out the error was caused because the namespaces of the page.xaml.cs had been changed without the corresponding change in the page.xaml file Class attribute. Once I made those two match, the error was resolved.

  • TedebusTedebus USMember ✭✭
    edited April 2016

    @JohnJHunter said:
    I just encountered and resolved this error today. I'm posting in case this helps someone.

    I was working on the latest version of Xamarin Forms ( with the App project in a PCL.

    Turns out the error was caused because the namespaces of the page.xaml.cs had been changed without the corresponding change in the page.xaml file Class attribute. Once I made those two match, the error was resolved.

    This is the solution of one of problems of mine. In this case it's normal that InitializeComponents is not reachable.

    @KimRasmussen said:
    After I have added a x:Name="something" in all xaml pages on one of the elements the error seems to go away most of the times. I use the latest build ( of Xamarin.Forms...

    This solution worked fine when the first failed, it seems to be a bug on Xamarin platform.

  • dpedrinhadpedrinha DEMember ✭✭✭
    edited April 2016

    I was following this tutorial:
    I got this problem and I fixed it somehow just changing the "Class" in .xaml file, saving, changing it back to the original value and saving again.
    Maybe it forced the recreation of the connection between the .xaml and the .xaml.cs files.

  • LuisBeltranLuisBeltran CZUniversity ✭✭
    edited April 2016

    I also had this problem with Xamarin Forms I could build to Android, but when trying to build to UWP I got the "InitializeComponent does not exist in the current context" error. After trying so many things, my solution was to analyze both Droid.csproj and the UWP.csproj files.

    Then I found that in Droid.csproj there is an Import tag for Xamarin.Forms. For example, mine is:

    Import Project="....\packages\Xamarin.Forms.\build\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+MonoTouch10+Xamarin.iOS10\Xamarin.Forms.targets" Condition="Exists('....\packages\Xamarin.Forms.\build\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+MonoTouch10+Xamarin.iOS10\Xamarin.Forms.targets')"

    and UWP.csproj didn't have it, so I just added it and now I can build to UWP. Hope it helps!

  • AlezhukAlezhuk USMember ✭✭

    Hey guys! This fixes really easy. I was investigating this bug strange behavior and finally the result came. Simply recreate a file in your project and you'll get rid of damn build error :)

  • AlezhukAlezhuk USMember ✭✭

    Simply try to recreate a problem file :)

  • GautamJainGautamJain INMember ✭✭✭

    Here is my fix:

    When I opened the project in Mac, it changed all the Xaml file's Custom Tool to MSBuild:UpdateDesignTimeXaml from MSBuild:Compile.

    Then opening the project again on Windows in VS causes these InitializeComponent errors.

    Changing MSBuild:UpdateDesignTimeXaml back to MSBuild:Compile fixed the problem.

  • ChuckFarleyChuckFarley USMember
    edited July 2016

    found a solution -> go into your xaml forms (start with the most recently added) and delete and replace a char in the x:Class="your_namespace.your_class" field. you won't have to save, refresh or rebuild, the red will just go away (once you do it to the right one).

  • OwenPOwenP USMember ✭✭
    edited September 2016

    I encountered this today, and none of the mentioned solutions worked around it. This came as an important deadline is approaching, and it's very disappointing I'm going to have to abandon XAML for the time being just to make my deadline.

    I've been wanting to use XAML for a long time, and along comes the first project where I can pitch it to my team and here I am, face-planting into mud due to "known toolchain issues". Maybe if we update XF, but I don't have the time at the moment to propose an attempt.

  • DominicNDominicN USForum Administrator, Xamarin Team, University Xamurai

    Hey @OwenP - sorry to hear about the trouble you're facing! Could you let us know what version of Xamarin.Forms you're currently running as well as the workarounds you've tried? We have identified some fixes that are in more recent versions of Xamarin.Forms, but we'll try to get you up and running without updating if at all possible.

  • OwenPOwenP USMember ✭✭
    edited September 2016

    Hi @DominicN, I'd like to get it up and running, too.

    Right now the project is using I have a feeling that's kind of old. I think we could pain-free update to a new version, but that's not happening until I get some room to do a "high risk" kind of branch.

    Things I've tried:

    • My first thought was some intermediate files got borked, so I did a clean build. That didn't work.
    • I tried changing a bit of the XAML to see if it'd regenerate. That didn't work.
    • I double-checked the namespaces are correct in the x:Class and the actual file.
    • I tried adding a new XAML file to the project: that one doesn't find InitializeComponent() either.
    • I've tried messing with the custom tool, it doesn't seem the IDE likes me doing that. So I tried to edit the .shproj file. That didn't do anything, or sometimes got reverted. I know this is really vague and would work best if I could show you what doesn't work, I can get to that once I meet my current deadline.
    • On a lark, I started a new solution. That one can use XAML. I did notice its .shproj has some extra bits like Compile elements in the .projitems file. Trying to hand-edit my .shproj and .projitems files didn't seem to fix this.

    I haven't yet compared the Android and iOS versions of the files, because I need to finish this week so I started work on a no-XAML version of my UI. I feel like the iOS solution worked at some point previously. The feature I'm adding is Android-focused but I usually work in iOS because I like the simulator better, so I feel like last week I was testing this UI in iOS no problem. However, I can't find a changeset in my source control that works in iOS, so it's possible I did all my work in Android and just don't remember.

    That a new project works fine makes me think that something's borked in my project files, but our project is very large and it'll take a while for me to confirm that. (Plus also I'm facing a new tight deadline so I kind of have to shelve this.)

    But I'd love to get it working, because I've been pushing for a few weeks that "all new UI should be in XAML" and this would put a cramp on that campaign. What kind of elements might magically disappear from .shproj and .projitems files that'd throw a wrench in the gears? Or is there some other project-related file I'm missing?

  • OwenPOwenP USMember ✭✭

    OK. I'm making small progress on this issue.

    Our project has an NUnit test project, and it is specifically that project where the XAML fails to build. That project is... special, and has displayed a lot of weird behavior in the past. There is probably some kind of weird configuration issue, but I'm not quite sure what, yet. Nothing in the IDE looks particularly suspect, but I could have some weird package issue.

  • DominicNDominicN USForum Administrator, Xamarin Team, University Xamurai

    Hey Owen,

    Glad to hear you're making some progress! We do have some confirmation that the newer updates to Xamarin Forms have rectified what seems to be the same issue. I'd be curious to see if you're still hitting that issue after updating. I know it's not what's easiest for you at the moment, but it'll likely be the best way to ensure we catch the issue you're seeing and get it rectified if it hasn't been already.

    You don't even have to update to the newest version. This prerelease version is the earliest package I know of that has a confirmed fix (and if you're looking for a non prerelease package, take a look at Both of these packages were released back in April, about a month after the package you're using was.

    It also looks like there are some workarounds documented here that may actually prove useful to you. Let us know what you see once you give them a try.

    If you still see the issue with a newer version of Forms, please do reach out to us via the email I provided you with and we'll get some additional information to proceed further.

  • OwenPOwenP USMember ✭✭
    edited September 2016

    @DominicN I'm under a bunch of pressures that make it hard to pitch any kind of dependency change, but I can push that task up the ladder next time I get the chance. I swear I tried the most recent Xamarin Forms last week, but usually when I swear that I find out whatever it is starts working so I'll try it again when I've got a little free time.

    I've diffed that particular project with newer ones several times, and haven't found any obvious differences, but when I set up a new project with the right references and start copying that old project's files in it seems to be behaving. Sometime this week I'm hoping to try that out, there's some reasons why that project needs to be moved to a different folder so that seems like a good task to take on. I'm having to be conservative right now, we're in the middle of a cycle where I get yelled at if I introduce risk factors so I'm having to play it safe.

    I'll be back with news either way.

  • OwenPOwenP USMember ✭✭

    I can confirm, @DominicN, that upgrading to Xamarin.Forms addresses the issue. It also introduces a host of teeny layout issues, which is the fear, but hey, at least I've got a solution going forward.

  • dpedrinhadpedrinha DEMember ✭✭✭
    edited September 2016

    Same problem here AGAIN since latest update
    Seems like the dev team don't even compile a single app before releasing an update.
    It happens even in a new project!
    I'm sorry but Xamarin is too old for this kind of mistake on every few updates. Every time I see an update I get afraid of having issues like that. And more often than not, I do.
    Honestly, why are you adding more stuff to Xamarin instead of making it REALLY stable?
    I'm this close to go native in all three platforms.
    Update: didn't fix it.
    Uninstalling Forms and installing looks better.

  • dpedrinhadpedrinha DEMember ✭✭✭
    edited September 2016

    It is still showing the red underline under initializeComponent and any other reference to the Xaml file, but not throwing errors when compiling. Which doesn't make sense.

  • MikeRowley403MikeRowley403 CAMember ✭✭✭
    edited September 2016

    @dpedrinha this is what we have been dealing with for many, many months, you will get errors for any xaml.cs pages that are open in VS but the illegitimate errors wont stop compilation. Close the pages and the illegitimate errors will go away.

    It has something to do with the obj files (*.xaml.g.cs) that are created at compile time but dont seem to be referenced properly in VS to stop the errors.

    You wont see these errors in the Resharper Errors window, which has been the solution many of us have used in the past year or so.

    I can attest from personal experience that posting in the forums will get you less than no response from Xamarin/Microsoft anymore, if you don't pay for support you will get little to no support except from the community.

    Best of luck

  • dpedrinhadpedrinha DEMember ✭✭✭

    Looks like not in the forum nor in bugzilla. The only answers I get there is asking for information when all they have to do is to update Forms in VS 2015 and compile any project to find all the answers.
    I have a real feeling that this is not going forward. Old problems are never fixed, we have to rely on workarounds all the time. And to make it worse, every update brings more trouble than fixes.
    @MikeRowley403 Thanks about the tips, but I have no idea of Resharper is, and I've seen many bug reports about it too, so I just avoided it.
    And the latest Forms are actually preventing me to compile. I had to downgrade it.

  • MikeRowley403MikeRowley403 CAMember ✭✭✭

    @dpedrinha I am pretty sure that nothing is being abandoned, Microsoft's acquisition should guarantee that, MS desperately needs a cross-platform mobile solution or Visual Studio becomes crippled, but I think the transition will take time. The lack of support is rather typical for MS however, you get nothing but community help in most cases unless you pay.
    And from my 2 years experience with Forms, downgrading and not always being on the latest version of Forms is very, very common. You will often find dependency issues in the many nuget packages required to build a full realized production app solution. The trick is watching the second digit changes 2.1 to 2.2 to 2.3 etc, these will often be breaking changes or dependency changes which will break projects, dependencies etc.

    Xamarin.Forms is an excellent solution even though it doesn't often feel full baked before it is released, however the alternative is a much steeper learning curve and diminished code reuse, IMO, creates its own brand of headaches down the road. Then consider learning Swift and Java and developing two separate apps with absolutely no code reuse and some Forms bugs become a more minor inconvenience.

    Even after a nightmare first year with XF, where I paid for the product before the acquisition and got little to no support, I still chose to move forward with Forms as my solution for a second, much larger project. The biggest lesson I learned is that cross platform mobile app development is 2-3 times more difficult or at least time consuming than any other development I have done and I have adjusted my estimates to match that.

    There is a reason why mobile app developers charge clients so much for native applications, its time consuming and wrought with problems and nuanced inconsistencies.

  • EmanueleSabettaEmanueleSabetta ITBeta ✭✭✭
    edited October 2016

    @dpedrinha said:
    I have a real feeling that this is not going forward. Old problems are never fixed, we have to rely on workarounds all the time. And to make it worse, every update brings more trouble than fixes.

    Xamarin.Forms is indeed understaffed. If you look at the commits on the official repo, you'll see that just 7 people are working on it. And 7 people are not nearly enough for mantaining a project of such size. There are thousands of bugs, critical unsolved issues, insufficient performances due to early wrong architectural choices that don't scale. So it is very hard to understand why in Xamarin decided to hire just 7 people to work on the XF project.
    The XF project is very popular, and now that is shipped with Visual Studio even more than before. But after a while developers see their enthusiasm plummet because find themself literally drowning in bugs.

    Someone should explain us the rationale behind this lack of commitment and resources in a good project like XF. We pay a lot of money every year for this product. People are getting tired of complaining, and at some point they will leave and never come back. If nothing changes soon, Xamarin is going to shoot itself in the foot.

  • JohnMillerJohnMiller USForum Administrator, Xamarin Team Xamurai

    Hey All,

    I'm following up on these issues and I do see there have been a few similar problems in the past too. I did find an open bug that could be related:

    I have noticed an InitializeComponent does not exist... error a few days ago while working on something else, but the project isn't doing it now. I'm currently using XVS If anyone has the following, please message me so I can get the right info.

    • Version Information
    • Sample that reproduces it
  • DonBoxDonBox USMember ✭✭
    edited October 2016

    @MikeRowley403 said:
    Microsoft's acquisition should guarantee that, MS desperately needs a cross-platform mobile solution or Visual Studio becomes crippled.

    Desperately needs a cross-platform mobile solution for what? Microsoft didn't even use Xamarin for writing their own Office apps and other apps for iOS and Android.
    You're overestimating Microsoft. Microsoft is a huge company with deep pockets. That doesn't mean they know what they are doing. Don't believe me? Look at Nokia. And it's just one example, and it's not only Microsoft.
    Also, don't underestimate the hoards of developers. You gotta try make them happy somehow from time to time. Especially these rough times with all these non-MS technologies running around :)

    @MikeRowley403 said:
    Xamarin.Forms is an excellent solution even though it doesn't often feel full baked before it is released.

    Before it's released!? It's v2.3 now.
    The main problem with Xamarin Forms is Xamarin themselves didn't believe in the framework and they still don't.
    There's a very small team working on Xamarin Forms, and it feels like a side project. This is weird considering that they promoted Xamarin Forms everywhere, hired Charles Petzold(a long time Microsoft API guy) to write THE Xamarin Forms book, and surprise, surprise, Microsoft acquired Xamarin.

    @EmanueleSabetta said:
    Xamarin is going to shoot itself in the foot.

    There's already many people who think Xamarin Forms is Xamarin and viceversa. They read about Xamarin, "cross-platform", "write once, run everywhere", "C#", "XAML", "Microsoft", "Visual Studio". These people had a pretty bad and rough one time experience with Xamarin Forms, and never looked back. Unfortunately they can't be bothered to spend some time with a niche technology trying to understand the tools and technology and make difference between Xamarin and Xamarin Forms.

    I'm sorry if it sounds too pessimistic or negative. I like Xamarin a lot, I did several projects with it, it's a great technology. I hope they will stick around for years to come and I hope Xamarin Forms will someday be the framework I dream about :)

    As for Microsoft + Xamarin marriage, I guess we'll wait and see next year. By then, it will be enough time to make an opinion.
    I heard Google is creating a new OS. I hope Xamarin is going to be around and see it supporting it and all other major mobile OSes to come :)

  • DonBoxDonBox USMember ✭✭
    edited October 2016

    @EmanueleSabetta said:
    So it is very hard to understand why in Xamarin decided to hire just 7 people to work on the XF project.

    Not sure, are you counting @AdrianKnight too ? The guy has been doing a tremendous job, he's been actually fixing more bugs than anybody else.
    But beside fixing bugs, there are issues in Xamarin Forms which require deep expertise in the development of a truly performant UI layout engine.

  • EmanueleSabettaEmanueleSabetta ITBeta ✭✭✭

    @DonBox They are all doing excellent work. It is not their fault. The problem is that 7 people are not enough to fix thousands of bugs. In my experience not even a team of 30 people could manage a project of such size.

Sign In or Register to comment.