Mostrando postagens com marcador Xamarin. Mostrar todas as postagens
Mostrando postagens com marcador Xamarin. Mostrar todas as postagens

sexta-feira, 8 de abril de 2016

The name 'InitializeComponent' does not exist in the current context

Hi guys, I've been had some trouble when I try to open a xamarin project on Visual Studio 2015 Community, I get this error "The name 'InitializeComponent' does not exist in the current context".

So, after several research and spend several hour, i found one solution.
On "csproj" file, has one tag to identify a MSBuild target "<Project ToolsVersion="4.0" DefaultTargets="Build"...", then you just check whats your MSBuild version on "C:\Program Files (x86)\MSBuild", you will see which versions are available, so you just need is change the tag "ToolsVersion="  to the newest version. See below:

MSBuild avaiable version:
C:\Program Files (x86)\MSBuild>dir
 O volume na unidade C é OS
 O Número de Série do Volume é 4229-8960

 Pasta de C:\Program Files (x86)\MSBuild

01/04/2016  09:02    <DIR>          .
01/04/2016  09:02    <DIR>          ..
13/02/2016  17:32    <DIR>          12.0
31/03/2016  22:53    <DIR>          14.0
13/02/2016  20:04    <DIR>          4.0
31/03/2016  23:01    <DIR>          Microsoft
13/02/2016  16:25    <DIR>          Microsoft.Cpp
01/04/2016  09:02    <DIR>          Novell
01/04/2016  09:03    <DIR>          Xamarin
               0 arquivo(s)              0 bytes
               9 pasta(s)   58.584.809.472 bytes disponíveis

Before: <Project ToolsVersion="4.0" DefaultTargets="Build"
After: <Project ToolsVersion="14.0" DefaultTargets="Build"

Another things that you need verify, is if in the property of your ".xaml" files, the  "CammonTool" field is setted to "MSBuild:UpdateDesignTimeXaml".