【问题标题】:Creating a Hello World in Visual Studio with Xamarin Forms Fails使用 Xamarin 表单在 Visual Studio 中创建 Hello World 失败
【发布时间】:2016-04-01 03:01:44
【问题描述】:

我引用了这个解决方案/问题The type or namespace name 'Xamarin' missing in xamarin studio

但是仍然无法从新的通用应用项目向导构建应用。

Severity    Code    Description Project File    Line    Suppression State
Error   CS0117  'Resource.Attribute' does not contain a definition for 'actionBarSize'  
Project.Droid   C:\dev\Project.Droid\Resources\Resource.Designer.cs 29  Active

Xamarin 新手有什么想法吗?

【问题讨论】:

  • 您使用的是哪个版本的 Xamarin.Forms?其次,引用了各个 Google 支持库的哪个版本?
  • 2.1.0.6529 从我通过 NuGet 添加时开始安装。我不确定是否安装了 google 支持库。
  • 您可以粘贴Resource.desginer.cs 文件的内容吗?也许是要点。
  • 我们会在找到一行代码后:public const int actionBarSize = 2130772085; 如果您的Resource.designer.cs 文件中没有类似的元素,请尝试通过 NuGet 重新安装 Xamarin.Forms并删除Resource.designer.cs 文件。尝试再次编译,文件将被隐藏,将其重新添加到您的解决方案中。
  • 这里是要求的要点。 gist.github.com/ilopez/6064f808c50cc6179e37686fbb9cdee7我去寻找提到的代码。

标签: c# xamarin visual-studio-2015


【解决方案1】:

好的,这就是答案!我对此进行了本地复制,似乎 .csproj 中缺少一些参考:

请确保将以下内容添加到您的.csproj 作为参考:

<Reference Include="Xamarin.Android.Support.Design, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
  <HintPath>..\..\packages\Xamarin.Android.Support.Design.23.0.1.3\lib\MonoAndroid403\Xamarin.Android.Support.Design.dll</HintPath>
  <Private>True</Private>
</Reference>
<Reference Include="Xamarin.Android.Support.v4, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
  <HintPath>..\..\packages\Xamarin.Android.Support.v4.23.0.1.3\lib\MonoAndroid403\Xamarin.Android.Support.v4.dll</HintPath>
  <Private>True</Private>
</Reference>
<Reference Include="Xamarin.Android.Support.v7.AppCompat, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
  <HintPath>..\..\packages\Xamarin.Android.Support.v7.AppCompat.23.0.1.3\lib\MonoAndroid403\Xamarin.Android.Support.v7.AppCompat.dll</HintPath>
  <Private>True</Private>
</Reference>
<Reference Include="Xamarin.Android.Support.v7.CardView, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
  <HintPath>..\..\packages\Xamarin.Android.Support.v7.CardView.23.0.1.3\lib\MonoAndroid403\Xamarin.Android.Support.v7.CardView.dll</HintPath>
  <Private>True</Private>
</Reference>
<Reference Include="Xamarin.Android.Support.v7.MediaRouter, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
  <HintPath>..\..\packages\Xamarin.Android.Support.v7.MediaRouter.23.0.1.3\lib\MonoAndroid403\Xamarin.Android.Support.v7.MediaRouter.dll</HintPath>
  <Private>True</Private>
</Reference>

然后您可以从您的项目中删除Resource.designer.cs 文件,重新构建您的项目,然后将Resource.designer.cs 文件重新添加到您的项目中。它应该生成以下Attribute 项目:https://gist.github.com/JonDouglas/7adf61469ce21663d7f536a4aa27c7df

【讨论】:

  • 删除 Resource.designer.cs 允许项目 (.droid) 编译。重新添加它会带来错误。我需要那个文件吗?我怎样才能在没有错误的情况下重新添加它?
猜你喜欢
  • 1970-01-01
  • 2016-12-20
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-12-20
  • 2022-08-16
相关资源
最近更新 更多