[英]Ambiguous reference intellisense error from Resource.Designer.cs
I am running into a peculiar bug when developing on Visual Studio 2017 that I have been able to ignore for a while, but is now beginning to really bug me. 我在Visual Studio 2017上开发时遇到了一个奇怪的错误,我已经能够忽略一段时间,但现在开始真的让我感到烦恼 。
I refer to this issue as a bug rather than an error because I am still able to build my projects in Visual Studio and deploy them to my development device without errors or warnings from the build output. 我将此问题称为错误而不是错误,因为我仍然可以在Visual Studio中构建我的项目并将它们部署到我的开发设备,而不会出现构建输出中的错误或警告。 This might seem alright to ignore for a bit, but over time it has become an issue because my intellisense is underlining it in red as an error
这似乎可以忽略一点,但随着时间的推移它已经成为一个问题,因为我的intellisense用红色强调它作为一个错误
every time I reference attributes from the Resource class. 每次我引用Resource类的属性。 As you might guess, I refer this class a lot and the Visual Studio editor eventually becomes cluttered with these "errors" which (a) hinders my ability to find actual errors in my code and (b) irritates me beyond all reason...
正如你可能猜到的那样,我引用了很多这个类,Visual Studio编辑器最终变得混乱了这些“错误”,它们(a)阻碍了我在代码中发现实际错误的能力,并且(b)让我无法理解......
.
。
The .csproj config file contains the tags: .csproj配置文件包含标记:
<AndroidResgenFile>Resources\\Resource.Designer.cs</AndroidResgenFile> <AndroidResgenClass>Resource</AndroidResgenClass> <GenerateSerializationAssemblies>Off</GenerateSerializationAssemblies> <AndroidUseLatestPlatformSdk>false</AndroidUseLatestPlatformSdk> <TargetFrameworkVersion>v7.1</TargetFrameworkVersion> <AndroidManifest>Properties\\AndroidManifest.xml</AndroidManifest> <MonoAndroidResourcePrefix>Resources</MonoAndroidResourcePrefix> <MonoAndroidAssetsPrefix>Assets</MonoAndroidAssetsPrefix>
6/6/2018 Update
6/6/2018更新
If you have ReSharper, you most likely will be able to disregard my per-project solution described below and, instead, simply install the latest version (currently ReSharper 2018.1.2).
如果你有ReSharper,你很可能会忽略我下面描述的每个项目解决方案,而只需安装最新版本(目前是ReSharper 2018.1.2)。 Apparently, the underlying issue was caused by a bug in a previous version.
显然,底层问题是由先前版本中的错误引起的。 Upgrading resolved the issue for me.
升级为我解决了这个问题。
See youtrack.jetbrains.com/issue/RSRP-469636 for more information.
有关更多信息,请参阅youtrack.jetbrains.com/issue/RSRP-469636 。
Thanks to @davidbauduin over at Xamarin Forums for this information.
感谢@davidbauduin在Xamarin论坛上获取此信息。
I believe I have figured out the underlying issue and have a viable solution. 我相信我已经找到了根本问题,并有一个可行的解决方案。
Add the following to the <PropertyGroup>
section in your .csproj file: 将以下内容添加到.csproj文件中的
<PropertyGroup>
部分:
<AndroidUseManagedDesignTimeResourceGenerator>False</AndroidUseManagedDesignTimeResourceGenerator>
While previous versions of Visual Studio had that feature turned off by default, the latest VS2017 update (15.7.3) has it turned on. 虽然以前版本的Visual Studio默认关闭了该功能,但最新的VS2017更新(15.7.3)已打开。 That feature generates a second Resources.Designer.cs file that results in the ambiguous reference issue.
该功能会生成第二个Resources.Designer.cs文件,导致模糊的引用问题。
You can verify by hovering over the resource constant with the Intellisense error, right-clicking, selecting "Go To Definition", and selecting the 1st item, which takes you to a Resource.Designer.cs file. 您可以通过将智能感知错误悬停在资源常量上进行验证,右键单击,选择“转到定义”,然后选择第一个项目,该项目将转到Resource.Designer.cs文件。 If you repeat, but select the 2nd one, you'll be taken to a different Resource.Designer.cs file.
如果您重复,但选择第二个,您将被带到另一个Resource.Designer.cs文件。 One of these points to the obj\\Debug\\designtime\\Resource.Designer.cs file.
其中一个指向obj \\ Debug \\ designtime \\ Resource.Designer.cs文件。 By setting that feature to False as described above, that Resource.Designer.cs file in the obj\\Debug\\designtime path will not be generated.
通过如上所述将该功能设置为False,将不会生成obj \\ Debug \\ designtime路径中的Resource.Designer.cs文件。
https://developer.xamarin.com/releases/android/xamarin.android_8/xamarin.android_8.1/#design-time-builds-managed-resource-parser https://developer.xamarin.com/releases/android/xamarin.android_8/xamarin.android_8.1/#design-time-builds-managed-resource-parser
https://github.com/dotnet/project-system/blob/master/docs/design-time-builds.md#design-time-builds https://github.com/dotnet/project-system/blob/master/docs/design-time-builds.md#design-time-builds
Hope this helps! 希望这可以帮助!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.