简体   繁体   English

VS2015 Xamarin.Android:Intellisense无法看到Resource.designer.cs

[英]VS2015 Xamarin.Android: Intellisense can't see Resource.designer.cs

I'm using Visual Studio 2015 with Xamarin.Android. 我正在使用Visual Studio 2015和Xamarin.Android。 My solution compiles and links fine, with no warnings or errors. 我的解决方案编译和链接很好,没有警告或错误。 It runs correctly on my target device. 它在我的目标设备上正确运行。

However, Intellisense can't find the autogenerated Resource.designer.cs file (which provides all the resource ID constants for things like page design elements from .axml files, string resources, assets and so on). 但是,Intellisense无法找到自动生成的Resource.designer.cs文件(它提供了诸如.axml文件,字符串资源,资产等页面设计元素之类的所有资源ID常量)。

If I have code like: var button = FindView(Resource.Id.some_button); 如果我有类似的代码: var button = FindView(Resource.Id.some_button); , then in the edit window the "Resource" part will have a red underline, and if I mouse over it, I see: "The name 'Resource' does not exist in the current context." ,然后在编辑窗口中,“资源”部分将有一个红色下划线,如果我将鼠标悬停在它上面,我会看到:“当前上下文中不存在名称'资源'。”

In the Output window, if I change the dropdown to show output from Intellisense, I see a line like: 在“输出”窗口中,如果我将下拉列表更改为显示Intellisense的输出,我会看到如下行:

[Failure] Could not find file 'C:\Users\dghenke\Downloads\Widget\Widget\Widget.Android\obj\Debug\designtime\Resource.Designer.cs'.

That path exists up to the Debug\\ folder, but there is no designtime\\ folder underneath. 该路径存在于Debug \\文件夹中,但下面没有设计时\\文件夹。

Things I have tried: 我尝试过的事情:

  • Closing and re-opening Visual Studio. 关闭并重新打开Visual Studio。
  • "Clean Solution" followed by "Build Solution". “清洁解决方案”后跟“构建解决方案”。
  • Completely removing my source tree then fetching a fresh copy from source control. 完全删除我的源代码树,然后从源代码控制中获取一个新的副本。
  • Checking my .csproj file to make sure that <MonoAndroidResourcePrefix>Resources</MonoAndroidResourcePrefix> <AndroidResgenClass>Resource</AndroidResgenClass> <AndroidResgenFile>Resources\\Resource.designer.cs</AndroidResgenFile> is in the first <PropertyGroup> element. 检查我的.csproj文件以确保<MonoAndroidResourcePrefix>Resources</MonoAndroidResourcePrefix> <AndroidResgenClass>Resource</AndroidResgenClass> <AndroidResgenFile>Resources\\Resource.designer.cs</AndroidResgenFile>位于第一个<PropertyGroup>元素中。
  • Removing the Resource.designer.cs file from the project and re-adding it. 从项目中删除Resource.designer.cs文件并重新添加它。

Things I have not tried (and would prefer to keep it that way): Creating a whole new solution from scratch then manually re-adding all my source files from the original. 我没有尝试过的东西(并且希望保持这种方式):从头开始创建一个全新的解决方案,然后手动重新添加原始的所有源文件。

Versions: 版本:

  • Visual Studio Professional 2015 14.0.25431.01 Update 3 Visual Studio Professional 2015 14.0.25431.01更新3
  • Xamarin 4.8.0.756 Xamarin 4.8.0.756
  • Xamarin.Android 8.1.0.13 Xamarin.Android 8.1.0.13

What finally worked for me was addding: 最终对我有用的是添加:

<AndroidUseManagedDesignTimeResourceGenerator>False</AndroidUseManagedDesignTimeResourceGenerator>

to the first PropertyGroup in my .csproj file. 到我的.csproj文件中的第一个PropertyGroup

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM