Quantcast
Channel: Recent Threads — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 204402

InitailizeComponent() - from undefined to already exists

$
0
0

Hi all,

This morning i started a new Xamarin Forms project. At first i had the issue where InitializeComponent doesn't exist in this context appears.
I opened the xaml saved the doc and reopened the code behind. All worked surprisingly well.

After coming back from lunch i decided to deploy the app to a device again but during compilation i NOW get the error

The Xamarin Studio version of the error (of course i get a similar error in VS2013):
/Volumes/C/MPos Prototype/MobilePos/MPos/MPos/obj/Debug/MPos.Core.Views.Login.xaml.g.cs(22,22): Error CS0111: A member MPos.Core.Views.Login.InitializeComponent()' is already defined. Rename this member or use different parameter types (CS0111) (MPos.Core)

Any help would be welcomed

Thanks - Aiden

The code

//Login.xaml.g.cs  
public partial class Login : global::Xamarin.Forms.ContentPage {    
    [System.CodeDom.Compiler.GeneratedCodeAttribute("Xamarin.Forms.Build.Tasks.XamlG", "0.0.0.0")]
    private void InitializeComponent() {
        this.LoadFromXaml(typeof(Login));
    }
}

//login.xaml.cs
public partial class Login : ContentPage
{
    public Login()
    {
        InitializeComponent();
    }
}

//login.xaml
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://xamarin.com/schemas/2014/forms"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             xmlns:viewmodels="clr-namespace:MPos.Core.ViewModels;assembly=MPos.Core"
             x:Class="MPos.Core.Views.Login"
             Padding="30">

  <ContentPage.BindingContext>
    <viewmodels:LoginViewModel/>
  </ContentPage.BindingContext>

  <ContentPage.Resources>
    <ResourceDictionary>
      <Style TargetType="Button">    
        <Setter Property="BorderColor" Value="Gray" />
        <Setter Property="BorderWidth" Value="2" />
      </Style>
    </ResourceDictionary>
  </ContentPage.Resources>

  <StackLayout HorizontalOptions="Fill" VerticalOptions="StartAndExpand" Spacing="10">
    <StackLayout HorizontalOptions="Fill" VerticalOptions="StartAndExpand" Spacing="10">
      <Entry Placeholder="username"
             HorizontalOptions="Fill"
             VerticalOptions="End"/>

      <Entry IsPassword="True"
             Placeholder="password"
             HorizontalOptions="Fill"
             VerticalOptions="Fill"/>
    </StackLayout>
    <StackLayout HorizontalOptions="FillAndExpand" VerticalOptions="Center" Spacing="10" Orientation="Horizontal">
      <Button Text="Cancel"
              Command="{Binding Cancel}"
              HorizontalOptions="FillAndExpand"
              VerticalOptions="End"/>

      <Button Text="Login"
              Command="{Binding Login}"
              HorizontalOptions="FillAndExpand"
              VerticalOptions="Fill"/>
    </StackLayout>
  </StackLayout>
</ContentPage>

And finally the actual csproj file

<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup>
    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
    <ProjectTypeGuids>{786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
    <ProjectGuid>{760B277D-98F8-4031-98D7-A788120E2B96}</ProjectGuid>
    <OutputType>Library</OutputType>
    <RootNamespace>MPos.Core</RootNamespace>
    <AssemblyName>MPos.Core</AssemblyName>
    <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
    <TargetFrameworkProfile>Profile111</TargetFrameworkProfile>
    <MinimumVisualStudioVersion>10.0</MinimumVisualStudioVersion>
    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
    <RestorePackages>true</RestorePackages>
    <NuGetPackageImportStamp>81fa07ab</NuGetPackageImportStamp>
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
    <DebugSymbols>true</DebugSymbols>
    <DebugType>full</DebugType>
    <Optimize>false</Optimize>
    <OutputPath>bin\Debug</OutputPath>
    <DefineConstants>DEBUG;</DefineConstants>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
    <ConsolePause>false</ConsolePause>
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
    <DebugType>full</DebugType>
    <Optimize>true</Optimize>
    <OutputPath>bin\Release</OutputPath>
    <ErrorReport>prompt</ErrorReport>
    <WarningLevel>4</WarningLevel>
    <ConsolePause>false</ConsolePause>
  </PropertyGroup>
  <ItemGroup>
    <Compile Include="Commands\BaseCommand.cs" />
    <Compile Include="Commands\DeviceSelectCommand.cs" />
    <Compile Include="Commands\ExecutableCommand.cs" />
    <Compile Include="Commands\PurchaseCommand.cs" />
    <Compile Include="Commands\LoginCommand.cs" />
    <Compile Include="Commands\RegisterCommand.cs" />
    <Compile Include="CustomControls\ListView.cs" />
    <Compile Include="MPosApplication.xaml.cs">
      <DependentUpon>MPosApplication.xaml</DependentUpon>
    </Compile>
    <Compile Include="Properties\Annotations.cs" />
    <Compile Include="Properties\AssemblyInfo.cs" />
    <Compile Include="ViewModels\DeviceListViewModel.cs" />
    <Compile Include="ViewModels\LandingPageViewModel.cs" />
    <Compile Include="ViewModels\LoginViewModel.cs" />
    <Compile Include="ViewModels\PurchaseViewModel.cs" />
    <Compile Include="Views\CardPayment.xaml.cs">
      <DependentUpon>CardPayment.xaml</DependentUpon>
      <SubType>Code</SubType>
    </Compile>
    <Compile Include="Views\DeviceList.xaml.cs">
      <DependentUpon>DeviceList.xaml</DependentUpon>
      <SubType>Code</SubType>
    </Compile>
    <Compile Include="Views\LandingPage.xaml.cs">
      <DependentUpon>LandingPage.xaml</DependentUpon>
      <SubType>Code</SubType>
    </Compile>
    <Compile Include="Views\Login.xaml.cs">
      <DependentUpon>Login.xaml</DependentUpon>
      <SubType>Code</SubType>
    </Compile>
    <Compile Include="Views\Purchase.xaml.cs">
      <DependentUpon>Purchase.xaml</DependentUpon>
      <SubType>Code</SubType>
    </Compile>
    <Compile Include="Views\SelectReceiptType.xaml.cs">
      <DependentUpon>SelectReceiptType.xaml</DependentUpon>
      <SubType>Code</SubType>
    </Compile>
    <Compile Include="Views\TransactionResult.xaml.cs">
      <DependentUpon>TransactionResult.xaml</DependentUpon>
      <SubType>Code</SubType>
    </Compile>
  </ItemGroup>
  <ItemGroup>
    <Folder Include="Models\" />
  </ItemGroup>
  <ItemGroup>
    <EmbeddedResource Include="MPosApplication.xaml">
      <Generator>MSBuild:UpdateDesignTimeXaml</Generator>
      <SubType>Designer</SubType>
    </EmbeddedResource>
    <EmbeddedResource Include="Views\TransactionResult.xaml">
      <SubType>Designer</SubType>
      <Generator>MSBuild:UpdateDesignTimeXaml</Generator>
    </EmbeddedResource>
    <EmbeddedResource Include="Views\SelectReceiptType.xaml">
      <SubType>Designer</SubType>
      <Generator>MSBuild:UpdateDesignTimeXaml</Generator>
    </EmbeddedResource>
    <EmbeddedResource Include="Views\Purchase.xaml">
      <SubType>Designer</SubType>
      <Generator>MSBuild:UpdateDesignTimeXaml</Generator>
    </EmbeddedResource>
    <EmbeddedResource Include="Views\LandingPage.xaml">
      <SubType>Designer</SubType>
      <Generator>MSBuild:UpdateDesignTimeXaml</Generator>
    </EmbeddedResource>
    <EmbeddedResource Include="Views\DeviceList.xaml">
      <SubType>Designer</SubType>
      <Generator>MSBuild:UpdateDesignTimeXaml</Generator>
    </EmbeddedResource>
    <EmbeddedResource Include="Views\CardPayment.xaml">
      <SubType>Designer</SubType>
      <Generator>MSBuild:UpdateDesignTimeXaml</Generator>
    </EmbeddedResource>
    <EmbeddedResource Include="Views\Login.xaml">
      <SubType>Designer</SubType>
      <Generator>MSBuild:UpdateDesignTimeXaml</Generator>
    </EmbeddedResource>
  </ItemGroup>
  <Import Project="$(MSBuildExtensionsPath32)\Microsoft\Portable\$(TargetFrameworkVersion)\Microsoft.Portable.CSharp.targets" />
  <Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" />
  <Import Project="..\..\packages\Xamarin.Forms.2.0.1.6505\build\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+MonoTouch10+Xamarin.iOS10\Xamarin.Forms.targets" Condition="Exists('..\..\packages\Xamarin.Forms.2.0.1.6505\build\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+MonoTouch10+Xamarin.iOS10\Xamarin.Forms.targets')" />
  <Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
    <PropertyGroup>
      <ErrorText>This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them.  For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
    </PropertyGroup>
    <Error Condition="!Exists('$(SolutionDir)\.nuget\NuGet.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(SolutionDir)\.nuget\NuGet.targets'))" />
  </Target>
  <ItemGroup>
    <Reference Include="Xamarin.Forms.Core">
      <HintPath>..\..\packages\Xamarin.Forms.2.0.1.6505\lib\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+MonoTouch10+Xamarin.iOS10\Xamarin.Forms.Core.dll</HintPath>
    </Reference>
    <Reference Include="Xamarin.Forms.Xaml">
      <HintPath>..\..\packages\Xamarin.Forms.2.0.1.6505\lib\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+MonoTouch10+Xamarin.iOS10\Xamarin.Forms.Xaml.dll</HintPath>
    </Reference>
    <Reference Include="Xamarin.Forms.Platform">
      <HintPath>..\..\packages\Xamarin.Forms.2.0.1.6505\lib\portable-win+net45+wp80+win81+wpa81+MonoAndroid10+MonoTouch10+Xamarin.iOS10\Xamarin.Forms.Platform.dll</HintPath>
    </Reference>
  </ItemGroup>
  <ItemGroup>
    <None Include="packages.config" />
  </ItemGroup>
</Project>

Viewing all articles
Browse latest Browse all 204402


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>